/** * Make a new label with this <code>String</code> as the "name". * * @param labelStr A string that determines the content of the label. * For a StringLabel, it is exactly the given string * @return The created label */ public Label newLabel(String labelStr) { return new StringLabel(labelStr); }
/** * Create a new <code>StringLabel</code> with the given content. * * @param str The new label's content * @param beginPosition Start offset in original text * @param endPosition End offset in original text */ public StringLabel(String str, int beginPosition, int endPosition) { this.str = str; setBeginPosition(beginPosition); setEndPosition(endPosition); }
for (HasWord aGoldSentence : goldSentence) { StringLabel word = (StringLabel) aGoldSentence; goldCharBuf.append(word.value());
/** * Creates annotation with Penn Treebank style representations of the syntax tree * * @param aBegin * start offset. * @param aEnd * end offset. */ public void createPennTreeAnnotation(int aBegin, int aEnd) { Tree t = tokenTree.getTree(); // write Penn Treebank-style string to cas PennTree pTree = new PennTree(jCas, aBegin, aEnd); // create tree with simple labels and get penn string from it t = t.deepCopy(t.treeFactory(), StringLabel.factory()); pTree.setPennTree(t.pennString()); pTree.addToIndexes(); }
for (Iterator wordIter = goldSentence.iterator(); wordIter.hasNext();) { StringLabel word = (StringLabel) wordIter.next(); goldCharBuf.append(word.value());
/** * Create a <code>LabeledConstituent</code> object with given values. * * @param start Start node of edge * @param end End node of edge * @param stringValue The name of the <code>Constituent</code> */ public LabeledConstituent(int start, int end, String stringValue) { super(start, end); this.label = new StringLabel(stringValue); }
/** * Create a new <code>StringLabel</code> with the * <code>value()</code> of another label as its label. * * @param label The other label */ public StringLabel(Label label) { this.str = label.value(); if (label instanceof HasOffset) { HasOffset ofs = (HasOffset) label; setBeginPosition(ofs.beginPosition()); setEndPosition(ofs.endPosition()); } }
/** * Make a new label with this <code>String</code> as the "name". * * @param labelStr A string that determines the content of the label. * For a StringLabel, it is exactly the given string * @param options The options are ignored by a StringLabelFactory * @return The created label */ public Label newLabel(String labelStr, int options) { return new StringLabel(labelStr); }
/** * Create a new <code>StringLabel</code> with the given content. * * @param str The new label's content * @param beginPosition Start offset in original text * @param endPosition End offset in original text */ public StringLabel(String str, int beginPosition, int endPosition) { this.str = str; setBeginPosition(beginPosition); setEndPosition(endPosition); }
/** * Create a new <code>StringLabel</code>, where the label is * formed from * the <code>Label</code> object passed in. Depending on what fields * each label has, other things will be <code>null</code>. * * @param oldLabel The Label that the new label is being created from * @return a new label of a particular type */ public Label newLabel(Label oldLabel) { return new StringLabel(oldLabel); }
/** * Create a new <code>StringLabel</code> with the given content. * * @param str The new label's content * @param beginPosition Start offset in original text * @param endPosition End offset in original text */ public StringLabel(String str, int beginPosition, int endPosition) { this.str = str; setBeginPosition(beginPosition); setEndPosition(endPosition); }
@Override public void setFromString(String labelStr) { this.label = new StringLabel(labelStr); }
/** * Create a new <code>StringLabel</code> with the given content. * * @param str The new label's content * @param beginPosition Start offset in original text * @param endPosition End offset in original text */ public StringLabel(String str, int beginPosition, int endPosition) { this.str = str; setBeginPosition(beginPosition); setEndPosition(endPosition); }
/** * Make a new label with this <code>String</code> as the "name". * This version does no decoding -- StringLabels just have a value. * * @param labelStr A string that determines the content of the label. * For a StringLabel, it is exactly the given string * @return The created label */ public Label newLabelFromString(String labelStr) { return new StringLabel(labelStr); }
/** * Create a new <code>StringLabel</code> with the given content. * * @param str The new label's content * @param beginPosition Start offset in original text * @param endPosition End offset in original text */ public StringLabel(String str, int beginPosition, int endPosition) { this.str = str; setBeginPosition(beginPosition); setEndPosition(endPosition); }
/** * Make a new <code>LabeledScoredConstituent</code>. * * @param labelStr A string * @return The created label */ public Label newLabel(final String labelStr) { return new LabeledScoredConstituent(0, 0, new StringLabel(labelStr), 0.0); }
/** * Create a new <code>StringLabel</code> with the * <code>value()</code> of another label as its label. * * @param label The other label */ public StringLabel(Label label) { this.str = label.value(); if (label instanceof HasOffset) { HasOffset ofs = (HasOffset) label; setBeginPosition(ofs.beginPosition()); setEndPosition(ofs.endPosition()); } }
/** * Make a new <code>LabeledConstituent</code>. * * @param labelStr A string. * @return The created label */ public Label newLabel(final String labelStr) { return new LabeledConstituent(0, 0, new StringLabel(labelStr)); }
/** * Create a new <code>StringLabel</code> with the * <code>value()</code> of another label as its label. * * @param label The other label */ public StringLabel(Label label) { this.str = label.value(); if (label instanceof HasOffset) { HasOffset ofs = (HasOffset) label; setBeginPosition(ofs.beginPosition()); setEndPosition(ofs.endPosition()); } }
/** Turns a sentence into a flat phrasal tree. * The structure is S -> tag*. And then each tag goes to a word. * The tag is either found from the label or made "WD". * The tag and phrasal node have a StringLabel. * * @param s The Sentence to make the Tree from * @param lf The LabelFactory with which to create the new Tree labels * @return The one phrasal level Tree */ public static Tree toFlatTree(List<? extends HasWord> s, LabelFactory lf) { List<Tree> daughters = new ArrayList<>(s.size()); for (HasWord word : s) { Tree wordNode = new LabeledScoredTreeNode(lf.newLabel(word.word())); if (word instanceof TaggedWord) { TaggedWord taggedWord = (TaggedWord) word; wordNode = new LabeledScoredTreeNode(new StringLabel(taggedWord.tag()), Collections.singletonList(wordNode)); } else { wordNode = new LabeledScoredTreeNode(lf.newLabel("WD"), Collections.singletonList(wordNode)); } daughters.add(wordNode); } return new LabeledScoredTreeNode(new StringLabel("S"), daughters); }