本文介绍了在Python中使用NLTK的短语的一致性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使NLTK中的短语保持一致?

Is it possible to get concordance for a phrase in NLTK?

import nltk
from nltk.corpus import PlaintextCorpusReader

corpus_loc = "c://temp//text//"
files = ".*\.txt"
read_corpus = PlaintextCorpusReader(corpus_loc, files)
corpus  = nltk.Text(read_corpus.words())
test = nltk.TextCollection(corpus_loc)

corpus.concordance("claim")

例如上面的返回

on okay okay okay i can give you the claim number and my information and
 decide on the shop okay okay so the claim number is xxxx - xx - xxxx got

,现在,如果我尝试使用corpus.concordance("claim number"),它将不起作用...我确实有使用.partition()方法执行此操作的代码,并且在同一代码上进行了进一步的编码...但我想知道是否可以使用concordance进行同样的操作.

and now if I try corpus.concordance("claim number") it does not work... I do have the code to do this with just by using .partition() method and some further coding on the same... but I'm wondering if it's possible to do the same using concordance.

推荐答案

根据此问题,它不是(还)可以使用concordance()函数搜索多个单词.

According to this issue it is not (yet) possible to search for multiple words with the concordance() function.

这篇关于在Python中使用NLTK的短语的一致性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 05:22