- 词干提取:
作用:去除后缀并输出词的词干。
porterStremmer/LancasterStremmer:
from nltk import PorterStemmer ,LancasterStemmer,word_tokenize raw="My name is Maximus Decimus Meridius,commander of the armies of the North,General of the Felix legions and loyal servant to the true emperor\ ,Marcus Aurelius .Father to a mudered son, husband to a murdered wife .And I will have my vengeance , in this life or the next." token=word_tokenize(raw)
讯享网
output:

讯享网
讯享网porter =PorterStemmer() pStems =[porter.stem(t) for t in token] print(pStems)
output:

porter =LancasterStemmer() pStems =[porter.stem(t) for t in token] print(pStems)
output:



- 词形还原:字典匹配的过程,不仅仅是简单的去除或者替换后缀(优先使用)
讯享网from nltk import word_tokenize , PorterStemmer,WordNetLemmatizer lemmatizer=WordNetLemmatizer() print([lemmatizer.lemmatize(t) for t in ['armies','legions']])
output:

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/101376.html