/** 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)); }
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)); } }
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)); } }
/** 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)); }
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)); } }
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; }
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; }
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; }
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; }
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; }
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 ()); }
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 ()); }
public void testOne () { Pipe p = createPipe(); InstanceList ilist = new InstanceList (p); ilist.addThruPipe(new StringArrayIterator(data)); assertTrue (ilist.size() == 3); }
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; }
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); }
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); }
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()); } }
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()); } }
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()); } }
@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); }