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


Java LogicalConstant.read方法代码示例

本文整理汇总了Java中edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant.read方法的典型用法代码示例。如果您正苦于以下问题:Java LogicalConstant.read方法的具体用法?Java LogicalConstant.read怎么用?Java LogicalConstant.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant的用法示例。


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

示例1: test1

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
@Test
public void test1() {
	final Variable variable = new Variable(LogicLanguageServices
			.getTypeRepository().getEntityType());
	final LogicalExpression e1 = new Lambda(variable, new Literal(
			LogicalConstant.read("boo:<e,<<e,t>,t>>"), ArrayUtils.create(
					variable,
					new Lambda(variable,
							new Literal(LogicalConstant.read("goo:<e,t>"),
									ArrayUtils.create(variable))))));
	final LogicalExpression e2 = LogicalExpression
			.read("(lambda $0:e (boo:<e,<<e,t>,t>> $0 (lambda $1:e (goo:<e,t> $1))))");
	Assert.assertEquals(e2, e1);

	final LogicalExpression result1 = TestServices.getCategoryServices()
			.apply(e1, LogicalConstant.read("foo:e"));
	final LogicalExpression result2 = TestServices.getCategoryServices()
			.apply(e2, LogicalConstant.read("foo:e"));
	Assert.assertEquals(result1, result2);
	System.out.println(result1);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:22,代码来源:LogicalExpressionApplicationTest.java

示例2: test2

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
@Test
public void test2() {
	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,<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> ($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

示例3: test3

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的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

示例4: readConstantsFile

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
public static List<LogicalConstant> readConstantsFile(File file)
		throws IOException {
	// First, strip the comments and prepare a clean LISP string to
	// parse
	final StringBuilder strippedFile = new StringBuilder();
	try (final BufferedReader reader = new BufferedReader(new FileReader(
			file))) {
		String line = null;
		while ((line = reader.readLine()) != null) {
			line = line.trim();
			line = line.split("\\s*//")[0];
			if (!line.equals("")) {
				strippedFile.append(line).append(" ");
			}
		}
	}

	// Read the constants
	final List<LogicalConstant> constants = new LinkedList<LogicalConstant>();
	final LispReader lispReader = new LispReader(new StringReader(
			strippedFile.toString()));
	while (lispReader.hasNext()) {
		final LogicalConstant exp = LogicalConstant.read(lispReader.next());
		constants.add(exp);
	}

	return constants;

}
 
开发者ID:clic-lab,项目名称:spf,代码行数:30,代码来源:ConstantsReader.java

示例5: test7

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
@Test
public void test7() {
	final Variable variable = new Variable(LogicLanguageServices
			.getTypeRepository().getEntityType());
	final LogicalExpression e1 = new Lambda(variable, new Literal(
			LogicalConstant.read("boo:<e,<<e,t>,t>>"), ArrayUtils.create(
					variable,
					new Lambda(variable,
							new Literal(LogicalConstant.read("goo:<e,t>"),
									ArrayUtils.create(variable))))));
	final LogicalExpression e2 = LogicalExpression
			.read("(lambda $0:e (boo:<e,<<e,t>,t>> $0 (lambda $1:e (goo:<e,t> $1))))");
	Assert.assertEquals(e2, e1);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:15,代码来源:LogicalExpressionEqualsTest.java

示例6: test9

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
@Test
public void test9() {
	final Variable variable = new Variable(LogicLanguageServices
			.getTypeRepository().getEntityType());
	final LogicalExpression e1 = new Lambda(variable, new Lambda(variable,
			new Literal(LogicalConstant.read("pred:<e,<e,t>>"),
					ArrayUtils.create(variable, variable))));
	final LogicalExpression e2 = LogicalExpression
			.read("(lambda $0:e (lambda $1:e (pred:<e,<e,t>> $0 $1)))");
	Assert.assertNotEquals(e2, e1);
	Assert.assertNotEquals(e1, e2);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:13,代码来源:LogicalExpressionEqualsTest.java

示例7: AToExistsTest

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
public AToExistsTest() {
	// Make sure test services is initialized
	TestServices.init();
	this.existsPredicate = LogicalConstant.read("exists:<<e,t>,t>");
	this.aPredicate = LogicalConstant.read("a:<<e,t>,e>");
	this.equalsPredicates = new HashMap<Type, LogicalConstant>();
	this.equalsPredicates.put(LogicLanguageServices.getTypeRepository()
			.getEntityType(), LogicalConstant.read("eq:<e,<e,t>>"));

}
 
开发者ID:clic-lab,项目名称:spf,代码行数:11,代码来源:AToExistsTest.java

示例8: create

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
@Override
public DatesGenerator create(Parameters params, IResourceRepository repo) {
	return new DatesGenerator(params.get("label", "dyn-dates"),
			LogicalConstant.read(params.get("day")),
			LogicalConstant.read(params.get("year")),
			LogicalConstant.read(params.get("month")),
			LogicalConstant.read(params.get("entityType")),
			Syntax.read(params.get("syntax")));
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:10,代码来源:DatesGenerator.java

示例9: NamedEntityGenerator

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
public NamedEntityGenerator(
		ICategoryServices<LogicalExpression> categoryServices,
		String baseLabel) {
	this.baseLabel = baseLabel;
	this.helperSemantics = categoryServices
			.readSemantics("(lambda $0:e (and:<t*,t> (TYPE:<e,t> $0) (c_name:<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 NAME:txt)))))))");
	this.typePlaceholder = LogicalConstant.read("TYPE:<e,t>");
	this.namePlceholder = LogicalConstant.read("NAME:txt");
	this.singularNounSyntax = Syntax.read("N[sg]");
	this.singularNPSyntax = Syntax.read("NP[sg]");
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:13,代码来源:NamedEntityGenerator.java

示例10: main

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {
		// //////////////////////////////////////////
		// Init logging
		// //////////////////////////////////////////

		Logger.DEFAULT_LOG = new Log(System.err);
		Logger.setSkipPrefix(true);
		LogLevel.INFO.set();

		// //////////////////////////////////////////
		// Init AMR.
		// //////////////////////////////////////////

		Init.init(new File(args[0]), false);

		final LogicalConstant namePredicate = LogicalConstant
				.read("c_name:<e,<txt,t>>");

		final AMROntology ontology = AMROntology.read(new File(args[1]));

		for (final SingleSentence sentence : SingleSentenceCollection.read(
				new File(args[2]), new Tokenizer())) {
			System.out.println(sentence.getSample());
			for (final Pair<String, String> entityType : GetNamedEntities
					.of(sentence.getLabel(), namePredicate)) {
				if (entityType.second() == null
						|| !ontology.isType(entityType.second())) {
					System.out.println(entityType.first());
				} else {
					System.out.println(String.format("%s\t%s",
							entityType.first(), entityType.second()));
				}
			}
			System.out.println();
		}
	} catch (final IOException e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:41,代码来源:NamedEntitiesCandidates.java

示例11: DatesGeneratorTest

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
public DatesGeneratorTest() {
	TestServices.init();
	this.gen = new DatesGenerator("dyn-dates",
			LogicalConstant.read("c_day:<e,<i,t>>"),
			LogicalConstant.read("c_year:<e,<i,t>>"),
			LogicalConstant.read("c_month:<e,<i,t>>"),
			LogicalConstant.read("date-entity:<e,t>"),
			Syntax.read("NP[sg]"));
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:10,代码来源:DatesGeneratorTest.java

示例12: DateStamp

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
public DateStamp() {
	super(UnaryRuleName.create(LABEL));
	this.sourceSyntax = Syntax.read("NP[sg]");
	this.dateInstanceType = LogicalConstant.read("date-entity:<e,t>");
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:6,代码来源:DateStamp.java

示例13: test

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
@Test
public void test() {
	final ColumnHeader h1 = new ColumnHeader(new LogicalConstantNode(
			LogicalConstant.read("boo:e"), ArrayUtils.create(
					LogicalConstant.read("boo1:e"),
					LogicalConstant.read("boo2:e")), 1));
	final ColumnHeader h2 = new ColumnHeader(new LogicalConstantNode(
			LogicalConstant.read("bo:e"), ArrayUtils.create(
					LogicalConstant.read("bo1:e"),
					LogicalConstant.read("bo2:e"),
					LogicalConstant.read("bo3:e")), 2));
	final Table table = new Table(false, h1, h2);
	table.setAll(1.0);
	Assert.assertEquals(
			3.0,
			table.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo1:e"))), 0.0);
	Assert.assertEquals(
			3.0,
			table.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo2:e"))), 0.0);
	Assert.assertEquals(
			2.0,
			table.get(MappingPair.of(h2.getNode(),
					LogicalConstant.read("bo2:e"))), 0.0);
	for (final LogicalExpression h1Assignment : h1.getNode()
			.slowGetAssignments()) {
		for (final LogicalExpression h2Assignment : h2.getNode()
				.slowGetAssignments()) {
			Assert.assertEquals(1.0, table.get(
					MappingPair.of(h1.getNode(), h1Assignment),
					MappingPair.of(h2.getNode(), h2Assignment)), 0.0);
		}
	}

	final Table table2 = new Table(false, h1);
	table2.setAll(2.0);
	table2.set(10.0,
			MappingPair.of(h1.getNode(), LogicalConstant.read("boo1:e")));
	table2.set(3.0,
			MappingPair.of(h1.getNode(), LogicalConstant.read("boo2:e")));
	for (final LogicalExpression assignment : h1.getNode()
			.slowGetAssignments()) {
		final MappingPair pair = MappingPair.of(h1.getNode(), assignment);
		table2.multiply(table.get(pair), pair);
	}
	Assert.assertEquals(
			30.0,
			table2.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo1:e"))), 0.0);
	Assert.assertEquals(
			9.0,
			table2.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo2:e"))), 0.0);
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:56,代码来源:TableTest.java

示例14: test2

import edu.cornell.cs.nlp.spf.mr.lambda.LogicalConstant; //导入方法依赖的package包/类
@Test
public void test2() {
	final ColumnHeader h1 = new ColumnHeader(new LogicalConstantNode(
			LogicalConstant.read("boo:e"), ArrayUtils.create(
					LogicalConstant.read("boo1:e"),
					LogicalConstant.read("boo2:e")), 1));
	final ColumnHeader h2 = new ColumnHeader(new LogicalConstantNode(
			LogicalConstant.read("bo:e"), ArrayUtils.create(
					LogicalConstant.read("bo1:e"),
					LogicalConstant.read("bo2:e"),
					LogicalConstant.read("bo3:e")), 2));
	final Table table = new Table(true, h1, h2);
	table.setAll(1.0);
	Assert.assertEquals(
			2.0986122886681096,
			table.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo1:e"))), 0.1);
	Assert.assertEquals(
			2.0986122886681096,
			table.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo2:e"))), 0.1);
	Assert.assertEquals(
			1.6931471805599452,
			table.get(MappingPair.of(h2.getNode(),
					LogicalConstant.read("bo2:e"))), 0.1);
	for (final LogicalExpression h1Assignment : h1.getNode()
			.slowGetAssignments()) {
		for (final LogicalExpression h2Assignment : h2.getNode()
				.slowGetAssignments()) {
			Assert.assertEquals(1.0, table.get(
					MappingPair.of(h1.getNode(), h1Assignment),
					MappingPair.of(h2.getNode(), h2Assignment)), 0.0);
		}
	}

	final Table table2 = new Table(true, h1);
	table2.setAll(2.0);
	table2.set(10.0,
			MappingPair.of(h1.getNode(), LogicalConstant.read("boo1:e")));
	table2.set(3.0,
			MappingPair.of(h1.getNode(), LogicalConstant.read("boo2:e")));
	for (final LogicalExpression assignment : h1.getNode()
			.slowGetAssignments()) {
		final MappingPair pair = MappingPair.of(h1.getNode(), assignment);
		table2.multiply(table.get(pair), pair);
	}
	Assert.assertEquals(
			10.0 * 2.0986122886681096,
			table2.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo1:e"))), 0.1);
	Assert.assertEquals(
			3.0 * 2.0986122886681096,
			table2.get(MappingPair.of(h1.getNode(),
					LogicalConstant.read("boo2:e"))), 0.1);
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:56,代码来源:TableTest.java


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