public Instance pipe (Instance carrier) { if (carrier.getData() instanceof CharSequence) { CharSequence data = (CharSequence) carrier.getData(); carrier.setData(data.toString().toLowerCase()); } else { throw new IllegalArgumentException("CharSequenceLowercase expects a CharSequence, found a " + carrier.getData().getClass()); } return carrier; }
public Instance pipe (Instance carrier) { if (prefix != null) System.out.print (prefix); String targetString = "<null>"; if (carrier.getTarget() != null) targetString = carrier.getTarget().toString(); System.out.println ("name: " + carrier.getName() + "\ntarget: " + targetString + "\ninput: " + carrier.getData() // Swapping order, since data often has a newline at the end -DM ); return carrier; }
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 () {
@Override public Instance pipe(Instance inst) { List<String> source = (List<String>) inst.getData(); inst.setData(makeTokenSeq(source)); if (inst.getTarget() != null && updateTarget) { List<String> target = (List<String>) inst.getTarget(); Preconditions.checkState(target.size() == source.size(), "target %s source %s", target, source); inst.setTarget(makeTokenSeq(target)); } return inst; }
public Instance shallowCopy () { Instance ret = new Instance (data, target, name, source); ret.locked = locked; ret.properties = properties; return ret; }
public void unhideAllLabels () { for (int i = 0; i < this.size(); i++) { Instance instance = this.get(i); Object t; if (instance.getTarget() == null && (t=instance.getProperty(TARGET_PROPERTY)) != null) { instance.unLock(); instance.setTarget(t); instance.lock(); } } }
private static void printTrialClassification(Trial trial) { for (Classification c : trial) { Instance instance = c.getInstance(); System.out.print(instance.getName() + " " + instance.getTarget() + " "); Labeling labeling = c.getLabeling(); for (int j = 0; j < labeling.numLocations(); j++){ System.out.print(labeling.getLabelAtRank(j).toString() + ":" + labeling.getValueAtRank(j) + " "); } System.out.println(); } }
public void testOne () { Iterator iter = new PatternMatchIterator( data, Pattern.compile("<p>(.+?)</p>", Pattern.DOTALL)); int i=0; while (iter.hasNext()) { Instance inst = (Instance) iter.next(); System.out.println( inst.getName() + " : " + inst.getData() ); if (i++==0) assertTrue (inst.getData().equals("Inside inside inside")); else assertTrue (inst.getData().equals("inside\ninside")); } }
public String[] getDocumentNames() { String[] docNames = new String[ data.size() ]; for (int doc = 0; doc < docNames.length; doc++) { docNames[doc] = (String) data.get(doc).instance.getName(); } return docNames; }
/** Sets the "target" field to <code>null</code> in all instances. This makes unlabeled data. */ public void removeTargets() { for (Instance instance : this) instance.setTarget (null); }
public InstanceWithConfidence (Instance inst, double c, Sequence predicted) { this.instance = inst; this.confidence = c; this.correct = true; Sequence truth = (Sequence) inst.getTarget (); for (int i=0; i < truth.size(); i++) { if (!truth.get(i).equals (predicted.get(i))) { this.correct = false; break; } } }
public Instance pipe (Instance carrier) { if (prefix != null) System.out.print (prefix); String targetString = "<null>"; if (carrier.getTarget() != null) targetString = carrier.getTarget().toString(); System.out.println ("name: " + carrier.getName() + "\ntarget: " + targetString + "\ninput: " + carrier.getData() // Swapping order, since data often has a newline at the end -DM ); return carrier; }
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 shallowCopy () { Instance ret = new Instance (data, target, name, source); ret.locked = locked; ret.properties = properties; return ret; }