簡體   English   中英

從NLTK一致性中獲取所有結果

[英]Get all results from NLTK concordance

我正在使用NLTK來查找單詞的一致性,但是我不知道如何獲取所有結果並將它們放入listset

例如:

text.concordance(word)

僅顯示前25個結果。

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM