将复数名词转换为单数

时间:2022-04-11 10:16:20

This is done using SimpleNLG Java API

这是使用SimpleNLG Java API完成的

I want to convert "elves" to elf. The code below converts from singular to plural, how can it be modified to convert from plural to singular ?

我想把“精灵”变成精灵。下面的代码从单数转换为复数,如何修改为从复数转换为单数?

final XMLLexicon xmlLexicon = new XMLLexicon();
final WordElement word = xmlLexicon.getWord("elves", LexicalCategory.NOUN);
final InflectedWordElement pluralWord = new InflectedWordElement(word);
pluralWord.setPlural(true);
final Realiser realiser = new Realiser(xmlLexicon);
System.out.println(realiser.realise(pluralWord));

1 个解决方案

#1


1  

There apparently is no setSingular() method in this API (I was really banking on that one, and I think it's kind of funny there isn't one for something like this.) Also there is no setPlural() method either as of V4.

显然在这个API中没有setSingular()方法(我真的很喜欢那个,我觉得有点像这样的东西很有趣。)从V4开始也没有setPlural()方法。

[1] Note that in SimpleNLG V4, there are no lexicon methods to directly get inflected variants of a word; in other words, there is no equivalent in V4 of the SimpleNLG V3 getPlural(), getPastParticiple(), etc. methods. It is possible in V4 to compute inflected variants of words, but the process is more complicated: basically we need to create an InflectedWordElement around the base form, add appropriate features to this InflectedWordElement, and then realise it.

[1]请注意,在SimpleNLG V4中,没有词典方法可以直接获取单词的变形变体;换句话说,在SimpleNLG V3 getPlural(),getPastParticiple()等方法的V4中没有等价物。在V4中可以计算单词的变形,但是过程更复杂:基本上我们需要在基本表单周围创建一个InflectedWordElement,为这个InflectedWordElement添加适当的功能,然后实现它。

I think this might do the trick: (I did not test it because I do not have time right now.)

我认为这可能会成功:(我没有测试它,因为我现在没有时间。)

final XMLLexicon xmlLexicon = new XMLLexicon();
final WordElement word = xmlLexicon.getWord("elves", LexicalCategory.NOUN);
final InflectedWordElement singularWord = new InflectedWordElement(word);
WordElement sw = singularWord.getBaseWord();
final Realiser realiser = new Realiser(xmlLexicon);
System.out.println(realiser.realise(sw));

If that does not work you or anyone else is welcome to look here(docs) and here(tutorial) for the answer.

如果这不起作用,欢迎您或其他任何人在这里(文档)和这里(教程)寻找答案。

#1


1  

There apparently is no setSingular() method in this API (I was really banking on that one, and I think it's kind of funny there isn't one for something like this.) Also there is no setPlural() method either as of V4.

显然在这个API中没有setSingular()方法(我真的很喜欢那个,我觉得有点像这样的东西很有趣。)从V4开始也没有setPlural()方法。

[1] Note that in SimpleNLG V4, there are no lexicon methods to directly get inflected variants of a word; in other words, there is no equivalent in V4 of the SimpleNLG V3 getPlural(), getPastParticiple(), etc. methods. It is possible in V4 to compute inflected variants of words, but the process is more complicated: basically we need to create an InflectedWordElement around the base form, add appropriate features to this InflectedWordElement, and then realise it.

[1]请注意,在SimpleNLG V4中,没有词典方法可以直接获取单词的变形变体;换句话说,在SimpleNLG V3 getPlural(),getPastParticiple()等方法的V4中没有等价物。在V4中可以计算单词的变形,但是过程更复杂:基本上我们需要在基本表单周围创建一个InflectedWordElement,为这个InflectedWordElement添加适当的功能,然后实现它。

I think this might do the trick: (I did not test it because I do not have time right now.)

我认为这可能会成功:(我没有测试它,因为我现在没有时间。)

final XMLLexicon xmlLexicon = new XMLLexicon();
final WordElement word = xmlLexicon.getWord("elves", LexicalCategory.NOUN);
final InflectedWordElement singularWord = new InflectedWordElement(word);
WordElement sw = singularWord.getBaseWord();
final Realiser realiser = new Realiser(xmlLexicon);
System.out.println(realiser.realise(sw));

If that does not work you or anyone else is welcome to look here(docs) and here(tutorial) for the answer.

如果这不起作用,欢迎您或其他任何人在这里(文档)和这里(教程)寻找答案。