public Label lookupLabel (Object entry) { return this.lookupLabel (entry, true); }
private Label labelForTok (String tok, int lvl) { while (labelDicts.size() <= lvl) { labelDicts.add (new LabelAlphabet ()); } LabelAlphabet dict = (LabelAlphabet) labelDicts.get (lvl); return dict.lookupLabel (tok); }
private Label trimTag (LabelAlphabet dict, Label tag) { String name = (String) tag.getEntry (); return dict.lookupLabel (name.substring (2)); }
private Label trimTag (LabelAlphabet dict, Label tag) { String name = (String) tag.getEntry (); return dict.lookupLabel (name.substring (2)); }
public Label getLabelAtRank (int rank) { if (rankOrder == null) setRankOrder (); return ((LabelAlphabet)dictionary).lookupLabel (rankOrder[rank]); }
/** * gets you the LabelAlphabet representation of the tags. */ public LabelAlphabet getAlphabet() { final LabelAlphabet dict = new LabelAlphabet(); for (int i = 0; i < tags.size(); i++) { final String label = tags.get(i); dict.lookupLabel(label, true); } return dict; }
public DocumentExtraction (String name, LabelAlphabet dict, Tokenization input, LabeledSpans predictedSpans, LabeledSpans trueSpans, String background) { this.document = input.getDocument (); this.name = name; this.backgroundTag = dict.lookupLabel (background); this.input = input; this.extractedSpans = predictedSpans; this.targetSpans = trueSpans; }
public DocumentExtraction (String name, LabelAlphabet dict, Tokenization input, LabeledSpans predictedSpans, LabeledSpans trueSpans, String background) { this.document = input.getDocument (); this.name = name; this.backgroundTag = dict.lookupLabel (background); this.input = input; this.extractedSpans = predictedSpans; this.targetSpans = trueSpans; }
/** * gets you the LabelAlphabet representation of the tags. */ public LabelAlphabet getAlphabet() { final LabelAlphabet dict = new LabelAlphabet(); for (int i = 0; i < tags.size(); i++) { final String label = tags.get(i); dict.lookupLabel(label, true); } return dict; }
private Label labelForTok (String tok, int lvl) { while (labelDicts.size() <= lvl) { labelDicts.add (new LabelAlphabet ()); } LabelAlphabet dict = (LabelAlphabet) labelDicts.get (lvl); return dict.lookupLabel (tok); }
public Label getBestLabel () { return ((LabelAlphabet)dictionary).lookupLabel (getBestIndex()); }
BinaryTestData(int numFeatures) { LabelAlphabet labelAlphabet = new LabelAlphabet(); posLabel = labelAlphabet.lookupLabel("pos", true); negLabel = labelAlphabet.lookupLabel("neg", true); List<String> featureNames = new ArrayList<String>(); for (int i = 0; i < numFeatures; i++) { featureNames.add(Integer.toString(i)); } dataAlphabet = new Alphabet(featureNames.toArray()); iList = new InstanceList(dataAlphabet, labelAlphabet); }
private static String[] determineFieldNames (LabelAlphabet dict) { List l = new ArrayList (); for (int i = 0; i < dict.size (); i++) { String lname = dict.lookupLabel (i).toString (); if (!lname.startsWith ("B-") && !lname.startsWith ("I-")) { l.add (lname); } } return (String[]) l.toArray (new String [l.size ()]); }
private static String[] determineFieldNames (LabelAlphabet dict) { List l = new ArrayList (); for (int i = 0; i < dict.size (); i++) { String lname = dict.lookupLabel (i).toString (); if (!lname.startsWith ("B-") && !lname.startsWith ("I-")) { l.add (lname); } } return (String[]) l.toArray (new String [l.size ()]); }
public List<RerankerResult> probabilities(List<RerankExample> ex) { Classification classify = model.classify(ex); LabelVector labeling = (LabelVector) classify.getLabeling(); List<RerankerResult> result = Lists.newArrayListWithCapacity(ex.size()); for (int i = 0; i < ex.size(); i++) { Label rankLabel = labeling.getLabelAlphabet().lookupLabel(Integer.toString(i)); result.add(new RerankerResult(ex.get(i), labeling.value(rankLabel))); } Collections.sort(result, Ordering.<RerankerResult>natural().reverse()); return result; }
public Instance pipe (Instance carrier) { if (carrier.getTarget() != null) { if (carrier.getTarget() instanceof Label) throw new IllegalArgumentException ("Already a label."); LabelAlphabet ldict = (LabelAlphabet) getTargetAlphabet(); carrier.setTarget(ldict.lookupLabel (carrier.getTarget())); } return carrier; }
public Instance pipe (Instance carrier) { if (carrier.getTarget() != null) { if (carrier.getTarget() instanceof Label) throw new IllegalArgumentException ("Already a label."); LabelAlphabet ldict = (LabelAlphabet) getTargetAlphabet(); carrier.setTarget(ldict.lookupLabel (carrier.getTarget())); } return carrier; }
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 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 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