joint representation form
This commit is contained in:
parent
401698409e
commit
87712128be
7
wani.py
7
wani.py
|
@ -850,7 +850,7 @@ class Writer:
|
||||||
|
|
||||||
def from_word(self, word):
|
def from_word(self, word):
|
||||||
if word is None:
|
if word is None:
|
||||||
return "" * self.length()
|
return [""] * self.length()
|
||||||
elif self.all:
|
elif self.all:
|
||||||
return [word.id, word.text, word.lemma, word.msd]
|
return [word.id, word.text, word.lemma, word.msd]
|
||||||
else:
|
else:
|
||||||
|
@ -879,17 +879,22 @@ class Writer:
|
||||||
rows = []
|
rows = []
|
||||||
for m, reason, cid in matches:
|
for m, reason, cid in matches:
|
||||||
to_write = []
|
to_write = []
|
||||||
|
representation = ""
|
||||||
|
|
||||||
for idx, comp in enumerate(components):
|
for idx, comp in enumerate(components):
|
||||||
idx = str(idx + 1)
|
idx = str(idx + 1)
|
||||||
word = m[idx] if idx in m else None
|
word = m[idx] if idx in m else None
|
||||||
to_write.extend(self.from_word(word))
|
to_write.extend(self.from_word(word))
|
||||||
|
representation += " " + to_write[-1]
|
||||||
|
|
||||||
# make them equal size
|
# make them equal size
|
||||||
to_write.extend([""] * (MAX_NUM_COMPONENTS * self.length() - len(to_write)))
|
to_write.extend([""] * (MAX_NUM_COMPONENTS * self.length() - len(to_write)))
|
||||||
to_write = [structure_id] + to_write + [colocation_ids.to_id(cid)]
|
to_write = [structure_id] + to_write + [colocation_ids.to_id(cid)]
|
||||||
|
|
||||||
if not self.all:
|
if not self.all:
|
||||||
|
representation = re.sub(' +', ' ', representation)
|
||||||
|
to_write.append(representation.strip())
|
||||||
|
|
||||||
if colocation_ids.should_write(cid):
|
if colocation_ids.should_write(cid):
|
||||||
to_write.append(colocation_ids.num(cid))
|
to_write.append(colocation_ids.num(cid))
|
||||||
colocation_ids.set_written(cid)
|
colocation_ids.set_written(cid)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user