這是使用SimpleNLG Java API完成的將複數名詞轉換爲單數
我想將「精靈」轉換爲精靈。下面的代碼從單數轉換爲複數,如何修改將其從複數轉換爲單數?
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));
也許試試pluralWord.setPlural(false);而不是pluralWord.setPlural(true); ...你是什麼意思的「做相反的事情」?它並不需要單數,是嗎? – Wolf
我不認爲你可以:http://stackoverflow.com/questions/1377020/can-you-programmatically-detect-pluralizations-of-english-words-and-derive-the –
@RC .:你爲什麼也這樣覺得?當然,你可以通過字典把複數變成單數,反之亦然......你的鏈接不會另有說明... – Wolf