public SumLattice newSumLattice (Transducer trans, Sequence input, Sequence output, Transducer.Incrementor incrementor, boolean saveXis, LabelAlphabet outputAlphabet) { return new SumLatticeDefault (trans, input, output, incrementor, saveXis, outputAlphabet); }
public SumLattice newSumLattice (Transducer trans, Sequence input, Sequence output, Transducer.Incrementor incrementor, boolean saveXis, LabelAlphabet outputAlphabet) { return new SumLatticeDefault (trans, input, output, incrementor, saveXis, outputAlphabet); }
public SumLattice newSumLattice (Transducer trans, Sequence input, Sequence output, Transducer.Incrementor incrementor, boolean saveXis, LabelAlphabet outputAlphabet) { return new SumLatticeDefault (trans, input, output, incrementor, saveXis, outputAlphabet); }
public Void call() throws Exception { for (int ii = start; ii < end; ii++) { if (instancesWithConstraints.get(ii)) { Instance instance = data.get(ii); SumLatticeDefault lattice = new SumLatticeDefault( this.crf, (FeatureVectorSequence)instance.getData(), null, null, true); lattices.add(lattice); } else { lattices.add(null); } } return null; } }
public Void call() throws Exception { for (int ii = start; ii < end; ii++) { if (instancesWithConstraints.get(ii)) { Instance instance = data.get(ii); SumLatticeDefault lattice = new SumLatticeDefault( this.crf, (FeatureVectorSequence)instance.getData(), null, null, true); lattices.add(lattice); } else { lattices.add(null); } } return null; } }
public Void call() throws Exception { for (int ii = start; ii < end; ii++) { if (instancesWithConstraints.get(ii)) { Instance instance = data.get(ii); SumLatticeDefault lattice = new SumLatticeDefault( this.crf, (FeatureVectorSequence)instance.getData(), null, null, true); lattices.add(lattice); } else { lattices.add(null); } } return null; } }
public void testEstimate () { transducer.setTrainable (true); SumLatticeDefault lattice = new SumLatticeDefault (transducer, seq); // used to have third argument: true double oldWeight = lattice.getTotalWeight (); transducer.estimate (); lattice = new SumLatticeDefault (transducer, seq); // used to have third argument: false double newWeight = lattice.getTotalWeight (); System.out.println ("oldWeight="+oldWeight+" newWeight="+newWeight); assertTrue (newWeight < oldWeight); }
public void testForwardBackward () { SumLatticeDefault lattice = new SumLatticeDefault (transducer, seq); System.out.println ("weight= "+lattice.getTotalWeight()); assertTrue (lattice.getTotalWeight() == seqWeight); }
public void testEstimate () { transducer.setTrainable (true); SumLatticeDefault lattice = new SumLatticeDefault (transducer, seq); // used to have third argument: true double oldWeight = lattice.getTotalWeight (); transducer.estimate (); lattice = new SumLatticeDefault (transducer, seq); // used to have third argument: false double newWeight = lattice.getTotalWeight (); System.out.println ("oldWeight="+oldWeight+" newWeight="+newWeight); assertTrue (newWeight < oldWeight); }
public void testForwardBackward () { SumLatticeDefault lattice = new SumLatticeDefault (transducer, seq); System.out.println ("weight= "+lattice.getTotalWeight()); assertTrue (lattice.getTotalWeight() == seqWeight); }
/** Calculates the confidence in the tagging of a {@link Segment}. @return 0-1 confidence value. higher = more confident. */ public double estimateConfidenceFor (Segment segment, SumLatticeDefault cachedLattice) { Sequence predSequence = segment.getPredicted (); Sequence input = segment.getInput (); SumLatticeDefault lattice = (cachedLattice == null) ? new SumLatticeDefault (model, input) : cachedLattice; // constrained lattice SumLatticeDefault constrainedLattice = new SumLatticeConstrained (model, input, null, segment, predSequence); double latticeWeight = lattice.getTotalWeight (); double constrainedLatticeWeight = constrainedLattice.getTotalWeight (); double confidence = Math.exp (latticeWeight - constrainedLatticeWeight); //System.err.println ("confidence: " + confidence); return confidence; }
/** Calculates the confidence in the tagging of a {@link Instance}. */ public double estimateConfidenceFor (Instance instance, Object[] startTags, Object[] inTags) { SumLatticeDefault lattice = new SumLatticeDefault (model, (Sequence)instance.getData()); SequencePairAlignment viterbi = new MaxLatticeDefault (model, (Sequence)instance.getData()).bestOutputAlignment(); return Math.exp (viterbi.getWeight() - lattice.getTotalWeight()); } }
/** Calculates the confidence in the tagging of a {@link Segment}. @return 0-1 confidence value. higher = more confident. */ public double estimateConfidenceFor (Segment segment, SumLatticeDefault cachedLattice) { Sequence predSequence = segment.getPredicted (); Sequence input = segment.getInput (); SumLatticeDefault lattice = (cachedLattice == null) ? new SumLatticeDefault (model, input) : cachedLattice; // constrained lattice SumLatticeDefault constrainedLattice = new SumLatticeConstrained (model, input, null, segment, predSequence); double latticeWeight = lattice.getTotalWeight (); double constrainedLatticeWeight = constrainedLattice.getTotalWeight (); double confidence = Math.exp (latticeWeight - constrainedLatticeWeight); //System.err.println ("confidence: " + confidence); return confidence; }
/** Calculates the confidence in the tagging of a {@link Instance}. */ public double estimateConfidenceFor (Instance instance, Object[] startTags, Object[] inTags) { SumLatticeDefault lattice = new SumLatticeDefault (model, (Sequence)instance.getData()); SequencePairAlignment viterbi = new MaxLatticeDefault (model, (Sequence)instance.getData()).bestOutputAlignment(); return Math.exp (viterbi.getWeight() - lattice.getTotalWeight()); } }
/** Calculates the confidence in the tagging of a {@link Instance}. */ public double estimateConfidenceFor (Instance instance, Object[] startTags, Object[] inTags) { SumLatticeDefault lattice = new SumLatticeDefault (model, (Sequence)instance.getData()); SequencePairAlignment viterbi = new MaxLatticeDefault (model, (Sequence)instance.getData()).bestOutputAlignment(); return Math.exp (viterbi.getWeight() - lattice.getTotalWeight()); } }
public void testIncrement () { transducer.setTrainable (true); SumLatticeDefault lattice = new SumLatticeDefault (transducer, seq); // used to have third argument: true double oldWeight = lattice.getTotalWeight (); System.out.println ("State 0 transition estimator"); Multinomial.Estimator est = ((FeatureTransducer.State)transducer.getState(0)).getTransitionEstimator(); est.print(); assertTrue (est.getCount(0) == 2.0); assertTrue (est.getCount(1) == 1.0); }
public void testIncrement () { transducer.setTrainable (true); SumLatticeDefault lattice = new SumLatticeDefault (transducer, seq); // used to have third argument: true double oldWeight = lattice.getTotalWeight (); System.out.println ("State 0 transition estimator"); Multinomial.Estimator est = ((FeatureTransducer.State)transducer.getState(0)).getTransitionEstimator(); est.print(); assertTrue (est.getCount(0) == 2.0); assertTrue (est.getCount(1) == 1.0); }
/** Calculates the confidence in the tagging of a {@link Segment}. @return 0-1 confidence value. higher = more confident. */ public double estimateConfidenceFor (Segment segment, SumLatticeDefault cachedLattice) { Sequence predSequence = segment.getPredicted (); Sequence input = segment.getInput (); SumLatticeDefault lattice = (cachedLattice==null) ? new SumLatticeDefault (model, input) : cachedLattice; double confidence = 1; for (int i=segment.getStart(); i <= segment.getEnd(); i++) confidence *= lattice.getGammaProbability (i+1, model.getState (stateIndexOfString ((String)predSequence.get (i)))); return confidence; }
/** Calculates the confidence in the tagging of a {@link Segment}. @return 0-1 confidence value. higher = more confident. */ public double estimateConfidenceFor (Segment segment, SumLatticeDefault cachedLattice) { Sequence predSequence = segment.getPredicted (); Sequence input = segment.getInput (); SumLatticeDefault lattice = (cachedLattice==null) ? new SumLatticeDefault (model, input) : cachedLattice; double confidence = 1; for (int i=segment.getStart(); i <= segment.getEnd(); i++) confidence *= lattice.getGammaProbability (i+1, model.getState (stateIndexOfString ((String)predSequence.get (i)))); return confidence; }
/** Calculates the confidence in the tagging of a {@link Segment}. @return 0-1 confidence value. higher = more confident. */ public double estimateConfidenceFor (Segment segment, SumLatticeDefault cachedLattice) { Sequence predSequence = segment.getPredicted (); Sequence input = segment.getInput (); SumLatticeDefault lattice = (cachedLattice==null) ? new SumLatticeDefault (model, input) : cachedLattice; double confidence = 1; for (int i=segment.getStart(); i <= segment.getEnd(); i++) confidence *= lattice.getGammaProbability (i+1, model.getState (stateIndexOfString ((String)predSequence.get (i)))); return confidence; }