public Instance shallowCopy () { Instance ret = new Instance (data, target, name, source); ret.locked = locked; ret.properties = properties; return ret; }
public Instance next () { File nextFile = subIterator.next(); fileCount++; return new Instance (nextFile, null, nextFile.toURI(), null); }
public Instance next () { URI uri = null; try { uri = new URI ("array:" + index); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException(); } return new Instance (data[index++], null, uri, null); }
public Instance next () { URI uri = null; try { uri = new URI ("array:" + index); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException(); } return new Instance (data[index++], null, uri, null); }
public Instance next () { Segment nextSegment = (Segment) subIterator.next(); return new Instance (nextSegment, nextSegment.getTruth (), null, null); }
public Instance next () { Segment nextSegment = (Segment) subIterator.next(); return new Instance (nextSegment, nextSegment.getTruth (), null, null); }
public Instance next () { Instance carrier = new Instance (nextGroup, null, "parengroup"+(groupIdx++), null); nextGroup = getNextGroup (); return carrier; }
public Instance next () { assert (nextElement != null); Instance carrier = new Instance (nextElement, null, "element"+elementIndex++, null); nextElement = getNextElement (); return carrier; }
private Tokenization doTokenize (Object obj) { Instance toked = new Instance (obj, null, null, null); tokenizationPipe.pipe (toked); return (Tokenization) toked.getData (); }
void addInstance(int[] features, boolean positive) { FeatureVector featureVector = new FeatureVector(dataAlphabet, features); Instance instance = new Instance(featureVector, positive ? posLabel : negLabel, null, null); iList.add(instance); }
/** * Compute the maxent classification of an instance. * * @param classifier the classifier * @param features the features that are on for this instance * @return the classification */ static public Classification classify(Classifier classifier, String[] features) { return classifier.classify( new Instance(new TokenSequence(features), null, null, null)); }
/** Pipe the object through this classifier's pipe, then classify the resulting instance. */ public Classification classify (Object obj) { if (obj instanceof Instance) return classify ((Instance)obj); return classify (instancePipe.instanceFrom(new Instance (obj, null, null, null))); }
/** * Compute the maxent classification of an instance. * * @param classifier the classifier * @param features the features that are on for this instance * @return the classification */ static public Classification classify(Classifier classifier, String[] features) { return classifier.classify( new Instance(new TokenSequence(features), null, null, null)); }
public Instance next () { if (currentIndex >= currentTokenSequence.size()) { currentInstance = source.next(); currentTokenSequence = (TokenSequence) currentInstance.getData(); } Instance ret = new Instance (currentTokenSequence.get(currentIndex), ((LabelSequence)currentInstance.getTarget()).getLabelAtPosition(currentIndex), null, null); currentIndex++; return ret; } public boolean hasNext () {
public Instance next () { Instance inst = subIt.next (); inst = pipe.pipe (inst); return new Instance (inst.getData (), inst.getTarget (), inst.getName (), inst.getSource ()); }
public Instance next () { if (currentIndex >= currentTokenSequence.size()) { currentInstance = source.next(); currentTokenSequence = (TokenSequence) currentInstance.getData(); } Instance ret = new Instance (currentTokenSequence.get(currentIndex), ((LabelSequence)currentInstance.getTarget()).getLabelAtPosition(currentIndex), null, null); currentIndex++; return ret; } public boolean hasNext () {
/** Calculates the confidence in the tagging of a {@link Segment}. */ public double estimateConfidenceFor (Segment segment, SumLatticeDefault cachedLattice) { Classification c = this.meClassifier.classify (pipe.instanceFrom(new Instance ( segment, segment.getTruth(), null, null))); return c.getLabelVector().value (this.correct); } }
public void testPipesAreStupid () { Pipe p1 = new StupidPipe (); Pipe p2 = new SimpleTaggerSentence2TokenSequence (); // initialize p2's dict p2.instanceFrom(new Instance (data, null, null, null)); Pipe serial = new SerialPipes (new Pipe[] { p1, p2 }); try { serial.getDataAlphabet (); assertTrue ("Test failed: Should have generated exception.", false); } catch (IllegalStateException e) {} }
public void testConcatenateNullPipes () { Pipe p1 = new StupidPipe (); Pipe p2 = new SimpleTagger.SimpleTaggerSentence2FeatureVectorSequence (); Pipe serial = PipeUtils.concatenatePipes (p1, p2); p2.instanceFrom(new Instance (data, null, null, null)); assertEquals (3, serial.getDataAlphabet ().size ()); }
public void testConcatenatePipes () { Pipe p1 = new StupidPipe (); Pipe p2 = new SimpleTagger.SimpleTaggerSentence2FeatureVectorSequence (); // initialize p2's dict p2.instanceFrom(new Instance (data, null, null, null)); assertEquals (3, p2.getDataAlphabet ().size()); Pipe serial = PipeUtils.concatenatePipes (p1, p2); Alphabet dict = serial.getDataAlphabet (); assertEquals (3, dict.size ()); assertTrue (dict == p2.getDataAlphabet ()); }