本文整理了Java中cc.mallet.types.InstanceList.addThruPipe()
方法的一些代码示例,展示了InstanceList.addThruPipe()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InstanceList.addThruPipe()
方法的具体详情如下:
包路径:cc.mallet.types.InstanceList
类名称:InstanceList
方法名:addThruPipe
[英]Adds the input instance to this list, after passing it through the InstanceList's pipe.
If several instances are to be added then accumulate them in a List\ and use addThruPipe(Iterator) instead.
[中]将输入实例通过InstanceList的管道后添加到此列表。
如果要添加多个实例,请将它们累积到列表\中,并改用addThruPipe(迭代器)。
代码示例来源:origin: cc.mallet/mallet
/** Adds the input instance to this list, after passing it through the
* InstanceList's pipe.
* <p>
* If several instances are to be added then accumulate them in a List\<Instance\>
* and use <tt>addThruPipe(Iterator<Instance>)</tt> instead.
*/
public void addThruPipe(Instance inst)
{
addThruPipe(new SingleInstanceIterator(inst));
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public static void addInstances(InstanceList instances, String[] ids, String[] texts) {
for (int i = 0; i < ids.length; i++) {
instances.addThruPipe(new Instance(texts[i], null, ids[i], null));
}
}
代码示例来源:origin: cc.mallet/mallet
public static void addInstances(InstanceList instances, String[] ids, String[] texts) {
for (int i = 0; i < ids.length; i++) {
instances.addThruPipe(new Instance(texts[i], null, ids[i], null));
}
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
/** Adds the input instance to this list, after passing it through the
* InstanceList's pipe.
* <p>
* If several instances are to be added then accumulate them in a List\<Instance\>
* and use <tt>addThruPipe(Iterator<Instance>)</tt> instead.
*/
public void addThruPipe(Instance inst)
{
addThruPipe(new SingleInstanceIterator(inst));
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public static void addInstances(InstanceList instances, String[] ids, String[] texts) {
for (int i = 0; i < ids.length; i++) {
instances.addThruPipe(new Instance(texts[i], null, ids[i], null));
}
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public InstanceList pipeInstances (Iterator<Instance> source)
{
// I think that pipes should be associated neither with InstanceLists, nor
// with Instances. -cas
InstanceList toked = new InstanceList (tokenizationPipe);
toked.addThruPipe (source);
InstanceList piped = new InstanceList (getFeaturePipe ());
piped.addThruPipe (toked.iterator());
return piped;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public InstanceList pipeInstances (Iterator<Instance> source)
{
// I think that pipes should be associated neither with InstanceLists, nor
// with Instances. -cas
InstanceList toked = new InstanceList (tokenizationPipe);
toked.addThruPipe (source);
InstanceList piped = new InstanceList (getFeaturePipe ());
piped.addThruPipe (toked.iterator());
return piped;
}
代码示例来源:origin: de.julielab/julielab-topic-modeling
public InstanceList malletPreprocess(List<TokenSequence> data) {
ArrayList<Pipe> pipeList = new ArrayList<>();
pipeList.add(new TokenSequenceRemoveStopwords(false, false));
pipeList.add(new TokenSequence2FeatureSequence());
InstanceList instances = new InstanceList(new SerialPipes(pipeList));
ArrayIterator dataListIterator = new ArrayIterator(data);
instances.addThruPipe(dataListIterator);
return instances;
}
代码示例来源:origin: cc.mallet/mallet
public static InstanceList getInstances(String dbName) throws Exception {
DBInstanceIterator dbIterator = new DBInstanceIterator(dbName);
InstanceList instances = new InstanceList(dbIterator.getPipe());
instances.addThruPipe(dbIterator);
dbIterator.cleanup();
return instances;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public static InstanceList getInstances(String dbName) throws Exception {
DBInstanceIterator dbIterator = new DBInstanceIterator(dbName);
InstanceList instances = new InstanceList(dbIterator.getPipe());
instances.addThruPipe(dbIterator);
dbIterator.cleanup();
return instances;
}
代码示例来源:origin: cc.mallet/mallet
public void testFixedNumLabels () throws IOException, ClassNotFoundException
{
Pipe p = new GenericAcrfData2TokenSequence (2);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleFixedData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public void testFixedNumLabels () throws IOException, ClassNotFoundException
{
Pipe p = new GenericAcrfData2TokenSequence (2);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleFixedData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public void testOne ()
{
Pipe p = createPipe();
InstanceList ilist = new InstanceList (p);
ilist.addThruPipe(new StringArrayIterator(data));
assertTrue (ilist.size() == 3);
}
代码示例来源:origin: org.cleartk/cleartk-ml-mallet
public InstanceList createInstanceList(File dataFile) throws IOException {
InstanceList instanceList = new InstanceList(new SerialPipes(new Pipe[] {
new Target2Label(),
new Csv2FeatureVector() }));
Reader fileReader = new FileReader(dataFile);
instanceList.addThruPipe(new DataIterator(fileReader));
fileReader.close();
return instanceList;
}
代码示例来源:origin: cc.mallet/mallet
public void testOneFromSerialized () throws IOException, ClassNotFoundException
{
Pipe p = createPipe ();
Pipe clone = (Pipe) TestSerializable.cloneViaSerialization (p);
InstanceList ilist = new InstanceList (clone);
ilist.addThruPipe(new StringArrayIterator(data));
assertTrue (ilist.size() == 3);
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public void testOneFromSerialized () throws IOException, ClassNotFoundException
{
Pipe p = createPipe ();
Pipe clone = (Pipe) TestSerializable.cloneViaSerialization (p);
InstanceList ilist = new InstanceList (clone);
ilist.addThruPipe(new StringArrayIterator(data));
assertTrue (ilist.size() == 3);
}
代码示例来源:origin: cc.mallet/mallet
public static void main(String[] args) {
String htmldir = args[0];
Pipe pipe = new SerialPipes(new Pipe[] { new Input2CharSequence(),
new CharSequenceRemoveHTML() });
InstanceList list = new InstanceList(pipe);
list.addThruPipe(new FileIterator(htmldir, FileIterator.STARTING_DIRECTORIES));
for (int index = 0; index < list.size(); index++) {
Instance inst = list.get(index);
System.err.println(inst.getData());
}
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public static void main(String[] args) {
String htmldir = args[0];
Pipe pipe = new SerialPipes(new Pipe[] { new Input2CharSequence(),
new CharSequenceRemoveHTML() });
InstanceList list = new InstanceList(pipe);
list.addThruPipe(new FileIterator(htmldir, FileIterator.STARTING_DIRECTORIES));
for (int index = 0; index < list.size(); index++) {
Instance inst = list.get(index);
System.err.println(inst.getData());
}
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public static void main(String[] args) {
String htmldir = args[0];
Pipe pipe = new SerialPipes(new Pipe[] { new Input2CharSequence(),
new CharSequenceRemoveHTML() });
InstanceList list = new InstanceList(pipe);
list.addThruPipe(new FileIterator(htmldir, FileIterator.STARTING_DIRECTORIES));
for (int index = 0; index < list.size(); index++) {
Instance inst = list.get(index);
System.err.println(inst.getData());
}
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-mallet
@Override
protected void doProcess(JCas jCas) throws AnalysisEngineProcessException {
InstanceList instances = new InstanceList(classifierModel.getInstancePipe());
instances.addThruPipe(new Instance(jCas.getDocumentText(), "", "from jcas", null));
Classification classify = classifierModel.classify(instances.get(0));
Metadata md = new Metadata(jCas);
md.setKey(metadataKey);
md.setValue(classify.getLabeling().getBestLabel().toString());
addToJCasIndex(md);
}
内容来源于网络,如有侵权,请联系作者删除!