2
我正在处理文本搜索项目,并使用文本blob从文本中搜索句子。 TextBlob有效地使用关键字拉取所有句子。然而,对于有效的研究,我也想提出一个句子,之后我无法确定。使用python进行文本搜索
下面是我使用的代码:
def extraxt_sents(Text,word):
search_words = set(word.split(','))
sents = ''.join([s.lower() for s in Text])
blob = TextBlob(sents)
matches = [str(s) for s in blob.sentences if search_words & set(s.words)]
print search_words
print(matches)
你的代码中是否有一些缩进错误? –
我建议,看看'nltk' – cengizkrbck
@cengizkrbck TextBlob似乎比nltk工作得更好。我一个,一个不能在前一个和后一个数字中找出一个句子。 –