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


Java Type.isComplex方法代碼示例

本文整理匯總了Java中edu.cornell.cs.nlp.spf.mr.language.type.Type.isComplex方法的典型用法代碼示例。如果您正苦於以下問題:Java Type.isComplex方法的具體用法?Java Type.isComplex怎麽用?Java Type.isComplex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.cornell.cs.nlp.spf.mr.language.type.Type的用法示例。


在下文中一共展示了Type.isComplex方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: isEntityToTruthType

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //導入方法依賴的package包/類
private static boolean isEntityToTruthType(Type type) {
	if (type.isComplex()) {
		final Type genType = LogicLanguageServices.getTypeRepository()
				.generalizeType(type);
		return LogicLanguageServices.getTypeRepository().getEntityType()
				.equals(((ComplexType) genType).getDomain())
				&& LogicLanguageServices.getTypeRepository()
						.getTruthValueType()
						.equals(((ComplexType) genType).getRange());
	} else {
		return false;
	}
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:14,代碼來源:AToExists.java

示例4: visit

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //導入方法依賴的package包/類
@Override
public void visit(LogicalConstant logicalConstant) {
	final Type type = logicalConstant.getType();
	if (!type.isArray() && !type.isComplex()) {
		constants.add(logicalConstant);
	}
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:8,代碼來源:GetAllSimpleLogicalConstants.java

示例5: getFinalType

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //導入方法依賴的package包/類
public static Type getFinalType(Type type) {
	Type currentType = type;
	while (!(currentType instanceof RecursiveComplexType)
			&& currentType.isComplex()) {
		currentType = currentType.getRange();
	}
	return currentType;
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:9,代碼來源:AMRServices.java

示例6: typeShiftSemantics

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //導入方法依賴的package包/類
/**
 * (lambda $0:x (g $0)) ==> (lambda $0:<x,t> (lambda $1:x (and:<t*,t> ($0
 * $1) (g $1))))
 */
protected LogicalExpression typeShiftSemantics(LogicalExpression sem) {
	final Type semType = sem.getType();
	final Type range = semType.getRange();

	if (semType.isComplex()
			&& range.equals(LogicLanguageServices.getTypeRepository()
					.getTruthValueType())) {

		// Make sure the expression is wrapped with lambda operators, since
		// the variables are required
		final Lambda lambda = (Lambda) sem;

		// Variable for the new outer lambda
		final Variable outerVariable = new Variable(LogicLanguageServices
				.getTypeRepository().getTypeCreateIfNeeded(
						LogicLanguageServices.getTypeRepository()
								.getTruthValueType(),
						lambda.getArgument().getType()));

		// Create the literal applying the function to the original
		// argument
		final LogicalExpression[] args = new LogicalExpression[1];
		args[0] = lambda.getArgument();
		final Literal newLiteral = new Literal(outerVariable, args);

		// Create the conjunction of newLitral and the original body
		final Literal conjunction = new Literal(
				LogicLanguageServices.getConjunctionPredicate(),
				ArrayUtils.create(newLiteral, lambda.getBody()));

		// The new inner lambda
		final Lambda innerLambda = new Lambda(lambda.getArgument(),
				conjunction);

		// The new outer lambda
		final Lambda outerLambda = new Lambda(outerVariable, innerLambda);

		// Simplify the output and return it
		final LogicalExpression ret = Simplify.of(outerLambda);

		return ret;
	}

	return null;
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:50,代碼來源:SententialAdverbialTypeShifting.java

示例7: typeShiftSemantics

import edu.cornell.cs.nlp.spf.mr.language.type.Type; //導入方法依賴的package包/類
/**
 * (lambda $0:x (g $0)) ==> (lambda $0:<x,t> (lambda $1:x (and:<t*,t> ($0
 * $1) (g $1))))
 */
protected LogicalExpression typeShiftSemantics(LogicalExpression sem) {
	final Type semType = sem.getType();
	final Type range = semType.getRange();

	if (semType.isComplex() && range.equals(LogicLanguageServices
			.getTypeRepository().getTruthValueType())) {

		// Make sure the expression is wrapped with lambda operators, since
		// the variables are required
		final Lambda lambda = (Lambda) sem;

		// Variable for the new outer lambda
		final Variable outerVariable = new Variable(LogicLanguageServices
				.getTypeRepository().getTypeCreateIfNeeded(
						LogicLanguageServices.getTypeRepository()
								.getTruthValueType(),
						lambda.getArgument().getType()));

		// Create the literal applying the function to the original
		// argument
		final LogicalExpression[] args = new LogicalExpression[1];
		args[0] = lambda.getArgument();
		final Literal newLiteral = new Literal(outerVariable, args);

		// Create the conjunction of newLitral and the original body
		final Literal conjunction = new Literal(
				LogicLanguageServices.getConjunctionPredicate(),
				ArrayUtils.create(newLiteral, lambda.getBody()));

		// The new inner lambda
		final Lambda innerLambda = new Lambda(lambda.getArgument(),
				conjunction);

		// The new outer lambda
		final Lambda outerLambda = new Lambda(outerVariable, innerLambda);

		// Simplify the output and return it
		final LogicalExpression ret = Simplify.of(outerLambda);

		return ret;
	}

	return null;
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:49,代碼來源:AbstractShiftingRule.java

示例8: 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) {

	// Right side must be a complex category.
	if (!(right instanceof ComplexCategory<?>)) {
		return null;
	}
	// It's the secondary argument of the composition.
	final ComplexCategory<LogicalExpression> secondary = (ComplexCategory<LogicalExpression>) right;

	// Verify secondary slash.
	if (!secondary.hasSlash(Slash.FORWARD)) {
		return null;
	}

	// Get the embedded X from the secondary. First verify we have the right
	// structure.
	if (!(secondary.getSyntax().getLeft() instanceof ComplexSyntax)
			|| !((ComplexSyntax) secondary.getSyntax().getLeft())
					.getSlash().equals(Slash.BACKWARD)) {
		return null;
	}
	final Syntax secondaryT = ((ComplexSyntax) secondary.getSyntax()
			.getLeft()).getLeft();
	final Syntax secondaryX = ((ComplexSyntax) secondary.getSyntax()
			.getLeft()).getRight();

	// Verify the Xs (see javadoc above) match.
	if (secondaryX.unify(left.getSyntax()) == null) {
		return null;
	}

	// Get the semantic type of the final result in the type raised
	// semantics.
	final Type secondaryReturnType = secondary.getSemantics().getType()
			.getRange();
	// Verify it matches the type of the primary semantics.
	if (secondaryReturnType == null
			|| !secondaryReturnType.isComplex()
			|| !left.getSemantics()
					.getType()
					.isExtendingOrExtendedBy(
							secondaryReturnType.getDomain())) {
		return null;
	}

	// Apply type raising.
	final ParseRuleResult<LogicalExpression> raisingResult = typeRaising
			.apply(left, left.getSyntax(), secondaryT,
					secondaryReturnType.getRange());
	if (raisingResult == null) {
		return null;
	}

	final ParseRuleResult<LogicalExpression> compositionResult = doComposition(
			raisingResult.getResultCategory(), right, false);

	if (compositionResult == null) {
		return null;
	}

	return new ParseRuleResult<LogicalExpression>(getName(),
			compositionResult.getResultCategory());
}
 
開發者ID:clic-lab,項目名稱:spf,代碼行數:67,代碼來源:ForwardTypeRaisedComposition.java


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