當前位置: 首頁>>代碼示例>>Java>>正文


Java LogicLanguageServices類代碼示例

本文整理匯總了Java中edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices的典型用法代碼示例。如果您正苦於以下問題:Java LogicLanguageServices類的具體用法?Java LogicLanguageServices怎麽用?Java LogicLanguageServices使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LogicLanguageServices類屬於edu.cornell.cs.nlp.spf.mr.lambda包,在下文中一共展示了LogicLanguageServices類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test4

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test4() {
	final LogicalExpression exp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> (do:<e,<e,<e,t>>> roo:e $1 (a:<<e,t>,e> (lambda $0:e (boo:<e,<e,t>> $0 too:e)))) ($0 $1) (boo:<e,<e,t>> $1 goo:e))))");
	final Result result = ExtractTypedSubExpression.of(exp, LogicalConstant
			.read("p:t"), LogicLanguageServices.getTypeRepository()
			.getTypeCreateIfNeeded("t"), false);
	Assert.assertNotNull(result);
	final LogicalExpression expectedSubExp = ((Lambda) ((Lambda) exp)
			.getBody()).getBody();
	final LogicalExpression expectedRemainder = TestServices
			.getCategoryServices().readSemantics(
					"(lambda $0:<e,t> (lambda $1:e p:t))");
	Assert.assertEquals(expectedRemainder,
			result.getExpressionWithPlaceholder());
	Assert.assertEquals(expectedSubExp, result.getExtractedSubExpression());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:20,代碼來源:ExtractTypedSubExpressionTest.java

示例2: test1

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test1() {
	final LogicalExpression exp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> ($0 $1) (boo:<e,<e,t>> $1 goo:e))))");
	final Result result = ExtractTypedSubExpression.of(exp, LogicalConstant
			.read("p:e"), LogicLanguageServices.getTypeRepository()
			.getEntityType(), true);
	Assert.assertNotNull(result);
	final LogicalExpression expectedSubExp = TestServices
			.getCategoryServices().readSemantics("goo:e");
	final LogicalExpression expectedRemainder = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> ($0 $1) (boo:<e,<e,t>> $1 p:e))))");
	Assert.assertEquals(expectedRemainder,
			result.getExpressionWithPlaceholder());
	Assert.assertEquals(expectedSubExp, result.getExtractedSubExpression());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:21,代碼來源:ExtractTypedSubExpressionTest.java

示例3: test5

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test5() {
	final AttachmentFeatures<Sentence> fs = new AttachmentFeatures<>(1.0,
			LogicLanguageServices.getTypeRepository()
					.getTypeCreateIfNeeded("<e,t>"), 1000, 10);

	final IHashVector features = HashVectorFactory.create();
	fs.setFeatures(
			createParseStep(
					TestServices
							.getCategoryServices()
							.read("N : (a:<id,<<e,t>,e>> na:id (lambda $0:e (and:<t*,t> (c_:<e,<e,t>> $0 (a:<id,<<e,t>,e>> na:id (lambda $1:e (and:<t*,t> (name:<e,t> $1) (c_op:<e,<txt,t>> $1 Saudi++Arabia:txt))))) (country:<e,t> $0))))"),
					TestServices.getCategoryServices().read(
							"N : (lambda $0:e (boo:<e,t> $0))")), features,
			new Sentence("dummy"));
	Assert.assertEquals(
			"{ATTACH#c_#name=1.000, ATTACH#c_op#txt=1.000, ATTACH#country#c_=1.000, ATTACH#country#c_#name=1.000, ATTACH#name#c_op=1.000, ATTACH#name#c_op#txt=1.000}",
			features.toString());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:20,代碼來源:AttachmentFeaturesTest.java

示例4: typeToSyntax

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
public static Syntax typeToSyntax(Type type) {
	if (type instanceof RecursiveComplexType) {
		// Basically something like and:<t*,t>, so we need two arguments, to
		// get something like N|N|N
		final RecursiveComplexType recursiveType = (RecursiveComplexType) type;
		return new ComplexSyntax(
				typeToSyntax(recursiveType.getFinalRange()),
				recurviseArgsToSyntax(recursiveType.getDomain(),
						recursiveType.getMinArgs()), Slash.VERTICAL);
	} else if (type.isComplex()) {
		return new ComplexSyntax(typeToSyntax(type.getRange()),
				typeToSyntax(type.getDomain()), Slash.VERTICAL);
	} else if (type == LogicLanguageServices.getTypeRepository()
			.getTruthValueType()) {
		// Case primitive type.
		// All things of type T have CCG category S
		return Syntax.S;
	} else {
		// Else NP
		return Syntax.NP;
	}
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:23,代碼來源:SplittingServices.java

示例5: simplify

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Override
public LogicalExpression simplify(LogicalExpression exp) {
	if (exp instanceof Literal) {
		final Literal literal = (Literal) exp;
		if (literal.numArgs() == 1
				&& literal.getArg(0) instanceof LogicalConstant
				&& literal.getArg(0).getType() == LogicLanguageServices
						.getTypeRepository().getIndexType()) {
			// If we have a single argument and it's a constant of type
			// index, replace it with a new constant
			final int i = LogicLanguageServices
					.indexConstantToInt((LogicalConstant) literal.getArg(0));
			return LogicLanguageServices.intToIndexConstant(i + 1);
		}
	}
	return exp;
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:18,代碼來源:IncSimplifier.java

示例6: test

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test() {
	final AttachmentFeatures<Sentence> fs = new AttachmentFeatures<>(1.0,
			LogicLanguageServices.getTypeRepository()
					.getTypeCreateIfNeeded("<e,t>"), 1000, 10);

	final IHashVector features = HashVectorFactory.create();
	fs.setFeatures(
			createParseStep(
					TestServices
							.getCategoryServices()
							.read("N : (lambda $0:e (and:<t*,t> (pred:<e,<e,t>> $0 (a:<id,<<e,t>,e>> na:id type:<e,t>)) (boo:<e,t> $0)))"),
					TestServices.getCategoryServices().read(
							"N : (lambda $0:e (boo:<e,t> $0))")), features,
			new Sentence("dummy"));
	Assert.assertEquals(
			"{ATTACH#boo#pred=1.000, ATTACH#boo#pred#type=1.000, ATTACH#pred#type=1.000}",
			features.toString());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:20,代碼來源:AttachmentFeaturesTest.java

示例7: test8

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test8() {
	final AttachmentFeatures<Sentence> fs = new AttachmentFeatures<>(1.0,
			LogicLanguageServices.getTypeRepository()
					.getTypeCreateIfNeeded("<e,t>"), 1000, 10);

	final IHashVector features = HashVectorFactory.create();
	fs.setFeatures(
			createParseStep(
					TestServices
							.getCategoryServices()
							.read("N : (lambda $0:<e,t> (lambda $1:e (and:<t*,t> (c_ARG1-of:<e,<e,t>> $1 (a:<id,<<e,t>,e>> na:id "
									+ "(lambda $2:e (and:<t*,t> (base-01:<e,t> $2) (c_location:<e,<e,t>> $2 (a:<id,<<e,t>,e>> na:id (lambda $2:e (and:<t*,t> (type:<e,t> $2) ($0 $2))))))))))))"),
					TestServices
							.getCategoryServices()
							.read("N : (lambda $0:<<e,t>,<e,t>> (lambda $1:<e,t> (lambda $2:e (and:<t*,t> ($0 (lambda $3:e ($1 $3)) $2) (c_REL:<e,<i,t>> $2 50:i)))))"),
					TestServices
							.getCategoryServices()
							.read("N : (lambda $0:<<e,t>,<e,t>> (lambda $1:e (and:<t*,t> (sponsor-01:<e,t> $1) (c_ARGX:<e,<e,t>> $1 (a:<id,<<e,t>,e>> na:id (lambda $2:e ($0 (lambda $3:e (expert-41:<e,t> $3)) $2)))))))")),
			features, new Sentence("dummy"));
	Assert.assertEquals(
			"{ATTACH#base-01#c_location=1.000, ATTACH#base-01#c_location#type=1.000, ATTACH#c_ARG1-of#base-01=1.000, ATTACH#c_location#type=1.000}",
			features.toString());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:25,代碼來源:AttachmentFeaturesTest.java

示例8: test6

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test6() {
	final LogicalExpression exp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> ($0 $1) (boo:<e,<e,t>> $1 goo:e))))");
	final Result result = ExtractTypedSubExpression.of(exp, LogicalConstant
			.read("p:t"), LogicLanguageServices.getTypeRepository()
			.getTypeCreateIfNeeded("t"), true);
	Assert.assertNotNull(result);
	final LogicalExpression expectedSubExp = ((Literal) ((Lambda) ((Lambda) exp)
			.getBody()).getBody()).getArg(1);
	final LogicalExpression expectedRemainder = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> ($0 $1) p:t)))");
	Assert.assertEquals(expectedRemainder,
			result.getExpressionWithPlaceholder());
	Assert.assertEquals(expectedSubExp, result.getExtractedSubExpression());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:21,代碼來源:ExtractTypedSubExpressionTest.java

示例9: before

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Before
public void before() {
	originalLLS = LogicLanguageServices.instance();
	try {
		LogicLanguageServices
				.setInstance(new LogicLanguageServices.Builder(
						LogicLanguageServices.getTypeRepository(),
						LogicLanguageServices.getTypeComparator())
						.setUseOntology(true)
						.addConstantsToOntology(
								TestServices.DEFAULT_ONTOLOGY_FILES)
						.setNumeralTypeName("n").closeOntology(true)
						.build());
	} catch (final IOException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:18,代碼來源:LogicalConstantTest.java

示例10: test2

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test2() {
	final AttachmentFeatures<Sentence> fs = new AttachmentFeatures<>(1.0,
			LogicLanguageServices.getTypeRepository()
					.getTypeCreateIfNeeded("<e,t>"), 1000, 10);

	final IHashVector features = HashVectorFactory.create();
	fs.setFeatures(
			createParseStep(
					TestServices
							.getCategoryServices()
							.read("N : (lambda $1:<e,t> (lambda $0:e (and:<t*,t> (pred:<e,<e,t>> $0 (a:<id,<<e,t>,e>> na:id $1)) (boo:<e,t> $0))))"),
					TestServices.getCategoryServices().read(
							"N : (lambda $0:e (boo:<e,t> $0))")), features,
			new Sentence("dummy"));
	Assert.assertEquals("{}", features.toString());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:18,代碼來源:AttachmentFeaturesTest.java

示例11: test3

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test3() {
	final LogicalExpression exp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> (do:<e,<e,<e,t>>> roo:e $1 (a:<<e,t>,e> (lambda $0:e (boo:<e,<e,t>> $0 too:e)))) ($0 $1) (boo:<e,<e,t>> $1 goo:e))))");
	final Result result = ExtractTypedSubExpression.of(exp, LogicalConstant
			.read("p:<e,<e,t>>"), LogicLanguageServices.getTypeRepository()
			.getTypeCreateIfNeeded("<e,<e,t>>"), false);
	Assert.assertNotNull(result);
	final LogicalExpression expectedSubExp = LogicalConstant
			.read("boo:<e,<e,t>>");
	final LogicalExpression expectedRemainder = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> (do:<e,<e,<e,t>>> roo:e $1 (a:<<e,t>,e> (lambda $0:e (boo:<e,<e,t>> $0 too:e)))) ($0 $1) (p:<e,<e,t>> $1 goo:e))))");
	Assert.assertEquals(expectedRemainder,
			result.getExpressionWithPlaceholder());
	Assert.assertEquals(expectedSubExp, result.getExtractedSubExpression());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:21,代碼來源:ExtractTypedSubExpressionTest.java

示例12: test5

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void test5() {
	final LogicalExpression exp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> (do:<e,<e,<e,t>>> roo:e $1 (a:<<e,t>,e> (lambda $0:e (boo:<e,<e,t>> $0 too:e)))) ($0 $1) (boo:<e,<e,t>> $1 goo:e))))");
	final Result result = ExtractTypedSubExpression.of(exp, LogicalConstant
			.read("p:t"), LogicLanguageServices.getTypeRepository()
			.getTypeCreateIfNeeded("t"), true);
	Assert.assertNotNull(result);
	final LogicalExpression expectedSubExp = ((Literal) ((Lambda) ((Lambda) exp)
			.getBody()).getBody()).getArg(0);
	final LogicalExpression expectedRemainder = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:<e,t> (lambda $1:e (and:<t*,t> p:t ($0 $1) (boo:<e,<e,t>> $1 goo:e))))");
	Assert.assertEquals(expectedRemainder,
			result.getExpressionWithPlaceholder());
	Assert.assertEquals(expectedSubExp, result.getExtractedSubExpression());
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:21,代碼來源:ExtractTypedSubExpressionTest.java

示例13: testSubExp10

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void testSubExp10() {
	final LogicalExpression appArg = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $1:e (a:<<e,t>,e> (lambda $0:e (and:<t*,t> (b:<e,t> A:e) (a:<e,t> P:e) (pred:<e,<e,t>> $1 $0)))))");
	final LogicalExpression subExp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(a:<<e,t>,e> (lambda $0:e (and:<t*,t> (b:<e,t> A:e) (a:<e,t> P:e) (pred:<e,<e,t>> boo:e $0))))");
	final Variable replacementVariable = new Variable(LogicLanguageServices
			.getTypeRepository().getType("<e,e>"));
	final LogicalExpression expected = new Literal(replacementVariable,
			ArrayUtils.create(TestServices.getCategoryServices()
					.readSemantics("boo:e")));
	Assert.assertEquals(expected, GetApplicationFunction.processSubExp(
			subExp, appArg, replacementVariable));
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:19,代碼來源:GetApplicationFunctionTest.java

示例14: testSubExp11

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void testSubExp11() {
	final LogicalExpression appArg = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $1:e (a:<<e,t>,e> (lambda $0:e (and:<t*,t> (b:<e,t> A:e) (a:<e,t> P:e) (pred:<e,<e,t>> $1 $0)))))");
	final Variable replacementVariable = new Variable(LogicLanguageServices
			.getTypeRepository().getType("<e,e>"));
	final LogicalExpression subExp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(a:<<e,t>,e> (lambda $0:e (and:<t*,t> (b:<e,t> A:e) (pred:<e,<e,t>> boo:e $0) (a:<e,t> P:e))))");
	final LogicalExpression expected = new Literal(replacementVariable,
			ArrayUtils.create(TestServices.getCategoryServices()
					.readSemantics("boo:e")));
	Assert.assertEquals(expected, GetApplicationFunction.processSubExp(
			subExp, appArg, replacementVariable));
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:19,代碼來源:GetApplicationFunctionTest.java

示例15: testSubExp12

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //導入依賴的package包/類
@Test
public void testSubExp12() {
	final LogicalExpression appArg = TestServices
			.getCategoryServices()
			.readSemantics(
					"(lambda $0:e (lambda $1:e (lambda $2:e (and:<t*,t> (b:<e,t> $2) (a:<e,t> P:e) (boo:<e,<e,t>> $0 $1)))))");
	final LogicalExpression subExp = TestServices
			.getCategoryServices()
			.readSemantics(
					"(and:<t*,t> (b:<e,t> doo:e) (a:<e,t> P:e) (boo:<e,<e,t>> koo:e loo:e))");
	final Variable replacementVariable = new Variable(LogicLanguageServices
			.getTypeRepository().getType("<e,<e,<e,t>>>"));
	final LogicalExpression expected = new Literal(replacementVariable,
			ArrayUtils.create(
					TestServices.getCategoryServices().readSemantics(
							"koo:e"),
					TestServices.getCategoryServices().readSemantics(
							"loo:e"),
					TestServices.getCategoryServices().readSemantics(
							"doo:e")));
	Assert.assertEquals(expected, GetApplicationFunction.processSubExp(
			subExp, appArg, replacementVariable));
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:24,代碼來源:GetApplicationFunctionTest.java


注:本文中的edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。