gpt4 book ai didi

python - 识别python中的动词时态

转载 作者:太空狗 更新时间:2023-10-30 01:51:24 25 4
gpt4 key购买 nike

如何使用Python + NLTK 来判断一个句子是否指代过去/现在/ future ?

我可以仅使用词性标记来做到这一点吗?这似乎有点不准确,在我看来我需要考虑句子上下文而不仅仅是单词。

对另一个可以做到这一点的图书馆有什么建议吗?

最佳答案

词性标记 - 它为您提供了让您查看动词时态的标记 - 已经考虑了句子上下文,因此它解决了您的问题。通过上下文的准确性。事实上,词性标注本身并不能很好地处理单词!从Ch. 5 of the NLTK book看这个例子给定句子中的上下文,让 NLTK 区分名词和动词给定的同音异义词(即给定像 permit 这样的词,它可以作为动词和名词具有不同的含义):

Let's look at another example, this time including some homonyms:

  >>> text = nltk.word_tokenize("They refuse to permit us to obtain the refuse permit")
>>> nltk.pos_tag(text)
[('They', 'PRP'), ('refuse', 'VBP'), ('to', 'TO'), ('permit', 'VB'), ('us', 'PRP'),
('to', 'TO'), ('obtain', 'VB'), ('the', 'DT'), ('refuse', 'NN'), ('permit', 'NN')]

Notice that refuse and permit both appear as a present tense verb(VBP) and a noun (NN). E.g. refUSE is a verb meaning "deny," whileREFuse is a noun meaning "trash" (i.e. they are not homophones). Thus,we need to know which word is being used in order to pronounce thetext correctly. (For this reason, text-to-speech systems usuallyperform POS-tagging.)

关于python - 识别python中的动词时态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19966345/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com