本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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;
}
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
示例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));
}
示例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));
}