Skip to content

Commit

Permalink
Add a function to sort the features on all words in a document
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Dec 18, 2024
1 parent 8e8b7db commit f00bb89
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stanza/models/common/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,16 @@ def build_ents(self):
self.ents += s_ents
return self.ents

def sort_features(self):
""" Sort the features on all the words... useful for prototype treebanks, for example """
for sentence in self.sentences:
for word in sentence.words:
if not word.feats:
continue
pieces = word.feats.split("|")
pieces = sorted(pieces)
word.feats = "|".join(pieces)

def iter_words(self):
""" An iterator that returns all of the words in this Document. """
for s in self.sentences:
Expand Down

0 comments on commit f00bb89

Please sign in to comment.