获取词干关键字的所有叶词

2024-04-20 05:05:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找类似于不堵塞的东西。有没有一种方法可以得到所有可能的有共同词干的单词列表。差不多

>>> get_leaf_words('play')
>>> ['player', 'play', 'playing' ... ]

Tags: 方法列表playget单词playerwordsleaf
1条回答
网友
1楼 · 发布于 2024-04-20 05:05:04

上述问题的解决办法:https://github.com/gutfeeling/word_forms!感谢@Divyanshu Srivastava

>>> from word_forms.word_forms import get_word_forms
>>> get_word_forms("president")
>>> {'n': {'presidents', 'presidentships', 'presidencies', 'presidentship', 'president', 'presidency'},
     'a': {'presidential'},
     'v': {'preside', 'presided', 'presiding', 'presides'},
     'r': {'presidentially'}}
>>> get_word_forms("elect")
>>> {'n': {'elects', 'electives', 'electors', 'elect', 'eligibilities', 'electorates', 'eligibility', 'elector', 'election', 'elections', 'electorate', 'elective'},
     'a': {'eligible', 'electoral', 'elective', 'elect'},
     'v': {'electing', 'elects', 'elected', 'elect'},
     'r': set()}


先前的答复:

反向词干分析是不可能的,因为大多数词干分析器使用应用于原始单词的某些规则集创建基词

但是有一种称为“实现”(或“表面实现”)的反向柠檬化

您可以使用一些公开的柠檬化数据集/字典来实现这一点

示例:https://raw.githubusercontent.com/richardwilly98/elasticsearch-opennlp-auto-tagging/master/src/main/resources/models/en-lemmatizer.dict[ApacheOpenNLP]

我在Python中找不到直接库,但在Java(pynlg)中找到了一个

此外:如果你有足够多的原始单词,你可以创建一个反向字典来进行柠檬化或词干分析

相关问题 更多 >