SimpleNLG:我们如何指定数量?

SimpleNLG: how we specify the quantity?

我的问题是如何在名词短语中指定数量? 例如:

NPPhraseSpec np = nlgFactory.createNounPhrase("", "apple");

例如,如何生成“5 个苹果”? 一种解决方案是放置一个预修饰符,代码为:

    Lexicon lexicon = Lexicon.getDefaultLexicon();
    NLGFactory nlgFactory = new NLGFactory(lexicon);
    Realiser realiser = new Realiser();
    NPPhraseSpec np = nlgFactory.createNounPhrase("", "apple");
    np.addPreModifier("5");
    np.setPlural(true);
    System.out.println(realiser.realiseSentence(np));

但是,难道没有另一种解决方案可以处理数字并自动将名词变成复数吗?

恐怕没有内置函数可以执行此操作。

但是,如果您将 SimpleNLG 插入更大的管道,您可以通过在 SimpleNLG 之前计算数量来自动执行此操作。例如,假设您通过计算 NP(苹果、香蕉、梨等)的头部的数量 n 得到“5”:如果 n 大于 1,则将 NP 的复数设置为真; else 什么也不做,因为 plural=false 是默认的。您甚至可以将其增加到更高级的值,例如:如果 n 等于 0,则添加 "no" 作为说明符。