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


Java Util.findClosingBracket方法代碼示例

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


在下文中一共展示了Util.findClosingBracket方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: canApply

import edu.uw.easysrl.util.Util; //導入方法依賴的package包/類
@Override
boolean canApply(final String input, final Map<String, Variable> nameToVar) {
	final int i = input.indexOf("(");
	if (i == -1 || Util.findClosingBracket(input, i) != input.length() - 1) {
		return false;
	}

	return CONSTANT_PARSER.canApply(input.substring(0, i), nameToVar);
}
 
開發者ID:uwnlp,項目名稱:EasySRL,代碼行數:10,代碼來源:LogicParser.java

示例2: valueOfUncached

import edu.uw.easysrl.util.Util; //導入方法依賴的package包/類
/**
 * Builds a category from a string representation.
 */
private static Category valueOfUncached(final String source) {
	// Categories have the form: ((X/Y)\Z[feature]){ANNOTATION}
	String newSource = source;

	if (newSource.startsWith("(")) {
		final int closeIndex = Util.findClosingBracket(newSource);

		if (Util.indexOfAny(newSource.substring(closeIndex), "/\\|") == -1) {
			// Simplify (X) to X
			newSource = newSource.substring(1, closeIndex);
			final Category result = valueOf(newSource);

			return result;
		}
	}

	final int endIndex = newSource.length();

	final int opIndex = Util.findNonNestedChar(newSource, "/\\|");

	if (opIndex == -1) {
		// Atomic Category
		int featureIndex = newSource.indexOf("[");
		final List<String> features = new ArrayList<>();

		final String base = (featureIndex == -1 ? newSource : newSource.substring(0, featureIndex));

		while (featureIndex > -1) {
			features.add(newSource.substring(featureIndex + 1, newSource.indexOf("]", featureIndex)));
			featureIndex = newSource.indexOf("[", featureIndex + 1);
		}

		if (features.size() > 1) {
			throw new RuntimeException("Can only handle single features: " + source);
		}

		final String feature = features.size() == 0 ? null : features.get(0);
		final Category c = new AtomicCategory(base, feature);
		return c;
	} else {
		// Functor Category

		final Category left = valueOf(newSource.substring(0, opIndex));
		final Category right = valueOf(newSource.substring(opIndex + 1, endIndex));
		return new FunctorCategory(left, Slash.fromString(newSource.substring(opIndex, opIndex + 1)), right);
	}
}
 
開發者ID:uwnlp,項目名稱:EasySRL,代碼行數:51,代碼來源:Category.java


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