Skip to content

Commit f84147c

Browse files
committed
both MWT and Node should have property words
1 parent acde65d commit f84147c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

udapi/block/write/vislcg.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ def process_tree(self, tree):
6464
# Print the line with forms and optional upos tags and feats.
6565
for token in tree.token_descendants:
6666
print('"<%s>"' % self._escape(token.form))
67-
try:
68-
words = token.words
69-
except AttributeError:
70-
words = [token]
67+
words = token.words
7168
print('\t' + self._node(words[0]))
7269
for nonfirst_mwt_word in words[1:]:
7370
print('\t\t' + self._node(nonfirst_mwt_word))

udapi/core/node.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,18 @@ def multiword_token(self):
884884
"""
885885
return self._mwt
886886

887+
@property
888+
def words(self):
889+
"""Return one-item list with this node.
890+
891+
This property is there for compatibility with udapi.core.mwt.MWT.words.
892+
So that it is possible to use code such as:
893+
for token in root.token_descendants:
894+
words = token.words
895+
...
896+
"""
897+
return [self]
898+
887899
def is_nonprojective(self):
888900
"""Is the node attached to its parent non-projectively?
889901

0 commit comments

Comments
 (0)