Skip to content

Commit acde65d

Browse files
committed
prevent creating nested MWTs
1 parent 59a8329 commit acde65d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

udapi/core/root.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ def create_multiword_token(self, words=None, form=None, misc=None):
176176
form: string representing the surface form of the new MWT
177177
misc: misc attribute of the new MWT
178178
"""
179+
# Nested or overlapping MWTs are not allowed in CoNLL-U,
180+
# so first remove all previous MWTs containing any of words.
181+
for w in words:
182+
if w.multiword_token:
183+
w.multiword_token.remove()
184+
# Now, create the new MWT.
179185
mwt = MWT(words, form, misc, root=self)
180186
self._mwts.append(mwt)
181187
if words[-1].misc["SpaceAfter"] == "No":

0 commit comments

Comments
 (0)