File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,7 @@ def process_tree(self, tree):
64
64
# Print the line with forms and optional upos tags and feats.
65
65
for token in tree .token_descendants :
66
66
print ('"<%s>"' % self ._escape (token .form ))
67
- try :
68
- words = token .words
69
- except AttributeError :
70
- words = [token ]
67
+ words = token .words
71
68
print ('\t ' + self ._node (words [0 ]))
72
69
for nonfirst_mwt_word in words [1 :]:
73
70
print ('\t \t ' + self ._node (nonfirst_mwt_word ))
Original file line number Diff line number Diff line change @@ -884,6 +884,18 @@ def multiword_token(self):
884
884
"""
885
885
return self ._mwt
886
886
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
+
887
899
def is_nonprojective (self ):
888
900
"""Is the node attached to its parent non-projectively?
889
901
You can’t perform that action at this time.
0 commit comments