I use the Numpy library and I convert sentences (sents
) into an array of int32 (words_idxs
), but I don't know how to use Numpy to reverse this step. That is, convert the array of int32 into a sentence.
def build_input_data(voc, sents, tags, tags_uni, cues, scopes, labels):
words_idxs = [np.array([voc['w2idxs'][w] if w in voc['w2idxs'] else voc['w2idxs']["<UNK>"] for w in sent],dtype=np.int32) for sent in sents]
tags_idxs = [np.array([voc['t2idxs'][t] for t in tag_sent],dtype=np.int32) for tag_sent in tags]
tags_uni_idxs = [np.array([voc['tuni2idxs'][tu] for tu in tag_sent_uni],dtype=np.int32) for tag_sent_uni in tags_uni]
y_idxs = [np.array([voc['y2idxs'][y] for y in y_array],dtype=np.int32) for y_array in labels]
cues_idxs = [np.array([1 if c=="CUE" else 0 for c in c_array],dtype=np.int32) for c_array in cues]
scope_idxs = [np.array([1 if s=="S" else 0 for s in s_array],dtype=np.int32) for s_array in scopes]
return words_idxs, tags_idxs, tags_uni_idxs, cues_idxs, scope_idxs, y_idxs