假设我有一串众所周知的短语,比如:{“我爱你”,“你的母亲是一个.”,“我想我怀孕了”……让我们来说说1000这样的话吧。现在,我希望用户在文本框中输入免费的文本,并放入某种NLP引擎来消化文本,并从“拉”中找到与文本相关的10个最相关的短语。
发布于 2013-09-17 10:17:07
看来TextBlob和ConeptNet已经足够解决这个问题了!
发布于 2013-09-17 02:47:20
TextBlob是一个用于Python的易于使用的NLP库,它是免费和开放源码的(许可使用麻省理工学院许可)。它为优秀的NLTK和模式库提供了一个很好的包装。
解决问题的一个简单方法是从给定的文本中提取名词短语。
下面是来自TextBlob文档的一个例子。
from text.blob import TextBlob
text = '''
The titular threat of The Blob has always struck me as the ultimate movie
monster: an insatiably hungry, amoeba-like mass able to penetrate
virtually any safeguard, capable of--as a doomed doctor chillingly
describes it--"assimilating flesh on contact.
Snide comparisons to gelatin be damned, it's a concept with the most
devastating of potential consequences, not unlike the grey goo scenario
proposed by technological theorists fearful of
artificial intelligence run rampant.
'''
blob = TextBlob(text)
print(blob.noun_phrases)
# => ['titular threat', 'blob', 'ultimate movie monster', ...]这可能是个起点。在那里,您可以尝试其他方法,如注释或TF-以色列国防军中提到的相似方法。TextBlob还使名词短语提取的互换模型变得容易。
完全披露:我是TextBlob的作者。
https://stackoverflow.com/questions/18837021
复制相似问题