/** * Transfer some Pipes from the feature pipe to the tokenization pipe. * The feature pipe must be a SerialPipes. This will destructively modify the CRF object of the extractor. * This is useful if you have a CRF hat has been trained from a single pipe, which you need to split up * int feature and tokenization pipes */ public void slicePipes (int num) { Pipe fpipe = getFeaturePipe (); if (!(fpipe instanceof SerialPipes)) throw new IllegalArgumentException ("slicePipes: FeaturePipe must be a SerialPipes."); SerialPipes sp = (SerialPipes) fpipe; ArrayList pipes = new ArrayList (); for (int i = 0; i < num; i++) { pipes.add (sp.getPipe (0)); //sp.removePipe (0); TODO Fix this } //setTokenizationPipe (sp); TODO Fix this throw new UnsupportedOperationException ("Not yet implemented..."); }
/** * Transfer some Pipes from the feature pipe to the tokenization pipe. * The feature pipe must be a SerialPipes. This will destructively modify the CRF object of the extractor. * This is useful if you have a CRF hat has been trained from a single pipe, which you need to split up * int feature and tokenization pipes */ public void slicePipes (int num) { Pipe fpipe = getFeaturePipe (); if (!(fpipe instanceof SerialPipes)) throw new IllegalArgumentException ("slicePipes: FeaturePipe must be a SerialPipes."); SerialPipes sp = (SerialPipes) fpipe; ArrayList pipes = new ArrayList (); for (int i = 0; i < num; i++) { pipes.add (sp.getPipe (0)); //sp.removePipe (0); TODO Fix this } //setTokenizationPipe (sp); TODO Fix this throw new UnsupportedOperationException ("Not yet implemented..."); }
/** * Transfer some Pipes from the feature pipe to the tokenization pipe. * The feature pipe must be a SerialPipes. This will destructively modify the CRF object of the extractor. * This is useful if you have a CRF hat has been trained from a single pipe, which you need to split up * int feature and tokenization pipes */ public void slicePipes (int num) { Pipe fpipe = getFeaturePipe (); if (!(fpipe instanceof SerialPipes)) throw new IllegalArgumentException ("slicePipes: FeaturePipe must be a SerialPipes."); SerialPipes sp = (SerialPipes) fpipe; ArrayList pipes = new ArrayList (); for (int i = 0; i < num; i++) { pipes.add (sp.getPipe (0)); //sp.removePipe (0); TODO Fix this } //setTokenizationPipe (sp); TODO Fix this throw new UnsupportedOperationException ("Not yet implemented..."); }
public Sequence pipeInput (Object input) { InstanceList all = new InstanceList (getFeaturePipe ()); all.add (input, null, null, null); return (Sequence) all.get (0).getData(); } }
public Sequence pipeInput (Object input) { InstanceList all = new InstanceList (getFeaturePipe ()); all.add (input, null, null, null); return (Sequence) all.get (0).getData(); } }
public Sequence pipeInput (Object input) { InstanceList all = new InstanceList (getFeaturePipe ()); all.add (input, null, null, null); return (Sequence) all.get (0).getData(); } }
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 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 Extraction extract (Iterator<Instance> source) { Extraction extraction = new Extraction (this, getTargetAlphabet ()); // Put all the instances through both pipes, then get viterbi path InstanceList tokedList = new InstanceList (tokenizationPipe); tokedList.addThruPipe (source); InstanceList pipedList = new InstanceList (getFeaturePipe ()); pipedList.addThruPipe (tokedList.iterator()); Iterator<Instance> it1 = tokedList.iterator (); Iterator<Instance> it2 = pipedList.iterator (); while (it1.hasNext()) { Instance toked = it1.next(); Instance piped = it2.next (); 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; }
public Extraction extract (Iterator<Instance> source) { Extraction extraction = new Extraction (this, getTargetAlphabet ()); // Put all the instances through both pipes, then get viterbi path InstanceList tokedList = new InstanceList (tokenizationPipe); tokedList.addThruPipe (source); InstanceList pipedList = new InstanceList (getFeaturePipe ()); pipedList.addThruPipe (tokedList.iterator()); Iterator<Instance> it1 = tokedList.iterator (); Iterator<Instance> it2 = pipedList.iterator (); while (it1.hasNext()) { Instance toked = it1.next(); Instance piped = it2.next (); 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; }
public Extraction extract (Iterator<Instance> source) { Extraction extraction = new Extraction (this, getTargetAlphabet ()); // Put all the instances through both pipes, then get viterbi path InstanceList tokedList = new InstanceList (tokenizationPipe); tokedList.addThruPipe (source); InstanceList pipedList = new InstanceList (getFeaturePipe ()); pipedList.addThruPipe (tokedList.iterator()); Iterator<Instance> it1 = tokedList.iterator (); Iterator<Instance> it2 = pipedList.iterator (); while (it1.hasNext()) { Instance toked = it1.next(); Instance piped = it2.next (); 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; }
private static ExtorInfo infoForDoc (String doc, String desc, String idx, DocumentExtraction docextr, CRFExtractor extor, boolean showLattice) { // Instance c2 = new Instance (doc, null, null, null, extor.getTokenizationPipe ()); // TokenSequence input = (TokenSequence) c2.getData (); TokenSequence input = (TokenSequence) docextr.getInput (); LabelSequence target = docextr.getTarget (); Sequence predicted = docextr.getPredictedLabels (); ExtorInfo info = new ExtorInfo (input, predicted, target, desc, idx); if (showLattice == true) { CRF crf = extor.getCrf(); // xxx perhaps the next two lines could be a transducer method??? Instance carrier = extor.getFeaturePipe().pipe(new Instance (input, null, null, null)); info.fvs = (FeatureVectorSequence) carrier.getData (); info.lattice = new MaxLatticeDefault (crf, (Sequence) carrier.getData(), null); info.bestStates = info.lattice.bestOutputSequence(); } return info; }
private static ExtorInfo infoForDoc (String doc, String desc, String idx, DocumentExtraction docextr, CRFExtractor extor, boolean showLattice) { // Instance c2 = new Instance (doc, null, null, null, extor.getTokenizationPipe ()); // TokenSequence input = (TokenSequence) c2.getData (); TokenSequence input = (TokenSequence) docextr.getInput (); LabelSequence target = docextr.getTarget (); Sequence predicted = docextr.getPredictedLabels (); ExtorInfo info = new ExtorInfo (input, predicted, target, desc, idx); if (showLattice == true) { CRF crf = extor.getCrf(); // xxx perhaps the next two lines could be a transducer method??? Instance carrier = extor.getFeaturePipe().pipe(new Instance (input, null, null, null)); info.fvs = (FeatureVectorSequence) carrier.getData (); info.lattice = new MaxLatticeDefault (crf, (Sequence) carrier.getData(), null); info.bestStates = info.lattice.bestOutputSequence(); } return info; }
private static ExtorInfo infoForDoc (String doc, String desc, String idx, DocumentExtraction docextr, CRFExtractor extor, boolean showLattice) { // Instance c2 = new Instance (doc, null, null, null, extor.getTokenizationPipe ()); // TokenSequence input = (TokenSequence) c2.getData (); TokenSequence input = (TokenSequence) docextr.getInput (); LabelSequence target = docextr.getTarget (); Sequence predicted = docextr.getPredictedLabels (); ExtorInfo info = new ExtorInfo (input, predicted, target, desc, idx); if (showLattice == true) { CRF crf = extor.getCrf(); // xxx perhaps the next two lines could be a transducer method??? Instance carrier = extor.getFeaturePipe().pipe(new Instance (input, null, null, null)); info.fvs = (FeatureVectorSequence) carrier.getData (); info.lattice = new MaxLatticeDefault (crf, (Sequence) carrier.getData(), null); info.bestStates = info.lattice.bestOutputSequence(); } return info; }