Oznaczanie części mowy zwykorzystaniem korpusu Browna| 103
elif char == CorpusParser.SPLITTER:
parse_word = False
elif char in CorpusParser.STOP:
ngrams.pop (0)
ngrams.append (CorpusParser.TagWord (word, pos))
yield copy (ngrams)
word = ''
pos = ''
parse_word = True
elif parse_word:
word += char
else:
pos += char
if len (word) > 0 and len (pos) > 0:
ngrams.pop (0)
ngrams.append (CorpusParser.TagWord (word, pos))
yield copy (ngrams)
Tak jak wpoprzednich rozdziałach implementacja parsera przy użyciu
each_char
jest
zwykle najbardziej wydajnym sposobem parsowania tekstów wjęzyku Python. Teraz
możemy przejść dodużo bardziej ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.