edu.cornell.cs.nlp.utils.string.StringUtils Java Examples

The following examples show how to use edu.cornell.cs.nlp.utils.string.StringUtils. 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: LogicalExpressionSimpleIndenter.java    From UDepLambda with Apache License 2.0 5 votes vote down vote up
@Override
final public void visit(Lambda lambda) {
	outputString.append("(lambda ");
	lambda.getArgument().accept(this);
	++currentDepth;
	outputString.append("\n"
			+ StringUtils.multiply(indentation, currentDepth));
	lambda.getBody().accept(this);
	--currentDepth;
	outputString.append(')');
}
 
Example #2
Source File: TaskResult.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
public TaskResult(Object output, long taskId, Throwable exception,
		String log) {
	this.output = output;
	this.taskId = taskId;
	this.exception = exception;
	this.log = StringUtils.escapeForPrint(log);
}
 
Example #3
Source File: LogicalExpressionSimpleIndenter.java    From UDepLambda with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(Literal literal) {
	final int len = literal.numArgs();
	 TypeRepository typeRepository = LogicLanguageServices
		        .getTypeRepository();
	
	if (LogicLanguageServices.isCoordinationPredicate(literal
			.getPredicate())
			// TODO: Fix this hack. Figure out how 
			|| literal.getPredicate().equals(AND_c)) {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		++currentDepth;
		for (int i = 0; i < len; ++i) {
			outputString.append("\n"
					+ StringUtils.multiply(indentation, currentDepth));
			literal.getArg(i).accept(this);
		}
		--currentDepth;
		outputString.append(')');
	} else if (literal.getPredicate().equals(EX_ex)) {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		outputString.append(' ');
		literal.getArg(0).accept(this); // the variable
		
		++currentDepth;
		for (int i = 1; i < len; ++i) {
			outputString.append("\n"
					+ StringUtils.multiply(indentation, currentDepth));
			literal.getArg(i).accept(this);
		}
		--currentDepth;
		outputString.append(')');
	} else if (!HasFreeVariables.of(literal, true)
			&& outputString.length() > 0) {
		++currentDepth;
		outputString.append("\n"
				+ StringUtils.multiply(indentation, currentDepth));
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		// ++currentDepth;
		for (int i = 0; i < len; ++i) {
			// outputString.append("\n"
			// + StringUtils.multiply(indentation, currentDepth));
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		// --currentDepth;
		--currentDepth;
		outputString.append(')');
	} else {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		for (int i = 0; i < len; ++i) {
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		outputString.append(')');
	}
}
 
Example #4
Source File: LogicalExpressionToAmr.java    From amr with GNU General Public License v2.0 4 votes vote down vote up
private void appendIndentation() {
	if (indent) {
		appendString("\n%s",
				StringUtils.multiply(indentString, currentDepth));
	}
}
 
Example #5
Source File: LogicalExpressionToIndentedString.java    From spf with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(Literal literal) {
	final int len = literal.numArgs();
	if (LogicLanguageServices.isCoordinationPredicate(literal
			.getPredicate())) {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		++currentDepth;
		for (int i = 0; i < len; ++i) {
			outputString.append("\n"
					+ StringUtils.multiply(indentation, currentDepth));
			literal.getArg(i).accept(this);
		}
		--currentDepth;
		outputString.append(')');
	} else if (!HasFreeVariables.of(literal, true)
			&& outputString.length() > 0) {
		++currentDepth;
		outputString.append("\n"
				+ StringUtils.multiply(indentation, currentDepth));
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		// ++currentDepth;
		for (int i = 0; i < len; ++i) {
			// outputString.append("\n"
			// + StringUtils.multiply(indentation, currentDepth));
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		// --currentDepth;
		--currentDepth;
		outputString.append(')');
	} else {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		for (int i = 0; i < len; ++i) {
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		outputString.append(')');
	}
}