edu.cornell.cs.nlp.spf.mr.language.type.Type Java Examples

The following examples show how to use edu.cornell.cs.nlp.spf.mr.language.type.Type. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TextEntitiesGenlex.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ResourceUsage usage() {
	return new ResourceUsage.Builder(type(),
			TemplateSupervisedGenlex.class)
					.setDescription(
							"GENLEX procedure to generate {@link LexicalEntry}s for named-entities that have txt-typed mentions in the logical form")
					.addParam("textType", Type.class,
							"Type of text-constants")
					.addParam("origin", String.class,
							"Origin of generated entries (default: genlex-txt)")
					.addParam("mark", Boolean.class,
							"Mark generated entries (default: false)")
					.addParam("generatedKeywords", Boolean.class,
							"Generate AMR-specific keyword NPs (e.g., for France FR) (default: false)")
					.addParam("attributes", String.class,
							"The set of allowed syntax attributes")
					.build();
}
 
Example #2
Source File: LogicalExpressionCoordinationServices.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
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;
	}
}
 
Example #3
Source File: AmrToLogicalExpressionConverter.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
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;
	}
}
 
Example #4
Source File: AMRServices.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: AMRServices.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: LogicalExpressionCoordinationServices.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
@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));
}
 
Example #7
Source File: IsTypeConsistent.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example #8
Source File: IsTypeConsistent.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
@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;
		}
	}
}
 
Example #9
Source File: LogicalConstant.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
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));
	}
}
 
Example #10
Source File: SplittingServices.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
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;
	}
}
 
Example #11
Source File: CoordinationServices.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example #12
Source File: LogicalConstant.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
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();
	}

}
 
Example #13
Source File: CoordinationC1Rule.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example #14
Source File: CoordinationC2Rule.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #15
Source File: ExtractTypedSubExpression.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
public static Result of(LogicalExpression exp,
		LogicalExpression placeholder, Type type, boolean skipCoordinations) {
	final GetDepthOrdering depthVisitor = new GetDepthOrdering(
			skipCoordinations);
	depthVisitor.visit(exp);
	int depth = 0;
	for (final List<LogicalExpression> depthSubExpressions : depthVisitor.subExpressionByDepth) {
		for (final LogicalExpression subExp : depthSubExpressions) {
			if (subExp.getType().equals(type)) {
				final ExtractTypedSubExpression visitor = new ExtractTypedSubExpression(
						placeholder, subExp, depth);
				visitor.visit(exp);
				return new Result(StripOverload.of(visitor.result), subExp);
			}
		}
		++depth;
	}
	return null;
}
 
Example #16
Source File: AttachmentFeatures.java    From amr with GNU General Public License v2.0 6 votes vote down vote up
public AttachmentFeatures(double scale, Type typingPredicateType,
		int cacheSize, int cacheConcurrencyLevel) {
	assert typingPredicateType != null;
	this.cacheSize = cacheSize;
	this.cacheConcurrencyLevel = cacheConcurrencyLevel;
	this.scale = scale;
	this.typingPredicateType = typingPredicateType;
	this.cache = CacheBuilder
			.newBuilder()
			.maximumSize(cacheSize)
			.concurrencyLevel(cacheConcurrencyLevel)
			.build(new CacheLoader<LogicalExpression, IHashVectorImmutable>() {

				@Override
				public IHashVectorImmutable load(LogicalExpression key)
						throws Exception {
					final ExtractFeatures visitor = new ExtractFeatures();
					visitor.visit(key);
					LOG.debug("%s -> %s", key, visitor.features);
					return visitor.features;
				}
			});
}
 
Example #17
Source File: LogicalExpressionCoordinationServices.java    From spf with GNU General Public License v2.0 6 votes vote down vote up
@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;
	}
}
 
Example #18
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
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>>"));

}
 
Example #19
Source File: IsTypeConsistent.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies consistency between a variable and its usage in a literal. If
 * the variable's historic type is unknown, it's a free variable -- treat it
 * like a constant. Therefore, this method shouldn't be called when
 * encountering the variables definition, but only its usage.
 */
private boolean verifyVariableType(Variable variable, Type signatureType) {
	final Type historicaltype = variableTypes.get(variable);
	if (historicaltype == null) {
		// Case not historical type, treat like a constant -- check it's
		// extending or extended by. Also, add to variableTypes. This
		// variable will never be removed from types, since its scoping is
		// global.
		variableTypes.put(variable, variable.getType());
		final boolean goodArg = variable.getType().isExtendingOrExtendedBy(
				signatureType);
		if (!goodArg) {
			message = "Argument type is incompatible with signature type (not extending or extended by signature type)";
		}
		return goodArg;
	} else {
		if (signatureType.isExtending(historicaltype)) {
			// Case the current signature type is a narrower instance of the
			// historical type, so remember it and return 'true'.
			variableTypes.put(variable, signatureType);
			return true;
		} else {
			// Return 'true' if the signature type is a narrower instance of
			// the historical type, so just return 'true'.
			final boolean extendingHistorical = historicaltype
					.isExtending(signatureType);
			if (!extendingHistorical) {
				message = "Mismatch between different uses of the same variable (e.g., one instance casts a specific type that another doesn't extend)";
			}
			return extendingHistorical;
		}
	}
}
 
Example #20
Source File: SplittingServices.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
private static Syntax recurviseArgsToSyntax(Type type, int numArgs) {
	final Syntax baseCategory = typeToSyntax(type);
	Syntax current = baseCategory;
	for (int i = 1; i < numArgs; ++i) {
		current = new ComplexSyntax(baseCategory, current, Slash.VERTICAL);
	}
	return current;
}
 
Example #21
Source File: LogicalConstant.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
protected static LogicalConstant read(String string,
		TypeRepository typeRepository) {
	try {
		final String[] split = string.split(Term.TYPE_SEPARATOR);
		if (split.length != 2) {
			throw new LogicalExpressionRuntimeException(
					"Constant sytax error: " + string);
		}

		// The type is the part of the string after the colon
		Type type = typeRepository.getType(split[1]);

		if (type == null) {
			// Try to create the type if not found, if this is a primitive
			// type
			// that is unknown, the type repository will return null
			type = typeRepository.getTypeCreateIfNeeded(split[1]);
		}

		if (type == null) {
			// If we still fail, the type is unknown
			throw new LogicalExpressionRuntimeException(
					String.format("Unknown type for: %s", string));
		}
		return create(string, type, false);
	} catch (final RuntimeException e) {
		LOG.error("Logical constant syntax error: %s", string);
		throw e;
	}
}
 
Example #22
Source File: AToExists.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
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;
	}
}
 
Example #23
Source File: GetAllSimpleLogicalConstants.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visit(LogicalConstant logicalConstant) {
	final Type type = logicalConstant.getType();
	if (!type.isArray() && !type.isComplex()) {
		constants.add(logicalConstant);
	}
}
 
Example #24
Source File: Literal.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
public static Pair<Type, Type[]> computeLiteralTyping(
		ComplexType predicateType, Type[] argTypes,
		ITypeComparator typeComparator, TypeRepository typeRepository) {
	final Type[] impliedSignatureTypes = new Type[argTypes.length];
	final Type computedType = computeLiteralTyping(predicateType, argTypes,
			typeComparator, typeRepository, impliedSignatureTypes);
	if (computedType == null) {
		return null;
	} else {
		return Pair.of(computedType, impliedSignatureTypes);
	}
}
 
Example #25
Source File: AbstractTypeRaising.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
private static LogicalExpression raiseSemantics(LogicalExpression sem,
		Type finalResultSemanticType) {
	final Variable variable = new Variable(LogicLanguageServices
			.getTypeRepository().getTypeCreateIfNeeded(
					LogicLanguageServices.getTypeRepository()
							.generalizeType(finalResultSemanticType),
					LogicLanguageServices.getTypeRepository()
							.generalizeType(sem.getType())));
	return new Lambda(variable, new Literal(variable,
			ArrayUtils.create(sem)));
}
 
Example #26
Source File: LogicalExpressionCoordinationServices.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
private static LogicalConstant createPredicate(LogicalConstant constant,
		int numArgs, Type argType) {
	// Using truth type as the final return type, 't' is a simple
	// placeholder here, it's completely meaningless.
	Type type = LogicLanguageServices.getTypeRepository()
			.getTypeCreateIfNeeded(
					LogicLanguageServices.getTypeRepository()
							.getTruthValueType(), argType);
	for (int i = 1; i < numArgs; ++i) {
		type = LogicLanguageServices.getTypeRepository()
				.getTypeCreateIfNeeded(type, argType);
	}
	return LogicalConstant
			.createDynamic(constant.getBaseName(), type, true);
}
 
Example #27
Source File: GenerationRepository.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
protected List<List<LogicalConstant>> createPotentialConstantSeqs(
		Set<LogicalConstant> constants, FactoringSignature signature) {
	if (signature.getTypes().isEmpty()) {
		// Case no arguments, create the empty list.
		return ListUtils.createSingletonList(
				Collections.<LogicalConstant> emptyList());
	} else {
		final List<Set<LogicalConstant>> setsOfConsts = new ArrayList<Set<LogicalConstant>>(
				signature.getTypes().size());
		final List<List<LogicalConstant>> potentialConstantSeqs = new LinkedList<List<LogicalConstant>>();
		// Create a the set of constants for each type in the signature.
		for (final Type type : signature.getTypes()) {
			final Set<LogicalConstant> consts = new HashSet<LogicalConstant>();
			for (final LogicalConstant constant : constants) {
				if (LogicLanguageServices.getTypeRepository()
						.generalizeType(constant.getType()).equals(type)) {
					consts.add(constant);
				}
			}
			setsOfConsts.add(consts);
		}

		for (final List<LogicalConstant> constantsList : CollectionUtils
				.cartesianProduct(setsOfConsts)) {
			potentialConstantSeqs
					.add(Collections.unmodifiableList(constantsList));
		}
		return potentialConstantSeqs;
	}
}
 
Example #28
Source File: TemplateCoarseGenlex.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
private Set<LogicalConstant> createAbstractConstants() {
	final Set<LogicalConstant> abstractConstants = new HashSet<LogicalConstant>();
	for (final LogicalConstant constant : constants) {
		final Type type = LogicLanguageServices.getTypeRepository()
				.generalizeType(constant.getType());
		abstractConstants.add(LogicalConstant
				.createDynamic(CONST_SEED_NAME, type, true));
	}
	return abstractConstants;
}
 
Example #29
Source File: AmrToLogicalExpressionConverter.java    From amr with GNU General Public License v2.0 5 votes vote down vote up
private static Literal createBinaryLiteral(String predicateName,
		LogicalExpression arg1, LogicalExpression arg2, Type returnType) {
	return createBinaryLiteral(
			createConstant(
					predicateName,
					LogicLanguageServices.getTypeRepository()
							.getTypeCreateIfNeeded(
									LogicLanguageServices
											.getTypeRepository()
											.getTypeCreateIfNeeded(
													returnType,
													arg2.getType()),
									arg1.getType())), arg1, arg2);
}
 
Example #30
Source File: FactoringServices.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
private LogicalConstant makeConstant(Type type) {
	final Type generalType = LogicLanguageServices
			.getTypeRepository().generalizeType(type);

	return LogicalConstant.createDynamic("#"
			+ (counters.containsKey(generalType)
					? counters.get(generalType).value() : 0)
			+ generalType, generalType, true);
}