将复数名词转换为单数 NLP
convert plural nouns to singular NLP
我有一个复数名词列表。比如apples, oranges等等。我想把它们都变成单数名词。有没有用于此目的的工具?最好是 Java 或 Python.
例如有https://pypi.python.org/pypi/inflect图书馆。
示例:
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')
来源:
您可以使用 Java 库,SimpleNLG (https://github.com/simplenlg/simplenlg)
或使用其 Python 包装器 PyNLG (https://github.com/mapado/pynlg) (pip install pynlg)。
它拥有丰富的词库,可以识别许多对象的数字形式。您可以设置它的特征并打印出它的单数形式。它非常适合简单的任务。
Lexicon lexicon = Lexicon.getDefaultLexicon();
NLGFactory nlgFactory = new NLGFactory(lexicon);
NPPhraseSpec subject = nlgFactory.createNounPhrase("apples");
subject.setFeature(Feature.NUMBER, NumberAgreement.SINGULAR);
会给"Apple"。默认情况下,simpleNLG 会将它可以识别的所有名词短语转换为单数。
我有一个复数名词列表。比如apples, oranges等等。我想把它们都变成单数名词。有没有用于此目的的工具?最好是 Java 或 Python.
例如有https://pypi.python.org/pypi/inflect图书馆。
示例:
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')
来源:
您可以使用 Java 库,SimpleNLG (https://github.com/simplenlg/simplenlg) 或使用其 Python 包装器 PyNLG (https://github.com/mapado/pynlg) (pip install pynlg)。
它拥有丰富的词库,可以识别许多对象的数字形式。您可以设置它的特征并打印出它的单数形式。它非常适合简单的任务。
Lexicon lexicon = Lexicon.getDefaultLexicon();
NLGFactory nlgFactory = new NLGFactory(lexicon);
NPPhraseSpec subject = nlgFactory.createNounPhrase("apples"); subject.setFeature(Feature.NUMBER, NumberAgreement.SINGULAR);
会给"Apple"。默认情况下,simpleNLG 会将它可以识别的所有名词短语转换为单数。