本文整理汇总了Java中edu.stanford.nlp.util.StringUtils.padLeft方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.padLeft方法的具体用法?Java StringUtils.padLeft怎么用?Java StringUtils.padLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.padLeft方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
private String convert(String in, boolean unicodeToBuckwalter) {
// System.err.println("convert u2b: " + unicodeToBuckwalter + " on " + in);
StringBuilder res = new StringBuilder(in.length());
for (int i = 0, sz = in.length(); i < sz; i++) {
Character inCh = Character.valueOf(in.charAt(i));
Character outCh;
if (unicodeToBuckwalter) {
if (PASS_ASCII_IN_UNICODE && inCh.charValue() < 127) {
outCh = inCh;
} else {
outCh = a2b.get(inCh);
}
} else {
if (SUPPRESS_DIGIT_MAPPING_IN_B2A && (inCh >= '0' && inCh <= '9')) {
outCh = inCh;
} else {
outCh = b2a.get(inCh);
}
}
if (outCh == null) {
if (DEBUG) {
String key = inCh + "[U+" +
StringUtils.padLeft(Integer.toString(inCh, 16).toUpperCase(), 4, '0') + ']';
unmappable.incrementCount(key);
}
res.append(inCh); // pass through char
} else {
if(!outputUnicodeValues) {
res.append(outCh);
} else {
res.append("\\u").append(StringUtils.padLeft(Integer.toString(inCh, 16).toUpperCase(), 4, '0'));
}
}
}
return res.toString();
}
示例2: convert
import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
private String convert(String in, boolean unicodeToBuckwalter) {
final StringTokenizer st = new StringTokenizer(in);
final StringBuilder result = new StringBuilder(in.length());
while(st.hasMoreTokens()) {
final String token = st.nextToken();
for (int i = 0; i < token.length(); i++) {
if(ATBTreeUtils.reservedWords.contains(token)) {
result.append(token);
break;
}
final Character inCh = Character.valueOf(token.charAt(i));
Character outCh = null;
if (unicodeToBuckwalter) {
outCh = (PASS_ASCII_IN_UNICODE && inCh.charValue() < 127) ? inCh : u2bMap.get(inCh);
} else if((SUPPRESS_DIGIT_MAPPING_IN_B2A && Character.isDigit(inCh)) ||
(SUPPRESS_PUNC_MAPPING_IN_B2A && latinPunc.matcher(inCh.toString()).matches())) {
outCh = inCh;
} else {
outCh = b2uMap.get(inCh);
}
if (outCh == null) {
if (DEBUG) {
String key = inCh + "[U+" +
StringUtils.padLeft(Integer.toString(inCh, 16).toUpperCase(), 4, '0') + ']';
unmappable.incrementCount(key);
}
result.append(inCh); // pass through char
} else if(outputUnicodeValues) {
result.append("\\u").append(StringUtils.padLeft(Integer.toString(inCh, 16).toUpperCase(), 4, '0'));
} else {
result.append(outCh);
}
}
result.append(" ");
}
return result.toString().trim();
}