/** Constructs and appends an instance to this list, passing it through this * list's pipe. Default weight is 1.0. * @return <code>true</code> */ public boolean add (Object data, Object target, Object name, Object source) { return add (data, target, name, source, 1.0); }
/** Constructs and appends an instance to this list, passing it through this * list's pipe and assigning it the specified weight. * @return <code>true</code> */ public boolean add (Object data, Object target, Object name, Object source, double instanceWeight) { return add (new Instance (data, target, name, source, pipe), instanceWeight); }
protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes) { System.out.println("PairIterator..."); long timeStart = System.currentTimeMillis(); InstanceList ilist = new InstanceList (instancePipe); ilist.add (new NodePairIterator (nodes) ); System.out.println("===="); long timeEnd = System.currentTimeMillis(); double timeElapse = (timeEnd - timeStart)/(1000.000); System.out.println("Time elapses " + timeElapse + " seconds for computing pair iterator."); return ilist; } protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes, List pairs) {
protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes, List pairs) { System.out.println("PairIterator..."); long timeStart = System.currentTimeMillis(); InstanceList ilist = new InstanceList (instancePipe); ilist.add (new NodePairIterator (nodes, pairs) ); System.out.println("===="); long timeEnd = System.currentTimeMillis(); double timeElapse = (timeEnd - timeStart)/(1000.000); System.out.println("Time elapses " + timeElapse + " seconds for computing pair iterator."); return ilist; } /*
protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes, List pairs) { System.out.println("PairIterator..."); long timeStart = System.currentTimeMillis(); InstanceList ilist = new InstanceList (instancePipe); ilist.add (new NodePairIterator (nodes, pairs) ); System.out.println("===="); long timeEnd = System.currentTimeMillis(); double timeElapse = (timeEnd - timeStart)/(1000.000); System.out.println("Time elapses " + timeElapse + " seconds for computing pair iterator."); return ilist; } /*
protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes) { System.out.println("PairIterator..."); long timeStart = System.currentTimeMillis(); InstanceList ilist = new InstanceList (instancePipe); ilist.add (new NodePairIterator (nodes) ); System.out.println("===="); long timeEnd = System.currentTimeMillis(); double timeElapse = (timeEnd - timeStart)/(1000.000); System.out.println("Time elapses " + timeElapse + " seconds for computing pair iterator."); return ilist; } protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes, List pairs) {
protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes, List pairs) { System.out.println("PairIterator..."); long timeStart = System.currentTimeMillis(); InstanceList ilist = new InstanceList (instancePipe); ilist.add (new NodePairIterator (nodes, pairs) ); System.out.println("===="); long timeEnd = System.currentTimeMillis(); double timeElapse = (timeEnd - timeStart)/(1000.000); System.out.println("Time elapses " + timeElapse + " seconds for computing pair iterator."); return ilist; } /*
protected static InstanceList makePairs(Pipe instancePipe, ArrayList nodes, List pairs) { System.out.println("PairIterator..."); long timeStart = System.currentTimeMillis(); InstanceList ilist = new InstanceList (instancePipe); ilist.add (new NodePairIterator (nodes, pairs) ); System.out.println("===="); long timeEnd = System.currentTimeMillis(); double timeElapse = (timeEnd - timeStart)/(1000.000); System.out.println("Time elapses " + timeElapse + " seconds for computing pair iterator."); return ilist; } /*
public static InstanceList makePairs(Pipe instancePipe, ArrayList nodes, List pairs) { logger.fine("PairIterator..."); long timeStart = System.currentTimeMillis(); InstanceList ilist = new InstanceList (instancePipe); ilist.add (new NodePairIterator (nodes, pairs) ); logger.fine("===="); long timeEnd = System.currentTimeMillis(); double timeElapse = (timeEnd - timeStart)/(1000.000); logger.fine("Time elapses " + timeElapse + " seconds for computing pair iterator."); return ilist; }
public InstanceList pipeInstances (PipeInputIterator source) { // I think that pipes should be associated neither with InstanceLists, nor // with Instances. -cas InstanceList toked = new InstanceList (tokenizationPipe); toked.add (source); InstanceList piped = new InstanceList (getFeaturePipe ()); piped.add (new InstanceListIterator (toked)); return piped; }
public InstanceList shallowClone () { InstanceList ret = new InstanceList (pipe, instances.size()); for (int i = 0; i < instances.size(); i++) ret.add (getInstance(i)); if (instanceWeights == null) ret.instanceWeights = null; else ret.instanceWeights = instanceWeights.cloneDoubleList(); return ret; }
public TreeModel (Pipe instancePipe, ArrayList nodes1, ArrayList nodes2, ArrayList nodes3, ArrayList pubs1, ArrayList pubs2, ArrayList pubs3) { this.instancePipe = instancePipe; ilist = new InstanceList (instancePipe); ilist.add (new PubCitIterator (nodes1, pubs1) ); ilist.add (new PubCitIterator (nodes2, pubs2) ); ilist.add (new PubCitIterator (nodes3, pubs3) ); instancePipe.getDataAlphabet().stopGrowth(); treeModel = (MaxEnt)(new MaxEntTrainer().train (ilist, null, null, null, null)); }
public InstanceList getInstances() { InstanceList ret = new InstanceList(m_ilist.getPipe()); for (int ii = 0; ii < m_instIndices.length; ii++) ret.add(m_ilist.getInstance(m_instIndices[ii])); return ret; }
/** Iterates over {@link Segment}s for only one {@link Instance}. */ public SegmentIterator (Transducer model, Instance instance, Object[] segmentStartTags, Object[] segmentContinueTags) { InstanceList ilist = new InstanceList (instance.getPipe ()); ilist.add (instance); setSubIterator (model, ilist, segmentStartTags, segmentContinueTags); }
/** Return an list of instances with a particular label. */ public InstanceList getCluster(int label) { InstanceList cluster = new InstanceList(instances.getPipe() ); for (int n=0 ; n<instances.size() ; n++ ) { if ( labels[n] == label) cluster.add( instances.getInstance(n) ); } return cluster; }
public Sequence pipeInput (Object input) { InstanceList all = new InstanceList (getFeaturePipe ()); all.add (input, null, null, null); return (Sequence) all.getInstance (0).getData(); } }
public TreeModel (Pipe instancePipe, ArrayList nodes, ArrayList pubs) { this.instancePipe = instancePipe; ilist = new InstanceList (instancePipe); ilist.add (new PubCitIterator (nodes, pubs) ); instancePipe.getDataAlphabet().stopGrowth(); System.out.println(" >>>> Training Tree Model <<<< "); treeModel = (MaxEnt)(new MaxEntTrainer().train (ilist, null, null, null, null)); }
public Classifier trainPairwiseClassifier (ArrayList[] nodes, Pipe p) { InstanceList ilist = new InstanceList (p); for (int i=0; i < nodes.length; i++) ilist.add (CitationUtils.makePairs (p, nodes[i])); System.err.println ("Training size: " + ilist.size() + "\tNum features: " + ilist.getDataAlphabet().size()); MaxEnt me = (MaxEnt)(new MaxEntTrainer().train(ilist, null, null, null, null)); ilist.getDataAlphabet().stopGrowth(); Trial t = new Trial(me, ilist); System.out.println("Pairwise classifier: -> Training F1 on \"yes\" is: " + t.labelF1("yes")); System.out.println("Pairwise classifier: -> Training F1 on \"no\" is: " + t.labelF1("no")); return me; }
private static Classifier trainPairwiseClassifier (ArrayList[] nodes, Pipe p) { InstanceList ilist = new InstanceList (p); for (int i=0; i < nodes.length; i++) ilist.add (CitationUtils.makePairs (p, nodes[i])); MaxEnt me = (MaxEnt)(new MaxEntTrainer().train(ilist, null, null, null, null)); ilist.getDataAlphabet().stopGrowth(); Trial t = new Trial(me, ilist); System.out.println("Pairwise classifier: -> Training F1 on \"yes\" is: " + t.labelF1("yes")); return me; }
/** Adds to this list every instance generated by the iterator, * passing each one through this list's pipe. */ public void add (PipeInputIterator pi) { int i=0; while (pi.hasNext()) { Instance carrier = pi.nextInstance(); // xxx Perhaps try to arrange this so that a new Instance does not have to allocated. add (new Instance (carrier.getData(), carrier.getTarget(), carrier.name, carrier.getSource(), this.pipe)); } }