当前位置: 首页>>代码示例>>Java>>正文


Java SPhraseSpec类代码示例

本文整理汇总了Java中simplenlg.phrasespec.SPhraseSpec的典型用法代码示例。如果您正苦于以下问题:Java SPhraseSpec类的具体用法?Java SPhraseSpec怎么用?Java SPhraseSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SPhraseSpec类属于simplenlg.phrasespec包,在下文中一共展示了SPhraseSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToPhrases

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
/**
 * Converts a collection of triples into a list of phrases.
 *
 * @param triples
 *            the triples
 * @return a list of phrases
 * @throws IOException
 */
public List<SPhraseSpec> convertToPhrases(Collection<Triple> triples, boolean dead, boolean summary)
		throws IOException {
	List<SPhraseSpec> phrases = new ArrayList<>();
	boolean changePronoun = false;
	int sizeOfTriples = triples.size();
	// System.out.println("triples size" + sizeOfTriples);
	int count = 0;
	for (Triple triple : triples) {
		// System.out.println("count of triples" + count);
		if (sizeOfTriples > 2 && count == 2 || count == 1) {
			// System.out.println("usar o seu");
			changePronoun = true;
			phrases.add(convertToPhrase(triple, dead, summary, changePronoun));
		} else {
			// System.out.println("usar o dele");
			phrases.add(convertToPhrase(triple, dead, summary, changePronoun));
		}
		changePronoun = false;
		count++;
	}
	return phrases;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:31,代码来源:TripleConverterPortuguese.java

示例2: testEx02

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
/**
 * This example shows: a) preposition contraction: em + uma = numa b) no
 * preposition contraction: de + São João = de + São João d) preposition
 * contraction: em + o = no e) preposition contraction: de + a = da
 */
@Test
public void testEx02() {
	NPPhraseSpec subject = this.phraseFactory.createNounPhrase("meus", "amigo");
	subject.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	VPPhraseSpec verb = this.phraseFactory.createVerbPhrase("estar");
	NPPhraseSpec place = this.phraseFactory.createNounPhrase("uma", "festa");
	PPPhraseSpec placePhrase = this.phraseFactory.createPrepositionPhrase("em", place);
	NPPhraseSpec type = this.phraseFactory.createNounPhrase("São João");
	PPPhraseSpec typePhrase = this.phraseFactory.createPrepositionPhrase("de", type);
	place.addComplement(typePhrase);
	SPhraseSpec s = this.phraseFactory.createClause(subject, verb, placePhrase);

	Assert.assertEquals("Meus amigos estão numa festa de São João.", getResult(s, "02a"));

	NPPhraseSpec subject2 = this.phraseFactory.createNounPhrase("eu");
	VPPhraseSpec verb2 = this.phraseFactory.createVerbPhrase("estar");
	NPPhraseSpec place2 = this.phraseFactory.createNounPhrase("o", "quarto");
	PPPhraseSpec place2Phrase = this.phraseFactory.createPrepositionPhrase("em", place2);
	NPPhraseSpec place3 = this.phraseFactory.createNounPhrase("a", "minha casa");
	PPPhraseSpec place3Phrase = this.phraseFactory.createPrepositionPhrase("de", place3);
	place2.addComplement(place3Phrase);
	SPhraseSpec s2 = this.phraseFactory.createClause(subject2, verb2, place2Phrase);

	Assert.assertEquals("Eu estou no quarto da minha casa.", getResult(s2, "02b"));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:31,代码来源:Testbed.java

示例3: testEx03

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
/**
 * This example shows a long verb periphrasis.
 * 
 */
@Test
public void testEx03() {
	NPPhraseSpec subject = this.phraseFactory.createNounPhrase("você");
	VPPhraseSpec verb = this.phraseFactory.createVerbPhrase("criar");
	verb.setFeature(Feature.NEGATED, true);
	verb.setFeature(Feature.PROSPECTIVE, true);
	verb.setFeature(Feature.PROGRESSIVE, "ficar");
	NPPhraseSpec object = this.phraseFactory.createNounPhrase("exemplo");
	object.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	SPhraseSpec s = this.phraseFactory.createClause(subject, verb, object);
	NPPhraseSpec subject2 = this.phraseFactory.createNounPhrase("a", "festa");
	VPPhraseSpec verb2 = this.phraseFactory.createVerbPhrase("acabar");
	verb2.setFeature(Feature.TENSE, Tense.IMPERSONAL_INFINITIVE);
	SPhraseSpec s2 = this.phraseFactory.createClause(subject2, verb2);
	s.addPostModifier("até");
	s.addPostModifier(s2);

	Assert.assertEquals("Você não vai ficar criando exemplos até a festa acabar.", getResult(s, "03"));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:24,代码来源:Testbed.java

示例4: testEx17

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testEx17() {
	NPPhraseSpec np = this.phraseFactory.createNounPhrase("que");
	VPPhraseSpec vp = this.phraseFactory.createVerbPhrase("instalar");
	np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	vp.setFeature(Feature.TENSE, Tense.PAST);
	vp.setFeature(Feature.PASSIVE, true);
	PPPhraseSpec pp = this.phraseFactory.createPrepositionPhrase("ao longo de");
	NPPhraseSpec np2 = this.phraseFactory.createNounPhrase("calçadão");
	np2.setSpecifier("o");
	pp.addComplement(np2);
	vp.addPostModifier(pp);
	SPhraseSpec s = this.phraseFactory.createClause(np, vp);

	Assert.assertEquals("Que foram instalados ao longo do calçadão.", getResult(s));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:17,代码来源:Testbed.java

示例5: testEx17b

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testEx17b() {
	NPPhraseSpec np = this.phraseFactory.createNounPhrase("que");
	VPPhraseSpec vp = this.phraseFactory.createVerbPhrase("instalar");
	np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	vp.setFeature(Feature.TENSE, Tense.IMPERFECT);
	vp.setFeature(Feature.PERFECT, true);
	PPPhraseSpec pp = this.phraseFactory.createPrepositionPhrase("ao longo de");
	NPPhraseSpec np2 = this.phraseFactory.createNounPhrase("calçadão");
	np2.setSpecifier("o");
	pp.addComplement(np2);
	vp.addPostModifier(pp);
	SPhraseSpec s = this.phraseFactory.createClause(np, vp);

	Assert.assertEquals("Que tinham instalado ao longo do calçadão.", getResult(s));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:17,代码来源:Testbed.java

示例6: testEx17c

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testEx17c() {
	NPPhraseSpec np = this.phraseFactory.createNounPhrase("que");
	VPPhraseSpec vp = this.phraseFactory.createVerbPhrase("instalar");
	np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	vp.setFeature(Feature.TENSE, Tense.PAST);
	vp.setFeature(Feature.PROGRESSIVE, true);
	PPPhraseSpec pp = this.phraseFactory.createPrepositionPhrase("ao longo de");
	NPPhraseSpec np2 = this.phraseFactory.createNounPhrase("calçadão");
	np2.setSpecifier("o");
	pp.addComplement(np2);
	vp.addPostModifier(pp);
	SPhraseSpec s = this.phraseFactory.createClause(np, vp);

	Assert.assertEquals("Que estiveram instalando ao longo do calçadão.", getResult(s));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:17,代码来源:Testbed.java

示例7: testEx27

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testEx27() {
	VPPhraseSpec vp = this.phraseFactory.createVerbPhrase("dar");
	PPPhraseSpec pp = this.phraseFactory.createPrepositionPhrase("para");
	VPPhraseSpec vp2 = this.phraseFactory.createVerbPhrase("ir");
	vp2.setFeature(Feature.TENSE, Tense.IMPERSONAL_INFINITIVE);
	PPPhraseSpec pp2 = this.phraseFactory.createPrepositionPhrase("de");
	NPPhraseSpec np = this.phraseFactory.createNounPhrase("bar");
	pp2.addComplement(np);
	PPPhraseSpec pp3 = this.phraseFactory.createPrepositionPhrase("em");
	pp3.addComplement(np);
	vp2.addComplement(pp2);
	vp2.addComplement(pp3);
	pp.addComplement(vp2);
	SPhraseSpec s = this.phraseFactory.createClause(vp, pp);

	Assert.assertEquals("Dá para ir de bar em bar.", getResult(s));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:19,代码来源:Testbed.java

示例8: testEx32

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testEx32() {
	VPPhraseSpec vp = this.phraseFactory.createVerbPhrase("chegar"); // chegar
	vp.setFeature(Feature.MODAL, "dar"); // da para chegar
	PPPhraseSpec pp = this.phraseFactory.createPrepositionPhrase("perto de"); // perto
																				// de
	pp.addPreModifier("bem"); // bem perto de
	NPPhraseSpec np = this.phraseFactory.createNounPhrase("as", "quedas"); // as
																			// quedas
	pp.addComplement(np); // bem perto das quedas
	AdvPhraseSpec ap = this.phraseFactory.createAdverbPhrase("em"); // em
	NPPhraseSpec np2 = this.phraseFactory.createNounPhrase("botes"); // botes
	ap.addComplement(np2); // em botes
	SPhraseSpec s = this.phraseFactory.createClause(vp, pp, ap);

	Assert.assertEquals("Dá para chegar bem perto das quedas em botes.", getResult(s));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:18,代码来源:Testbed.java

示例9: testEx35

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testEx35() {
	NPPhraseSpec np = this.phraseFactory.createNounPhrase("você");
	VPPhraseSpec vp = this.phraseFactory.createVerbPhrase("passar");
	vp.setFeature(Feature.PROSPECTIVE, true);
	PPPhraseSpec pp = this.phraseFactory.createPrepositionPhrase("por");
	NPPhraseSpec np2 = this.phraseFactory.createNounPhrase("o", "bairro");
	PPPhraseSpec pp2 = this.phraseFactory.createPrepositionPhrase("entre");
	NPPhraseSpec np3 = this.phraseFactory.createNounPhrase("as", "parada");
	np3.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	np3.addPostModifier("3 e 4");
	pp2.addComplement(np3);
	np2.addComplement(pp2);
	pp.addComplement(np2);
	vp.addComplement(pp);
	SPhraseSpec s = this.phraseFactory.createClause(np, vp);

	Assert.assertEquals("Você vai passar pelo bairro entre as paradas 3 e 4.", getResult(s));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:20,代码来源:Testbed.java

示例10: testEx58

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testEx58() {
	NPPhraseSpec np = this.phraseFactory.createNounPhrase("o", "local");
	np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	VPPhraseSpec vp = this.phraseFactory.createVerbPhrase("estar");
	AdvPhraseSpec ap = this.phraseFactory.createAdverbPhrase("espalhado");
	ap.addPreModifier("um pouco");
	SPhraseSpec s = this.phraseFactory.createClause(np, vp, ap);

	// TODO this example generates an ill-formed clause but, in the way
	// the grammar currently is, neither (a) determiner-noun agreement
	// happens, nor (b) subject-predicate agreement of copula clauses.
	// commented out is the realisation one wishes to get.
	Assert.assertEquals(
			// "os locais estão um pouco espalhados",
			"O locais estão um pouco espalhado.", getResult(s));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:18,代码来源:Testbed.java

示例11: testConvertTriplePatterns

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
@Test
public void testConvertTriplePatterns() throws Exception {
	TripleConverterPortuguese converter = new TripleConverterPortuguese();
	Triple t = Triple.create(NodeFactory.createVariable("person"),
			NodeFactory.createURI("http://dbpedia.org/ontology/occupation"),
			NodeFactory.createURI("http://dbpedia.org/resource/Writer"));
	String text = converter.convert(t);
	System.out.println(t + " -> " + text);

	t = Triple.create(NodeFactory.createURI("http://dbpedia.org/ontology/Albert"),
			NodeFactory.createURI("http://dbpedia.org/ontology/occupation"),
			NodeFactory.createURI("http://dbpedia.org/resource/Writer"));
	SPhraseSpec phrase = converter.convertToPhrase(t, false, false, false);
	phrase.getSubject().getChildren().get(0).setFeature(Feature.PRONOMINAL, true);

	System.out.println(t + " -> " + r.realise(phrase));

}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:19,代码来源:TripleConverterTest.java

示例12: applyMergeRules

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
/**
 * Generates a set of sentences by merging the sentences in the list as well
 * as possible
 *
 * @param triples
 *            List of triples
 * @return List of sentences
 */
public List<NLGElement> applyMergeRules(List<SPhraseSpec> triples, Gender g) {
	List<SPhraseSpec> phrases = new ArrayList<SPhraseSpec>();
	phrases.addAll(triples);

	int newSize = phrases.size(), oldSize = phrases.size() + 1;

	// apply merging rules if more than one sentence to merge
	if (newSize > 1) {
		// fix point iteration for object and predicate merging
		while (newSize < oldSize) {
			oldSize = newSize;
			int orCount = or.isApplicable(phrases);
			int prCount = pr.isApplicable(phrases);
			if (prCount > 0 || orCount > 0) {
				if (prCount > orCount) {
					phrases = pr.apply(phrases);
				} else {
					phrases = or.apply(phrases);
				}
			}
			newSize = phrases.size();
		}
	}
	return sr.apply(phrases, g);
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:34,代码来源:Verbalizer.java

示例13: testEx00

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
/**
 * This simple example shows only the SVO syntax.
 */
@Test
public void testEx00() {
	NPPhraseSpec subject = this.phraseFactory.createNounPhrase("Junho");
	VPPhraseSpec verb = this.phraseFactory.createVerbPhrase("ser");
	NPPhraseSpec object = this.phraseFactory.createNounPhrase("mês de São João");
	SPhraseSpec s = this.phraseFactory.createClause(subject, verb, object);

	Assert.assertEquals("Junho é mês de São João.", getResult(s, "00"));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:13,代码来源:Testbed.java

示例14: testEx01

import simplenlg.phrasespec.SPhraseSpec; //导入依赖的package包/类
/**
 * This example shows: a) -ão plural: folião + PLURAL = foliões b) -al
 * plural: arraial + PLURAL = arraiais c) verb periphrasis build: foliões
 * animados + gostar + brincar = foliões animados gostam de brincar
 */
@Test
public void testEx01() {
	NPPhraseSpec subject = this.phraseFactory.createNounPhrase("folião");
	subject.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	subject.addPostModifier("animados");
	VPPhraseSpec verb = this.phraseFactory.createVerbPhrase("brincar");
	verb.setFeature(Feature.MODAL, "gostar");
	NPPhraseSpec object = this.phraseFactory.createNounPhrase("em", "arraial");
	object.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
	SPhraseSpec s = this.phraseFactory.createClause(subject, verb, object);

	Assert.assertEquals("Foliões animados gostam de brincar em arraiais.", getResult(s, "01"));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:19,代码来源:Testbed.java

示例15: 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));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:13,代码来源:Testbed.java


注:本文中的simplenlg.phrasespec.SPhraseSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。