public static LabelSequence sliceLabelsSequence (LabelsSequence lbls, LabelAlphabet dict, int slice) { Label[] labels = new Label [lbls.size()]; for (int t = 0; t < lbls.size(); t++) { Label l = lbls.getLabels (t).get (slice); labels [t] = dict.lookupLabel (l.getEntry ()); } LabelSequence ls = new LabelSequence (labels); return ls; } } // SliceLabelsSequence
public static Metric getMetric(double q) { if (q == 1.0) { return new ManhattenDistance(); } else if (q == 2.0) { return new EuclideanDistance(); } else if (q == Double.POSITIVE_INFINITY) { return new InfiniteDistance(); } else { return new Minkowski(q); } }
public PerLabelInfoGain (InstanceList ilist) { double[][] pcig = calcPerLabelInfoGains (ilist); Alphabet v = ilist.getDataAlphabet(); int numClasses = ilist.getTargetAlphabet().size(); ig = new InfoGain[numClasses]; for (int i = 0; i < numClasses; i++) ig[i] = new InfoGain (v, pcig[i]); }
public FeatureSequence toFeatureSequence (Alphabet dict) { FeatureSequence fs = new FeatureSequence( dict, this.size() ); for (int i = 0; i < this.size(); i++) fs.add (dict.lookupIndex( (this.get(i)).getText())); return fs; }
public PerLabelFeatureCounts (InstanceList ilist) { dataAlphabet = ilist.getDataAlphabet(); targetAlphabet = ilist.getTargetAlphabet(); double[][] counts = calcFeatureCounts (ilist); fc = new FeatureCounts[targetAlphabet.size()]; for (int i = 0; i < fc.length; i++) fc[i] = new FeatureCounts (dataAlphabet, counts[i]); }
public Instance pipe (Instance instance) { TokenSequence sequence = (TokenSequence) instance.getData(); Token token = sequence.get(0); token.setFeatureValue(featureName, 1.0); return instance; }
private LabelSequence slice (LabelsSequence lseq, int k) { Label[] arr = new Label [lseq.size()]; for (int i = 0; i < lseq.size(); i++) { arr [i] = lseq.getLabels (i).get (k); } return new LabelSequence (arr); }
public RankedFeatureVector newRankedFeatureVector (InstanceList ilist) { assert (ilist.getTargetAlphabet() == classifications[0].getAlphabet()); return new ExpGain (ilist, classifications, gaussianPriorVariance); }
public FeatureSequence toFeatureSequence (Alphabet dict) { FeatureSequence fs = new FeatureSequence( dict, this.size() ); for (int i = 0; i < this.size(); i++) fs.add (dict.lookupIndex( (this.get(i)).getText())); return fs; }
public PerLabelInfoGain (InstanceList ilist) { double[][] pcig = calcPerLabelInfoGains (ilist); Alphabet v = ilist.getDataAlphabet(); int numClasses = ilist.getTargetAlphabet().size(); ig = new InfoGain[numClasses]; for (int i = 0; i < numClasses; i++) ig[i] = new InfoGain (v, pcig[i]); }
public PerLabelFeatureCounts (InstanceList ilist) { dataAlphabet = ilist.getDataAlphabet(); targetAlphabet = ilist.getTargetAlphabet(); double[][] counts = calcFeatureCounts (ilist); fc = new FeatureCounts[targetAlphabet.size()]; for (int i = 0; i < fc.length; i++) fc[i] = new FeatureCounts (dataAlphabet, counts[i]); }
public static LabelSequence sliceLabelsSequence (LabelsSequence lbls, LabelAlphabet dict, int slice) { Label[] labels = new Label [lbls.size()]; for (int t = 0; t < lbls.size(); t++) { Label l = lbls.getLabels (t).get (slice); labels [t] = dict.lookupLabel (l.getEntry ()); } LabelSequence ls = new LabelSequence (labels); return ls; } } // SliceLabelsSequence
public Instance pipe (Instance instance) { TokenSequence sequence = (TokenSequence) instance.getData(); Token token = sequence.get(0); token.setFeatureValue(featureName, 1.0); return instance; }
private LabelSequence slice (LabelsSequence lseq, int k) { Label[] arr = new Label [lseq.size()]; for (int i = 0; i < lseq.size(); i++) { arr [i] = lseq.getLabels (i).get (k); } return new LabelSequence (arr); }
public static Metric getMetric(double q) { if (q == 1.0) { return new ManhattenDistance(); } else if (q == 2.0) { return new EuclideanDistance(); } else if (q == Double.POSITIVE_INFINITY) { return new InfiniteDistance(); } else { return new Minkowski(q); } }
public FeatureSequence toFeatureSequence (Alphabet dict) { FeatureSequence fs = new FeatureSequence( dict, this.size() ); for (int i = 0; i < this.size(); i++) fs.add (dict.lookupIndex( (this.get(i)).getText())); return fs; }
public PerLabelInfoGain (InstanceList ilist) { double[][] pcig = calcPerLabelInfoGains (ilist); Alphabet v = ilist.getDataAlphabet(); int numClasses = ilist.getTargetAlphabet().size(); ig = new InfoGain[numClasses]; for (int i = 0; i < numClasses; i++) ig[i] = new InfoGain (v, pcig[i]); }
public PerLabelFeatureCounts (InstanceList ilist) { dataAlphabet = ilist.getDataAlphabet(); targetAlphabet = ilist.getTargetAlphabet(); double[][] counts = calcFeatureCounts (ilist); fc = new FeatureCounts[targetAlphabet.size()]; for (int i = 0; i < fc.length; i++) fc[i] = new FeatureCounts (dataAlphabet, counts[i]); }
public static LabelSequence sliceLabelsSequence (LabelsSequence lbls, LabelAlphabet dict, int slice) { Label[] labels = new Label [lbls.size()]; for (int t = 0; t < lbls.size(); t++) { Label l = lbls.getLabels (t).get (slice); labels [t] = dict.lookupLabel (l.getEntry ()); } LabelSequence ls = new LabelSequence (labels); return ls; } } // SliceLabelsSequence
public static Metric getMetric(double q) { if (q == 1.0) { return new ManhattenDistance(); } else if (q == 2.0) { return new EuclideanDistance(); } else if (q == Double.POSITIVE_INFINITY) { return new InfiniteDistance(); } else { return new Minkowski(q); } }