0
我使用NLTK查找一致性,但我找不到如何獲得所有結果&將它們放入列表或設置。獲取所有結果frm NLTK一致性
ex :text.concordance(word)
PRINT just the 25 first results
我使用NLTK查找一致性,但我找不到如何獲得所有結果&將它們放入列表或設置。獲取所有結果frm NLTK一致性
ex :text.concordance(word)
PRINT just the 25 first results
TL; DR
text.concordance(lines=100)
從代碼,https://github.com/nltk/nltk/blob/develop/nltk/text.py#L323:
def concordance(self, word, width=79, lines=25):
"""
Print a concordance for ``word`` with the specified context window.
Word matching is not case-sensitive.
:seealso: ``ConcordanceIndex``
"""
if '_concordance_index' not in self.__dict__:
#print("Building index...")
self._concordance_index = ConcordanceIndex(self.tokens,
key=lambda s:s.lower())
self._concordance_index.print_concordance(word, width, lines)