本文整理了Java中cc.mallet.types.Instance.setSource()
方法的一些代码示例,展示了Instance.setSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.setSource()
方法的具体详情如下:
包路径:cc.mallet.types.Instance
类名称:Instance
方法名:setSource
暂无
代码示例来源:origin: com.github.steveash.mallet/mallet
public Instance pipe (Instance carrier)
{
carrier.setSource (carrier.getData());
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe (Instance carrier)
{
carrier.setSource (carrier.getData());
return carrier;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance pipe (Instance carrier)
{
carrier.setSource (carrier.getData());
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe(Instance carrier) {
StringBuffer sb = new StringBuffer();
String source = (String) carrier.getSource();
Sequence as = (Sequence) carrier.getTarget();
// int startLabelIndex = as.getAlphabet().lookupIndex("start");
for (int i = 0; i < source.length(); i++) {
System.out.println("target[" + i + "]=" + as.get(i).toString());
if (as.get(i).toString().equals("start") && i != 0)
sb.append(' ');
sb.append(source.charAt(i));
}
carrier.setSource(sb.toString());
System.out.println("carrier.getSource() = " + carrier.getSource());
return carrier;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Instance pipe(Instance carrier) {
StringBuffer sb = new StringBuffer();
String source = (String) carrier.getSource();
Sequence as = (Sequence) carrier.getTarget();
// int startLabelIndex = as.getAlphabet().lookupIndex("start");
for (int i = 0; i < source.length(); i++) {
System.out.println("target[" + i + "]=" + as.get(i).toString());
if (as.get(i).toString().equals("start") && i != 0)
sb.append(' ');
sb.append(source.charAt(i));
}
carrier.setSource(sb.toString());
System.out.println("carrier.getSource() = " + carrier.getSource());
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe(Instance carrier)
{
StringBuffer sb = new StringBuffer();
String source = (String) carrier.getSource();
Sequence as = (Sequence) carrier.getTarget();
//int startLabelIndex = as.getAlphabet().lookupIndex("start");
for (int i = 0; i < source.length(); i++) {
System.out.println("target[" + i + "]=" + as.get(i).toString());
if (as.get(i).toString().equals("start") && i != 0)
sb.append(' ');
sb.append(source.charAt(i));
}
carrier.setSource(sb.toString());
System.out.println("carrier.getSource() = " + carrier.getSource());
return carrier;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Instance pipe(Instance carrier)
{
StringBuffer sb = new StringBuffer();
String source = (String) carrier.getSource();
Sequence as = (Sequence) carrier.getTarget();
//int startLabelIndex = as.getAlphabet().lookupIndex("start");
for (int i = 0; i < source.length(); i++) {
System.out.println("target[" + i + "]=" + as.get(i).toString());
if (as.get(i).toString().equals("start") && i != 0)
sb.append(' ');
sb.append(source.charAt(i));
}
carrier.setSource(sb.toString());
System.out.println("carrier.getSource() = " + carrier.getSource());
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
carrier.setTarget(target);
if (saveSource)
carrier.setSource(source);
return carrier;
代码示例来源:origin: cc.mallet/mallet
carrier.setSource(dataTokens);
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
carrier.setSource(dataTokens);
代码示例来源:origin: com.github.steveash.mallet/mallet
carrier.setSource(dataTokens);
代码示例来源:origin: de.julielab/jcore-jpos-ae
carrier.setSource(source);
return carrier;
代码示例来源:origin: com.github.steveash.mallet/mallet
carrier.setTarget(targetTokens);
carrier.setSource(dataTokens);
代码示例来源:origin: cc.mallet/mallet
carrier.setTarget(targetTokens);
carrier.setSource(dataTokens);
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
carrier.setTarget(targetTokens);
carrier.setSource(dataTokens);
代码示例来源:origin: ch.epfl.bbp.nlp/bluima_reference_classifier
public Instance pipe(Instance carrier) {
if (carrier.getData() instanceof File) {
try {
// get file text
File file = (File) carrier.getData();
@SuppressWarnings("resource")
String txt = new LineReader(new FileInputStream(file))
.getText("\n");
// update instance values
carrier.setData(new TokenSequence(addRegexes(txt)));
carrier.setSource(txt + " [file:" + file.getName() + "]");
} catch (java.io.IOException e) {
throw new IllegalArgumentException("IOException " + e);
}
} else if (carrier.getData() instanceof String) {
String txt = (String) carrier.getData();
// update instance values
carrier.setData(new TokenSequence(addRegexes(txt)));
carrier.setSource(txt);
} else {
throw new IllegalArgumentException("must be file or string "
+ carrier.getData());
}
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe(Instance carrier) {
TokenSequence ts = (TokenSequence) carrier.getData();
TokenSequence newTs = new TokenSequence();
FeatureSequence labelSeq = new FeatureSequence(getTargetAlphabet());
boolean lastWasSpace = true;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ts.size(); i++) {
Token t = ts.get(i);
if (t.getText().equals(" "))
lastWasSpace = true;
else {
sb.append(t.getText());
newTs.add(t);
labelSeq.add(lastWasSpace ? "start" : "notstart");
lastWasSpace = false;
}
}
if (isTargetProcessing())
carrier.setTarget(labelSeq);
carrier.setData(newTs);
carrier.setSource(sb.toString());
return carrier;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Instance pipe(Instance carrier) {
TokenSequence ts = (TokenSequence) carrier.getData();
TokenSequence newTs = new TokenSequence();
FeatureSequence labelSeq = new FeatureSequence(getTargetAlphabet());
boolean lastWasSpace = true;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ts.size(); i++) {
Token t = ts.get(i);
if (t.getText().equals(" "))
lastWasSpace = true;
else {
sb.append(t.getText());
newTs.add(t);
labelSeq.add(lastWasSpace ? "start" : "notstart");
lastWasSpace = false;
}
}
if (isTargetProcessing())
carrier.setTarget(labelSeq);
carrier.setData(newTs);
carrier.setSource(sb.toString());
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe(Instance carrier)
{
StringTokenization ts = (StringTokenization) carrier.getData();
StringTokenization newTs = new StringTokenization((CharSequence) ts.getDocument ());
final LabelAlphabet dict = (LabelAlphabet) getTargetAlphabet();
LabelSequence labelSeq = new LabelSequence(dict);
Label start = dict.lookupLabel ("start");
Label notstart = dict.lookupLabel ("notstart");
boolean lastWasSpace = true;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ts.size(); i++) {
StringSpan t = (StringSpan) ts.getSpan(i);
if (t.getText().equals(" "))
lastWasSpace = true;
else {
sb.append(t.getText());
newTs.add(t);
labelSeq.add(lastWasSpace ? "start" : "notstart");
lastWasSpace = false;
}
}
if (isTargetProcessing())
carrier.setTarget(labelSeq);
carrier.setData(newTs);
carrier.setSource(sb.toString());
return carrier;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Instance pipe(Instance carrier)
{
StringTokenization ts = (StringTokenization) carrier.getData();
StringTokenization newTs = new StringTokenization((CharSequence) ts.getDocument ());
final LabelAlphabet dict = (LabelAlphabet) getTargetAlphabet();
LabelSequence labelSeq = new LabelSequence(dict);
Label start = dict.lookupLabel ("start");
Label notstart = dict.lookupLabel ("notstart");
boolean lastWasSpace = true;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ts.size(); i++) {
StringSpan t = (StringSpan) ts.getSpan(i);
if (t.getText().equals(" "))
lastWasSpace = true;
else {
sb.append(t.getText());
newTs.add(t);
labelSeq.add(lastWasSpace ? "start" : "notstart");
lastWasSpace = false;
}
}
if (isTargetProcessing())
carrier.setTarget(labelSeq);
carrier.setData(newTs);
carrier.setSource(sb.toString());
return carrier;
}
内容来源于网络,如有侵权,请联系作者删除!