python - 如何自动进行词性标注和词形还原
问题描述
我们可以在python中使用wordnet。
假设我们给出文本:
"International companies had interns"
然后我们可以手动进行词性标注:
tokens = ["International","companies","had","interns"]
word_type = {"International":wordnet.ADJ,"companies":wordnet.NOUN,"had":wordnet.VERB,"interns":wordnet.NOUN}
lemmatizer=WordNetLemmatizer()
token_list=[]
for token in tokens:
token_list.append(lemmatizer.lemmatize(token,word_type[token]))
我想避免代码的手动部分并自动执行:
word_type = {"International":wordnet.ADJ,"companies":wordnet.NOUN,"had":wordnet.VERB,"interns":wordnet.NOUN}
#need to do above automatically from given text
解决方案
推荐阅读
- ruby-on-rails - 使用 minitest mocha 时如何为存根指定函数?
- java - 在 setArguments 之后调用 onCreateView 时?
- opencart - 来自模块的 OpenCart 3 标题图像
- flutter - Flutter 中的变量突然为空
- r - Json 到 Dataframe:错误:1:nrow(test) 中的错误:长度为 0 的参数
- excel - 如何连接到 Oracle 数据库并通过 Excel 运行查询
- django - 传单地图在 Django 模板块中的尺寸不正确
- c - 杨的 XPath current()
- shell - 一次在一个目录下构建多个 go 插件
- docker - Dockerfile 和 chown 权限