Java 将复数名词转换为单数NLP
我有一个复数名词的列表。例如,苹果、桔子等。我想把它们全部转换成单数名词。是否有用于此目的的工具?首选Java或Python。有示例库 例如:Java 将复数名词转换为单数NLP,java,python,nlp,Java,Python,Nlp,我有一个复数名词的列表。例如,苹果、桔子等。我想把它们全部转换成单数名词。是否有用于此目的的工具?首选Java或Python。有示例库 例如: import inflect p = inflect.engine() words = ["apples", "sheep", "oranges", "cats", "people", "dice", "pence"] for word in words: print("The singular of ", word, " is ", p.s
import inflect
p = inflect.engine()
words = ["apples", "sheep", "oranges", "cats", "people", "dice", "pence"]
for word in words:
print("The singular of ", word, " is ", p.singular_noun(word))
输出:
('The singular of ', 'apples', ' is ', 'apple')
('The singular of ', 'sheep', ' is ', 'sheep')
('The singular of ', 'oranges', ' is ', 'orange')
('The singular of ', 'cats', ' is ', 'cat')
('The singular of ', 'people', ' is ', 'person')
('The singular of ', 'dice', ' is ', 'die')
('The singular of ', 'pence', ' is ', 'pence')
资料来源:
将给“苹果”。默认情况下,SimpleLg会将它可以识别的所有名词短语转换为单数。我已经尝试过这个模块,它一般都可以工作,但并不完美。例如,如果您传递'as'或'does','means',它将输出'a'和'doe','means',这可能不是我们想要的。