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


Java Type类代码示例

本文整理汇总了Java中edu.cornell.cs.nlp.spf.mr.language.type.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: typeToSyntax

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的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

示例2: LogicalConstant

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
protected LogicalConstant(String name, Type type, boolean baseName) {
	super(type);
	// All strings are interned to save memory. This usually has little cost
	// since constants are mostly created when the system is initialized and
	// the data is read an IO device.
	if (baseName) {
		this.name = makeFullName(name, type).intern();
		this.baseName = name.intern();
	} else {
		this.name = name.intern();
		this.baseName = name.substring(0, name.length()
				- getType().getName().length() - TYPE_SEPARATOR.length())
				.intern();
	}

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

示例3: create

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
public static LogicalConstant create(String name, Type type,
		boolean dynamic, boolean baseName) {
	// Strip the dynamic marker if present and turn it into a flag.
	final String updatedName;
	final boolean makeDynamic;
	if (name.startsWith(DYNAMIC_MARKER)) {
		updatedName = name.substring(DYNAMIC_MARKER.length());
		makeDynamic = true;
	} else {
		updatedName = name;
		makeDynamic = dynamic;
	}

	if (LogicLanguageServices.getOntology() == null) {
		return new LogicalConstant(updatedName, type, baseName);
	} else {
		final String fullName = baseName ? makeFullName(updatedName, type)
				: updatedName;
		return LogicLanguageServices.getOntology().getOrAdd(fullName,
				makeDynamic,
				() -> new LogicalConstant(fullName, type, false));
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:24,代码来源:LogicalConstant.java

示例4: visit

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
@Override
public void visit(Literal literal) {
	literal.getPredicate().accept(this);
	// Check the arguments match the type of the function.
	final int len = literal.numArgs();
	for (int i = 0; i < len; ++i) {
		final LogicalExpression arg = literal.getArg(i);

		// Visit the argument.
		arg.accept(this);

		// Match the type of the argument with the signature type.
		final Type signatureType = literal.getArgSignature(i);
		wellTyped = wellTyped && verifyLiteralArgTyping(arg, signatureType);

		if (!wellTyped) {
			LOG.debug(
					"Literal %s is not well-typed. Mismatch between signature type %s to argument %s.",
					literal, signatureType, arg);
			return;
		}
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:24,代码来源:IsTypeConsistent.java

示例5: verifyLiteralArgTyping

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
/**
 * Verify the argument type against the signature type.
 */
private boolean verifyLiteralArgTyping(LogicalExpression arg,
		Type signatureType) {
	if (arg instanceof Variable) {
		// Case variable: check according to historical type and allow more
		// flexibility.
		return verifyVariableType((Variable) arg, signatureType);
	} else {
		// If the signature expects an array, the argument must be an array.
		// The relation between the signature type and the argument type
		// should be along the inheritance relation, but can be in either
		// direction.
		final boolean literalWellTyped = signatureType.isArray() == arg
				.getType().isArray()
				&& arg.getType().isExtendingOrExtendedBy(signatureType);
		if (!literalWellTyped) {
			message = "Array argument expected, or provided array argument doesn't extend signature array type";
		}
		return literalWellTyped;
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:24,代码来源:IsTypeConsistent.java

示例6: isPartialLiteral

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
protected boolean isPartialLiteral(Literal literal) {
	// Count number of arguments on predicate type
	Type type = literal.getPredicateType();
	int numArgs = 0;
	while (type.isComplex()) {
		if (type instanceof RecursiveComplexType) {
			numArgs += ((RecursiveComplexType) type).getMinArgs();
			type = ((RecursiveComplexType) type).getFinalRange();
		} else {
			++numArgs;
			type = type.getRange();
		}
	}

	return literal.numArgs() < numArgs;
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:17,代码来源:Evaluation.java

示例7: createPartialCoordination

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
@Override
public LogicalExpression createPartialCoordination(
		LogicalExpression coordinated, LogicalExpression coordinator) {
	// Create a binary predicate from coordinator
	if (!isBaseCoordinator(coordinator)) {
		return null;
	}

	// The type of the coordinated element is generalized to create the
	// coordination predicate
	final Type argType = LogicLanguageServices.getTypeRepository()
			.generalizeType(coordinated.getType());
	final LogicalConstant coordinationPredicate = createPredicate(
			(LogicalConstant) coordinator, 2, argType);

	// Create a literal using the predicate, with a variable as the
	// first argument and 'coordinated' as the second, and wrap the literal
	// with a lambda expression binding the varaible.
	final LogicalExpression[] arguments = new LogicalExpression[2];
	final Variable variable = new Variable(argType);
	arguments[0] = variable;
	arguments[1] = coordinated;
	return new Lambda(variable, new Literal(coordinationPredicate,
			arguments));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:26,代码来源:LogicalExpressionCoordinationServices.java

示例8: expandCoordination

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
@Override
public LogicalExpression expandCoordination(LogicalExpression coordination) {
	if (coordination instanceof Literal
			&& isCoordinator(((Literal) coordination).getPredicate(),
					((Literal) coordination).numArgs())) {
		final Literal literal = (Literal) coordination;
		final Type argType = ((ComplexType) literal.getPredicate()
				.getType()).getDomain();
		final int len = literal.numArgs();
		final LogicalExpression[] expandedArgs = new LogicalExpression[len + 1];
		// The variable referring to the new argument
		final LogicalExpression variable = new Variable(argType);
		expandedArgs[0] = variable;
		literal.copyArgsIntoArray(expandedArgs, 0, 1, len);
		return new Literal(
				createPredicate((LogicalConstant) literal.getPredicate(),
						len + 1, argType), expandedArgs);
	} else {
		return null;
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:22,代码来源:LogicalExpressionCoordinationServices.java

示例9: isCoordinator

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
private boolean isCoordinator(LogicalExpression predicate, int numArgs) {
	if (predicate instanceof LogicalConstant
			&& (isConjunctionCoordinator((LogicalConstant) predicate) || isDisjunctionCoordinator((LogicalConstant) predicate))
			&& predicate.getType() instanceof ComplexType) {
		final ComplexType predicateType = (ComplexType) predicate.getType();
		Type current = predicateType;
		int count = 0;
		while (current instanceof ComplexType) {
			++count;
			current = ((ComplexType) current).getRange();
		}
		return count == numArgs;
	} else {
		return false;
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:17,代码来源:LogicalExpressionCoordinationServices.java

示例10: read

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
public LogicalExpression read(String amr) throws IOException {
	try (StringReader reader = new StringReader(amr)) {
		final String firstToken = getNextToken(reader);
		if (!firstToken.equals("(")) {
			throw new IllegalStateException("AMR doesn't start with '(': "
					+ amr);
		}
		final Map<LogicalConstant, Pair<SkolemId, Type>> skolemIDs = new HashMap<>();
		final LogicalExpression instance = parseInstance(reader,
				new HashMap<String, Variable>(), skolemIDs);

		// Replace all dummy logical constants with the proper skolem IDs.
		final SetReferences visitor = new SetReferences(skolemIDs);
		visitor.visit(instance);
		return visitor.tempReturn;
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:18,代码来源:AmrToLogicalExpressionConverter.java

示例11: AMRServices

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
private AMRServices(String skolemPredicateBaseName, Type textType,
		String refPredicateBaseName, SpecificationMapping mapping,
		File stanfordModelFile, String opPredicatePrefix,
		LogicalConstant dummyEntity, LogicalConstant nameInstancePredicate,
		Type typingPredicateType, IllinoisNERWrapper namedEntityRecognizer,
		File propBankDir) throws IOException {
	this.opPredicatePrefix = opPredicatePrefix;
	this.dummyEntity = dummyEntity;
	this.nameInstancePredicate = nameInstancePredicate;
	this.typingPredicateType = typingPredicateType;
	this.namedEntityRecognizer = namedEntityRecognizer;
	// Add a lemmatizer that simply returns the lower-cased word.
	this.lemmatizer = new UnionLemmatizer(new WordNetLemmatizer(),
			word -> SetUtils.createSingleton(word.toLowerCase()));
	this.skolemPredicateBaseName = skolemPredicateBaseName;
	this.textType = textType;
	this.refPredicateBaseName = refPredicateBaseName;
	this.mapping = mapping;
	this.tagger = stanfordModelFile == null ? null
			: new MaxentTagger(stanfordModelFile.getAbsolutePath());
	this.propBank = propBankDir == null ? null : new PropBank(propBankDir);
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:23,代码来源:AMRServices.java

示例12: createRefPredicate

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
/**
 * Create a reference predicate, e.g., ref:<id,e>.
 */
public static LogicalConstant createRefPredicate(Type type) {
	final LogicalConstant cached = INSTANCE.refPredicatesCache.get(type);

	if (cached != null) {
		return cached;
	}

	final ComplexType predicateType = LogicLanguageServices
			.getTypeRepository()
			.getTypeCreateIfNeeded(type, SkolemServices.getIDType());
	final LogicalConstant predicate = LogicalConstant
			.create(INSTANCE.refPredicateBaseName, predicateType, true);

	INSTANCE.refPredicatesCache.put(type, predicate);

	return predicate;
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:21,代码来源:AMRServices.java

示例13: getCoordinationPredicate

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
/**
 * Given a coordination predicate, as initiated by
 * {@link CoordinationC1Rule}, return the appropriate coordination instance
 * of conjunction predicate.
 *
 * @param coordinationWrapper
 *            Coordination predicate, as initiated by
 *            {@link CoordinationC1Rule}.
 * @param coordinatedType
 *            The type of the coordinated items.
 */
public static LogicalConstant getCoordinationPredicate(
		String coordinationWrapperBaseName, Type coordinatedType) {
	if (coordinatedType.equals(LogicLanguageServices.getTypeRepository()
			.getTruthValueType())) {
		return coordinationWrapperBaseName
				.equals(INSTANCE.conjunctionLabel) ? LogicLanguageServices
				.getConjunctionPredicate() : LogicLanguageServices
				.getDisjunctionPredicate();
	} else if (coordinatedType.equals(LogicLanguageServices
			.getTypeRepository().getEntityType())) {
		return coordinationWrapperBaseName
				.equals(INSTANCE.conjunctionLabel) ? INSTANCE.entityConjunctionInstance
				: INSTANCE.entityDisjunctionInstance;
	} else {
		LOG.debug("Unsupported coordinationw wrapper type: %s with %s",
				coordinationWrapperBaseName, coordinatedType);
		return null;
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:31,代码来源:CoordinationServices.java

示例14: apply

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
@Override
public ParseRuleResult<LogicalExpression> apply(
		Category<LogicalExpression> left,
		Category<LogicalExpression> right, SentenceSpan span) {
	if (left.getSyntax().equals(Syntax.C)
			&& !(right.getSyntax() instanceof CoordinationSyntax)
			&& left.getSemantics() instanceof LogicalConstant
			&& CoordinationServices.isCoordinator((LogicalConstant) left
					.getSemantics()) && right.getSemantics() != null) {
		// The type of the coordinated expressions.
		final Type type = LogicLanguageServices.getTypeRepository()
				.generalizeType(right.getSemantics().getType());

		// Create the semantics, syntax, and the category.
		return new ParseRuleResult<>(ruleName,
				Category.<LogicalExpression> create(new CoordinationSyntax(
						right.getSyntax()), CoordinationServices
						.createLiteral(((LogicalConstant) left
								.getSemantics()).getBaseName(), ArrayUtils
								.create(right.getSemantics()), type)));

	}
	return null;
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:25,代码来源:CoordinationC1Rule.java

示例15: doApply

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //导入依赖的package包/类
protected ParseRuleResult<LogicalExpression> doApply(
		LogicalExpression left, Literal right, CoordinationSyntax syntax) {
	final Type baseType = right.getType();

	// Create the argument list and the new semantic form.
	final int numArgs = right.numArgs();
	final LogicalExpression[] arguments = new LogicalExpression[numArgs + 1];
	// Make sure there's no free variable overlap.
	arguments[0] = ReplaceFreeVariablesIfPresent.of(left,
			right.getFreeVariables());
	right.copyArgsIntoArray(arguments, 0, 1, numArgs);

	// Create the return category, including the syntactic
	// component.
	final Category<LogicalExpression> resultCategory = Category
			.<LogicalExpression> create(syntax, CoordinationServices
					.createLiteral(((LogicalConstant) right.getPredicate())
							.getBaseName(), arguments, baseType));

	return new ParseRuleResult<>(ruleName, resultCategory);
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:22,代码来源:CoordinationC2Rule.java


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