本文整理汇总了Java中edu.berkeley.nlp.util.StrUtils类的典型用法代码示例。如果您正苦于以下问题:Java StrUtils类的具体用法?Java StrUtils怎么用?Java StrUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StrUtils类属于edu.berkeley.nlp.util包,在下文中一共展示了StrUtils类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeProgram
import edu.berkeley.nlp.util.StrUtils; //导入依赖的package包/类
private void writeProgram(File temp) {
PrintWriter out = IOUtils.openOutHard(temp);
writeObjective(out);
for (String c : constraints) {
out.println(c);
}
String intCons = "int " + StrUtils.join(integerVariables, ", ") + ";";
if (!relaxIntegerConstraint)
out.println(intCons);
out.close();
}
示例2: main
import edu.berkeley.nlp.util.StrUtils; //导入依赖的package包/类
public static void main(String[] args) {
// Basic Test
String parse = "((S (NP (DT the) (JJ quick) (JJ brown) (NN fox)) (VP (VBD jumped) (PP (IN over) (NP (DT the) (JJ lazy) (NN dog)))) (. .)))";
if (args.length > 0) {
parse = StrUtils.join(args);
}
final PennTreeReader reader = new PennTreeReader(
new StringReader(parse));
final Tree<String> tree = reader.next();
System.out.println(PennTreeRenderer.render(tree));
System.out.println(tree);
// Robustness Tests
if (args.length == 0) {
System.out.println("Testing robustness");
String unbalanced1 = "((S (NP (DT the) (JJ quick) (JJ brown) (NN fox)) (VP (VBD jumped) (PP (IN over) (NP (DT the) (JJ lazy) (NN dog)))) (. .))";
String unbalanced2 = "((S (NP (DT the) (JJ quick) (JJ brown) (NN fox))) (VP (VBD jumped) (PP (IN over) (NP (DT the) (JJ lazy) (NN dog)))) (. .)))";
System.out.println("\nMissing a paren:");
System.out.println(unbalanced1);
System.out.println(PennTreeReader.parseEasy(unbalanced1, false));
System.out.println("\nExtra paren:");
System.out.println(unbalanced2);
System.out.println(PennTreeReader.parseEasy(unbalanced2, false));
String parens = "((S (NP (DT the) (SYM () (JJ quick) (JJ brown) (SYM )) (NN fox)) (VP (VBD jumped) (PP (IN over) (NP (DT the) (JJ lazy) (NN dog)))) (. .)))";
System.out.println("\nParens as characters:");
System.out.println(parens);
System.out.println(PennTreeReader.parseEasy(parens, false));
}
}
示例3: main
import edu.berkeley.nlp.util.StrUtils; //导入依赖的package包/类
public static void main(String argv[]) throws FileNotFoundException {
BufferedReader inputData = (argv.length == 0) ? new BufferedReader(
new InputStreamReader(System.in)) : new BufferedReader(
new InputStreamReader(new FileInputStream(argv[0])));
for (Tree<String> tree : Iterators.able(new Trees.PennTreeReader(
inputData))) {
tree = new Trees.EmptyNodeStripper().transformTree(tree);
System.out.println(StrUtils.join(tree.getYield()));
}
}
示例4: addLines
import edu.berkeley.nlp.util.StrUtils; //导入依赖的package包/类
public final void addLines(int row, int column, String text) {
Pair<Integer, Integer> key = new Pair<Integer, Integer>(row, column);
String currentString = StrUtils.join(table.entries.get(key), "\n");
if (!currentString.equals(""))
currentString = currentString + "\n";
currentString += text;
set(row, column, currentString);
}