本文整理汇总了Java中simplenlg.phrasespec.SPhraseSpec.setFeature方法的典型用法代码示例。如果您正苦于以下问题:Java SPhraseSpec.setFeature方法的具体用法?Java SPhraseSpec.setFeature怎么用?Java SPhraseSpec.setFeature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simplenlg.phrasespec.SPhraseSpec
的用法示例。
在下文中一共展示了SPhraseSpec.setFeature方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEx01
import simplenlg.phrasespec.SPhraseSpec; //导入方法依赖的package包/类
@Test
public void testEx01() {
NPPhraseSpec subject = this.phraseFactory.createNounPhrase("eles");
NPPhraseSpec object = this.phraseFactory.createNounPhrase("receita");
object.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
object.setSpecifier("as");
SPhraseSpec s = this.phraseFactory.createClause(subject, "trazer", object);
s.setFeature(Feature.TENSE, Tense.PAST);
Assert.assertEquals("Eles trouxeram as receitas.", getResult(s));
}
示例2: testEx04
import simplenlg.phrasespec.SPhraseSpec; //导入方法依赖的package包/类
@Test
public void testEx04() {
// TODO it should be possible to pack the subject "quem gosta" within
// a VP instead of within an NP, as it is. Something in the French
// grammar messes with the syntax if one does this.
NPPhraseSpec subject = this.phraseFactory.createNounPhrase("quem gosta");
NPPhraseSpec object = this.phraseFactory.createNounPhrase("capela");
object.setSpecifier("a");
SPhraseSpec s = this.phraseFactory.createClause(subject, "visitar", object);
s.setFeature(Feature.MODAL, "dever");
Assert.assertEquals("Quem gosta deve visitar a capela.", getResult(s));
}
示例3: testEx05
import simplenlg.phrasespec.SPhraseSpec; //导入方法依赖的package包/类
@Test
public void testEx05() {
NPPhraseSpec subject = this.phraseFactory.createNounPhrase("morador");
subject.setSpecifier("os");
subject.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
NPPhraseSpec object = this.phraseFactory.createNounPhrase("cidade");
object.setSpecifier("a");
SPhraseSpec s = this.phraseFactory.createClause(subject, "atravessar", object);
s.setFeature(Feature.MODAL, "precisar");
Assert.assertEquals("Os moradores precisam atravessar a cidade.", getResult(s));
}
示例4: testEx07
import simplenlg.phrasespec.SPhraseSpec; //导入方法依赖的package包/类
@Test
public void testEx07() {
PPPhraseSpec pp = this.phraseFactory.createPrepositionPhrase("a");
NPPhraseSpec np = this.phraseFactory.createNounPhrase("direita");
np.setSpecifier("a");
pp.addComplement(np);
SPhraseSpec s = this.phraseFactory.createClause(null, "virar", pp);
s.setFeature(Feature.TENSE, Tense.IMPERATIVE);
Assert.assertEquals("Vire à direita.", getResult(s));
}
示例5: testEx09
import simplenlg.phrasespec.SPhraseSpec; //导入方法依赖的package包/类
@Test
public void testEx09() {
NPPhraseSpec np = this.phraseFactory.createNounPhrase("quem gosta");
NPPhraseSpec np2 = this.phraseFactory.createNounPhrase("ponte");
np2.setSpecifier("a");
SPhraseSpec s = this.phraseFactory.createClause(np, "cruzar", np2);
s.setFeature(Feature.MODAL, "poder");
Assert.assertEquals("Quem gosta pode cruzar a ponte.", getResult(s));
}
示例6: testEx12
import simplenlg.phrasespec.SPhraseSpec; //导入方法依赖的package包/类
@Test
public void testEx12() {
NPPhraseSpec np = this.phraseFactory.createNounPhrase("as crianças");
np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
SPhraseSpec s = this.phraseFactory.createClause(np, "seguir", "a trilha");
s.setFeature(Feature.TENSE, Tense.PERSONAL_INFINITIVE);
Assert.assertEquals("As crianças seguirem a trilha.", getResult(s));
}
示例7: main
import simplenlg.phrasespec.SPhraseSpec; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
// Lexicon lexicon = Lexicon.getDefaultLexicon();
Lexicon lexicon = new XMLLexicon();
NLGFactory nlgFactory = new NLGFactory(lexicon);
Realiser realiser = new Realiser();
// realiser.setDebugMode(true);
SPhraseSpec ex = nlgFactory.createClause();
NPPhraseSpec locatum = nlgFactory.createNounPhrase("edifício");
// System.out.println(ex+"\n");
locatum.setSpecifier("o");
// System.out.println(ex+"\n");
ex.setSubject(locatum);
ex.setVerb("ficar");
PPPhraseSpec generalizedLocation = nlgFactory.createPrepositionPhrase();
NPPhraseSpec relatum = nlgFactory.createNounPhrase("praça");
relatum.setSpecifier("a");
generalizedLocation.addComplement(relatum);
generalizedLocation.setPreposition("em");
// System.out.println(ex+"\n");
ex.addComplement(generalizedLocation);
// System.out.println(ex+"\n");
// System.out.println(locatum+"\n");
// System.out.println(generalizedLocation+"\n");
String target = "O edifício fica na praça.";
String gloss = "The building lies at the square.";
String output = realiser.realiseSentence(ex);
if (!output.equals(target)) {
System.out.println("* " + output + " TARGET: " + target);
} else {
System.out.println(output + " (" + gloss + ")");
}
// EX100
String target100 = "Mariah Carey é uma cantora.";
String gloss100 = "Mariah Carey is a singer.";
SPhraseSpec ex100 = nlgFactory.createClause();
NPPhraseSpec subject100 = nlgFactory.createNounPhrase("Mariah Carey");
// subject100.setFeature(Feature.PERSON, Person.THIRD);
ex100.setSubject(subject100);
ex100.setVerb("ser");
ex100.setFeature(Feature.TENSE, Tense.PRESENT);
NPPhraseSpec object100 = nlgFactory.createNounPhrase("cantor");
object100.setFeature(LexicalFeature.GENDER, Gender.FEMININE);
object100.setSpecifier("um");
ex100.setObject(object100);
String output100 = realiser.realiseSentence(ex100);
System.out.println(output100);
}