joint representation form

This commit is contained in:
Ozbolt Menegatti 2019-05-13 00:26:00 +02:00
parent 401698409e
commit 87712128be

View File

@ -850,7 +850,7 @@ class Writer:
def from_word(self, word):
if word is None:
return "" * self.length()
return [""] * self.length()
elif self.all:
return [word.id, word.text, word.lemma, word.msd]
else:
@ -879,17 +879,22 @@ class Writer:
rows = []
for m, reason, cid in matches:
to_write = []
representation = ""
for idx, comp in enumerate(components):
idx = str(idx + 1)
word = m[idx] if idx in m else None
to_write.extend(self.from_word(word))
representation += " " + to_write[-1]
# make them equal size
to_write.extend([""] * (MAX_NUM_COMPONENTS * self.length() - len(to_write)))
to_write = [structure_id] + to_write + [colocation_ids.to_id(cid)]
if not self.all:
representation = re.sub(' +', ' ', representation)
to_write.append(representation.strip())
if colocation_ids.should_write(cid):
to_write.append(colocation_ids.num(cid))
colocation_ids.set_written(cid)