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


Java Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees方法代码示例

本文整理汇总了Java中com.sri.ai.expresso.helper.Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees方法的典型用法代码示例。如果您正苦于以下问题:Java Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees方法的具体用法?Java Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees怎么用?Java Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sri.ai.expresso.helper.Expressions的用法示例。


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

示例1: visitPropositionalRandomVariableDeclaration

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override 
public Expression visitPropositionalRandomVariableDeclaration(HOGMParser.PropositionalRandomVariableDeclarationContext ctx) { 
	Expression name  = newSymbol(ctx.name.getText());
	Expression arity = Expressions.ZERO;
	Expression range = visit(ctx.range);

	List<Expression> declarationArgs = new ArrayList<Expression>();
	declarationArgs.add(name);
	declarationArgs.add(arity);
	declarationArgs.add(range);

	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
			HOGMRandomVariableDeclaration.FUNCTOR_RANDOM_VARIABLE_DECLARATION,
			declarationArgs.toArray());
	
	randomVariableDeclarations.add(newStatementInfo(result, ctx));

	return result; 
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:20,代码来源:HOGModelVisitor.java

示例2: getConstantDeclaration

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
/**
 * 
 * @return an expression representing the full constant declaration.
 */
public Expression getConstantDeclaration() {
	// Lazy initialize this attribute
	if (constantDeclaration == null) {
		List<Expression> declarationArgs = new ArrayList<Expression>();
		declarationArgs.add(name);
		declarationArgs.add(arity);
		declarationArgs.addAll(parameters);
		declarationArgs.add(range);

		constantDeclaration = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
				FUNCTOR_CONSTANT_DECLARATION,
				declarationArgs.toArray());
	}

	return constantDeclaration;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:21,代码来源:ConstantDeclaration.java

示例3: visitRelationalRandomVariableDeclaration

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override 
public Expression visitRelationalRandomVariableDeclaration(HOGMParser.RelationalRandomVariableDeclarationContext ctx) { 
	Expression name = newSymbol(ctx.name.getText());
	List<Expression> parameters = expressionsList(ctx.parameters);
	Expression arity = Expressions.makeSymbol(parameters.size());
	Expression range = visit(ctx.range);

	List<Expression> declarationArgs = new ArrayList<Expression>();
	declarationArgs.add(name);
	declarationArgs.add(arity);
	declarationArgs.addAll(parameters);
	declarationArgs.add(range);

	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
			HOGMRandomVariableDeclaration.FUNCTOR_RANDOM_VARIABLE_DECLARATION,
			declarationArgs.toArray());
	
	randomVariableDeclarations.add(newStatementInfo(result, ctx));

	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:22,代码来源:HOGModelVisitor.java

示例4: getRandomVariableDeclaration

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
/**
 * 
 * @return an expression representing the full random variable declaration.
 */
public Expression getRandomVariableDeclaration() {
	// Lazy initialize this attribute
	if (randomVariableDeclaration == null) {
		List<Expression> declarationArgs = new ArrayList<Expression>();
		declarationArgs.add(name);
		declarationArgs.add(arity);
		declarationArgs.addAll(parameters);
		declarationArgs.add(range);

		randomVariableDeclaration = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
				FUNCTOR_RANDOM_VARIABLE_DECLARATION,
				declarationArgs.toArray());
	}

	return randomVariableDeclaration;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:21,代码来源:HOGMRandomVariableDeclaration.java

示例5: visitRelationalConstantDeclaration

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override 
public Expression visitRelationalConstantDeclaration(HOGMParser.RelationalConstantDeclarationContext ctx) { 
	Expression name = newSymbol(ctx.name.getText());
	List<Expression> parameters = expressionsList(ctx.parameters);
	Expression arity = Expressions.makeSymbol(parameters.size());
	Expression range = visit(ctx.range);

	List<Expression> declarationArgs = new ArrayList<Expression>();
	declarationArgs.add(name);
	declarationArgs.add(arity);
	declarationArgs.addAll(parameters);
	declarationArgs.add(range);

	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
			ConstantDeclaration.FUNCTOR_CONSTANT_DECLARATION,
			declarationArgs.toArray());
	
	constantDeclarations.add(newStatementInfo(result, ctx));

	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:22,代码来源:HOGModelVisitor.java

示例6: visitSort_decl

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override 
public Expression visitSort_decl(HOGMParser.Sort_declContext ctx) { 
	Expression name = newSymbol(ctx.name.getText());
	Expression size = HOGMSortDeclaration.UNKNOWN_SIZE;
	if (ctx.size != null) {
		size = newSymbol(ctx.size.getText());
	}
	List<Expression> constants = new ArrayList<Expression>();
	if (ctx.constants != null) {
		ctx.constants.forEach(c -> constants.add(newSymbol(c.getText())));
	}
	
	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
			HOGMSortDeclaration.FUNCTOR_SORT_DECLARATION, name, size,
			ExtensionalSets.makeUniSet(constants));
	
	sortDeclarations.add(newStatementInfo(result, ctx));
	
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:21,代码来源:HOGModelVisitor.java

示例7: getSortDeclaration

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
/**
 * 
 * @return an expression representing the full sort declaration.
 */
public Expression getSortDeclaration() {
	// Lazy initialize this attribute
	if (sortDeclaration == null) {
		sortDeclaration = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(FUNCTOR_SORT_DECLARATION, name,
				size, constants);
	}

	return sortDeclaration;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:14,代码来源:HOGMSortDeclaration.java

示例8: normalize

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
/**
 * Returns X = c, if 'expression' is c = X, for X a variable and c a constant, or 'expression' otherwise.
 * It actually works for any other functor as well. 
 */
public static Expression normalize(Expression expression, Context context) {
	if (expression.numberOfArguments() == 2
			&& context.isUniquelyNamedConstant(expression.get(0))) {
		if ( ! context.isUniquelyNamedConstant(expression.get(1))) {
			Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(expression.getFunctor(), expression.get(1), expression.get(0));
			return result;
		}
	}
	return expression;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:15,代码来源:Equality.java

示例9: visitMultiplicationOrDivisionOrIntegerInterval

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override
public Expression visitMultiplicationOrDivisionOrIntegerInterval(AntlrGrinderParser.MultiplicationOrDivisionOrIntegerIntervalContext ctx) {
	Expression result;	
	if (ctx.op.getText().equals("..")) {			
		result = apply(INTEGER_INTERVAL, visit(ctx.leftop), visit(ctx.rightop));
		// result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(FunctorConstants.INTEGER_INTERVAL, visit(ctx.leftop), visit(ctx.rightop));
		// using the above line places extra quotes around '..', not sure why.
	}
	else {			
		result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(ctx.op.getText(), visit(ctx.leftop), visit(ctx.rightop));
	}		
	result = possiblyFlatten(result);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:15,代码来源:ExpressionVisitor.java

示例10: visitUnaryMinus

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override 
public Expression visitUnaryMinus(HOGMParser.UnaryMinusContext ctx) { 
Expression argument = visit(ctx.term());
Expression result;
if (argument.getValue() instanceof Number) {
	result = Expressions.makeSymbol(argument.rationalValue().negate());
}
else {
	result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(MINUS, argument);
}
return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:13,代码来源:HOGModelVisitor.java

示例11: visitIntersection

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override
public Expression visitIntersection(
		AntlrGrinderParser.IntersectionContext ctx) {
	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(FunctorConstants.INTERSECTION, visit(ctx.leftop), visit(ctx.rightop));
	result = possiblyFlatten(result);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:8,代码来源:ExpressionVisitor.java

示例12: visitSort_real_interval

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override 
public Expression visitSort_real_interval(HOGMParser.Sort_real_intervalContext ctx) { 
	String intervalType;
	if (ctx.lower_bracket.getText().equals("[")) {
		if (ctx.upper_bracket.getText().equals("]")) {
			intervalType = REAL_INTERVAL_CLOSED_CLOSED;
		}
		else { // upper bracket is open i.e. [
			intervalType = REAL_INTERVAL_CLOSED_OPEN;
		}
	}  		
	else { // Lower bracket is open i.e. ]
		if (ctx.upper_bracket.getText().equals("]")) {
			intervalType = REAL_INTERVAL_OPEN_CLOSED;
		}
		else { // upper bracket is open i.e. [
			intervalType = REAL_INTERVAL_OPEN_OPEN;
		}
	}
	Rational lower = new Rational(ctx.lower.getText());
	if (ctx.negate_lower != null) {
		lower = lower.negate();
	}
	Rational upper = new Rational(ctx.upper.getText());
	if (ctx.negate_upper != null) {
		upper = upper.negate();
	}
	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(intervalType, Expressions.makeSymbol(lower), Expressions.makeSymbol(upper));
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:31,代码来源:HOGModelVisitor.java

示例13: visitCardinality

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override
public Expression visitCardinality(AntlrGrinderParser.CardinalityContext ctx) {
	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(FunctorConstants.CARDINALITY, visit(ctx.expr()));
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:6,代码来源:ExpressionVisitor.java

示例14: visitAdditionOrSubtraction

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
@Override
public Expression visitAdditionOrSubtraction(AntlrGrinderParser.AdditionOrSubtractionContext ctx) {
	Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(ctx.op.getText(), visit(ctx.leftop), visit(ctx.rightop));
	result = possiblyFlatten(result);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:7,代码来源:ExpressionVisitor.java

示例15: makeMultiSet

import com.sri.ai.expresso.helper.Expressions; //导入方法依赖的package包/类
public static Expression makeMultiSet(List<Expression> elements) {
	return Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(MULTI_SET_LABEL, Expressions.makeKleeneListIfNeeded(elements));
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:4,代码来源:ExtensionalSets.java


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