public ArrayList classify (InstanceList instances) { ArrayList ret = new ArrayList (instances.size()); InstanceList.Iterator iter = instances.iterator(); while (iter.hasNext()) ret.add (classify (iter.nextInstance())); return ret; }
ii++; double instanceWeight = iter.getInstanceWeight(); Instance instance = iter.nextInstance(); Labeling labeling = instance.getLabeling ();
Instance instance = iter.nextInstance(); Labeling labeling = instance.getLabeling ();
while (iter.hasNext()) { double instanceWeight = iter.getInstanceWeight(); Instance inst = iter.nextInstance(); Labeling labeling = inst.getLabeling (); FeatureVector fv = (FeatureVector) inst.getData (instancePipe);
while (iter.hasNext()) { double instanceWeight = iter.getInstanceWeight(); Instance inst = iter.nextInstance(); Labeling labeling = inst.getLabeling ();
while (iter.hasNext()) { double instanceWeight = iter.getInstanceWeight(); Instance inst = iter.nextInstance(); Labeling labeling = inst.getLabeling ();
Iterator iter = ilist.iterator(); while (iter.hasNext()) add(iter.nextInstance ()); } else if (pipe == notYetSetPipe) { Iterator iter = ilist.iterator(); while (iter.hasNext()) add (iter.nextInstance()); } else if (ilist.pipe == null) { add (iter.nextInstance ()); } else
public Extraction extract (PipeInputIterator source) { Extraction extraction = new Extraction (this, getTargetAlphabet ()); // Put all the instances through both pipes, then get viterbi path InstanceList tokedList = new InstanceList (tokenizationPipe); tokedList.add (source); InstanceList pipedList = new InstanceList (getFeaturePipe ()); pipedList.add (new InstanceListIterator (tokedList)); InstanceList.Iterator it1 = tokedList.iterator (); InstanceList.Iterator it2 = pipedList.iterator (); while (it1.hasNext()) { Instance toked = it1.nextInstance(); Instance piped = it2.nextInstance (); Tokenization tok = (Tokenization) toked.getData(); String name = piped.getName().toString(); Sequence input = (Sequence) piped.getData (); Sequence target = (Sequence) piped.getTarget (); Sequence output = crf.transduce (input); DocumentExtraction docseq = new DocumentExtraction (name, getTargetAlphabet (), tok, output, target, backgroundTag, filter); extraction.addDocumentExtraction (docseq); } return extraction; }
/** Returns the next split, given the number of folds you want in * the training data. */ public InstanceList[] nextSplit (int numTrainFolds) { InstanceList[] ret = new InstanceList[2]; ret[0] = new InstanceList (pipe); ret[1] = new InstanceList (pipe); // train on folds [index, index+numTrainFolds), test on rest for (int i = 0; i < folds.length; i++) { int foldno = (index + i) % folds.length; InstanceList addTo; if (i < numTrainFolds) { addTo = ret[0]; } else { addTo = ret[1]; } InstanceList.Iterator iter = folds[foldno].iterator(); while (iter.hasNext()) addTo.add (iter.nextInstance()); } index++; return ret; }
/** * Returns the next training/testing split. * @return A pair of lists, where <code>InstanceList[0]</code> is the larger split (training) * and <code>InstanceList[1]</code> is the smaller split (testing) */ public InstanceList[] nextSplit () { InstanceList[] ret = new InstanceList[2]; ret[0] = new InstanceList (pipe); for (int i=0; i < folds.length; i++) { if (i==index) continue; InstanceList.Iterator iter = folds[i].iterator(); while (iter.hasNext()) ret[0].add (iter.nextInstance()); } ret[1] = folds[index].shallowClone(); index++; return ret; }
public Object next () { return nextInstance(); } public void remove () { throw new UnsupportedOperationException(); }
public Instance nextInstance () { final Instance instance = iter.nextInstance (); Instance ret = new Instance (instance.getData(), instance.getTarget(), instance.getName(), instance.getSource()); ret.setPropertyList (instance.getPropertyList ()); return ret; }