本文整理汇总了Java中edu.berkeley.nlp.util.StringUtils类的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtils类属于edu.berkeley.nlp.util包,在下文中一共展示了StringUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString_old
import edu.berkeley.nlp.util.StringUtils; //导入依赖的package包/类
public String toString_old() {
Numberer n = Numberer.getGlobalNumberer("tags");
return "\""
+ StringUtils.escapeString(n.object(parentState).toString(),
charsToEscape, '\\')
+ "\" -> \""
+ StringUtils.escapeString(n.object(childState).toString(),
charsToEscape, '\\') + "\" "
+ ArrayUtil.toString(scores);
}
示例2: toString_old
import edu.berkeley.nlp.util.StringUtils; //导入依赖的package包/类
public String toString_old() {
Numberer n = Numberer.getGlobalNumberer("tags");
return "\""
+ StringUtils.escapeString(n.object(parentState).toString(),
charsToEscape, '\\')
+ "\" -> \""
+ StringUtils.escapeString(n.object(leftChildState).toString(),
charsToEscape, '\\')
+ "\" \""
+ StringUtils.escapeString(
n.object(rightChildState).toString(), charsToEscape,
'\\') + "\" " + ArrayUtil.toString(scores);
}
示例3: showScores
import edu.berkeley.nlp.util.StringUtils; //导入依赖的package包/类
public void showScores(double[][][][] scores, String title) {
System.out.println(title);
for (int diff = 1; diff <= length; diff++) {
for (int start = 0; start < (length - diff + 1); start++) {
int end = start + diff;
System.out.print("[" + start + " " + end + "]: ");
// List<Integer> possibleSt = possibleStates[start][end];
List<Integer> possibleSt = null;
if (noConstrains) {
possibleSt = new ArrayList<Integer>();
for (int i = 0; i < numStates; i++) {
possibleSt.add(i);
}
} else {
possibleSt = possibleStates[start][end];
}
for (int state : possibleSt) {
if (scores[start][end][state] != null) {
for (int s = 0; s < grammar.numSubStates[state]; s++) {
Numberer n = grammar.tagNumberer;
System.out.print("("
+ StringUtils.escapeString(n.object(state)
.toString(), new char[] { '\"' },
'\\') + "[" + s + "] "
+ scores[start][end][state][s] + ")");
}
}
}
System.out.println();
}
}
}
示例4: main
import edu.berkeley.nlp.util.StringUtils; //导入依赖的package包/类
public static void main(String[] argv) {
PTBLineLexer tokenizer = new PTBLineLexer();
try {
for (String line : Iterators.able(IOUtils.lineIterator(argv[0]))) {
final List<String> tokenizeLine = tokenizer.tokenizeLine(line);
if (tokenizeLine.get(tokenizeLine.size() - 1) == null)
tokenizeLine.remove(tokenizeLine.size() - 1);
System.out.println(StringUtils.join(tokenizeLine));
}
} catch (IOException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e);
}
}
示例5: toString
import edu.berkeley.nlp.util.StringUtils; //导入依赖的package包/类
public String toString() {
return "[" + StringUtils.join(num2name) + "]";
}
示例6: ptb2Text
import edu.berkeley.nlp.util.StringUtils; //导入依赖的package包/类
/**
* Returns a presentable version of the given PTB-tokenized words. Pass in a
* List of Words or Strings, or a Document and this method will join the
* words with spaces and call {@link #ptb2Text(String) } on the output. This
* method will check if the elements in the list are subtypes of Word, and
* if so, it will take the word() values to prevent additional text from
* creeping in (e.g., POS tags). Otherwise the toString value will be used.
*/
public static String ptb2Text(List ptbWords) {
for (int i = 0; i < ptbWords.size(); i++)
if (ptbWords.get(i) instanceof String)
ptbWords.set(i, (ptbWords.get(i)));
return (ptb2Text(StringUtils.join(ptbWords)));
}