7 Used to define subject/object noun ordering from a given verb. 8 Creates a left/right dict of nouns, wherein given a threshold, 9 verbs with respective nouns within that threshold on either side 10 can be thought of as subject (left) or object (right) for 11 bitstring state generation for encoding. 36 G.add_edge(k, self.
verb)
37 return G, v_idx, l_idx
50 G.add_edge(self.
verb, k)
51 return G, v_idx, r_idx
56 for word_v, locations_v
in corpus_list_v.items():
58 if len(locations_v[1]) <= 1:
62 lv = locations_v[1][:, np.newaxis]
63 for word_n, locations_n
in corpus_list_n.items():
64 dists = np.ndarray.flatten(locations_n[1] - lv)
65 if not isinstance(dists, np.int64):
66 vals = [x
for x
in dists
if np.abs(x) <= dist_cutoff]
68 vals = [dists]
if np.abs(dists) <= dist_cutoff
else []
70 dl = [(i,i_pos)
for i,i_pos
in zip(vals, locations_n[1])
if i < 0]
71 dr = [(i,i_pos)
for i,i_pos
in zip(vals, locations_n[1])
if i > 0]
79 for kl,vl
in v.left_nouns.items():
80 for kr,vr
in v.right_nouns.items():
81 lr_dist = vr[0][1] - vl[0][1]
82 if lr_dist < 2*dist_cutoff
and lr_dist > 0:
83 v.lr_nouns.update({(kl,kr) : lr_dist})
84 if len(v.left_nouns) >1
and len(v.right_nouns) >1
and len(v.lr_nouns) >1:
def createRGraph(self, G=None)
def __init__(self, verb=None, pos=[])
def calc_verb_noun_pairings(corpus_list_v, corpus_list_n, dist_cutoff, max_terms=5)
def addL(self, noun, pos)
def addR(self, noun, pos)
def createLGraph(self, G=None)