本文整理汇总了Java中cc.mallet.extract.Tokenization类的典型用法代码示例。如果您正苦于以下问题:Java Tokenization类的具体用法?Java Tokenization怎么用?Java Tokenization使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tokenization类属于cc.mallet.extract包,在下文中一共展示了Tokenization类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pipe
import cc.mallet.extract.Tokenization; //导入依赖的package包/类
public Instance pipe (Instance carrier)
{
Object data = carrier.getData ();
if (data instanceof Tokenization) {
// we're done
} else if (data instanceof TokenSequence) {
StringBuffer buf = new StringBuffer ();
TokenSequence ts = (TokenSequence) data;
StringTokenization spans = new StringTokenization (buf); // I can use a StringBuffer as the doc! Awesome!
for (int i = 0; i < ts.size(); i++) {
Token token = ts.get(i);
int start = buf.length ();
buf.append (token.getText());
int end = buf.length();
StringSpan span = new StringSpan (buf, start, end);
span.setFeatures (token.getFeatures ());
span.setProperties (token.getProperties ());
spans.add (span);
buf.append (" ");
}
carrier.setData (spans);
} else {
throw new IllegalArgumentException ("Can't convert "+data+" to Tokenization.");
}
return carrier;
}
示例2: pipe
import cc.mallet.extract.Tokenization; //导入依赖的package包/类
public Instance pipe (Instance carrier)
{
Tokenization tok = (Tokenization) carrier.getData ();
carrier.setProperty ("TOKENIZATION", tok);
return carrier;
}