本文整理匯總了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)));
}