本文整理汇总了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);
}
示例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);
}
}