@Override public Label newLabel(String labelStr) { CoreLabel coreLabel = new CoreLabel(); coreLabel.setValue(labelStr); return new IndexedWord(coreLabel); }
private IndexedWord makeCopy(int count) { CoreLabel labelCopy = new CoreLabel(label); IndexedWord copy = new IndexedWord(labelCopy); copy.setCopyCount(count); return copy; }
/** * Create a new <code>TaggedWord</code>. * * @param oldLabel A Label. If it implements the HasWord and/or * HasTag interface, then the corresponding value will be set */ public TaggedWord(Label oldLabel) { super(oldLabel.value()); if (oldLabel instanceof HasTag) { this.tag = ((HasTag) oldLabel).tag(); } }
/** * 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()); } }
/** * Helper method to set the TokenBeginAnnotation and TokenEndAnnotation of every token. */ private static void setTokenBeginTokenEnd(List<CoreLabel> tokensList) { int tokenIndex = 0; for (CoreLabel token : tokensList) { token.set(CoreAnnotations.TokenBeginAnnotation.class, tokenIndex); token.set(CoreAnnotations.TokenEndAnnotation.class, tokenIndex+1); tokenIndex++; } }
/** * Do nothing other than decorate the label with @ */ private static Label makeSimpleSyntheticLabel(Tree t) { String topCat = t.label().value(); String labelStr = '@' + topCat; String word = ((HasWord) t.label()).word(); String tag = ((HasTag) t.label()).tag(); return new CategoryWordTag(labelStr, word, tag); }
private static Label headMark(Label l) { Label l1 = l.labelFactory().newLabel(l); l1.setValue(l1.value() + headMark); return l1; }
public static void updateOffsets(List<Word> tokens, int offset) { for(Word l: tokens) { l.setBeginPosition(l.beginPosition() + offset); l.setEndPosition(l.endPosition() + offset); } }
public static <L,L2,F> Datum<L2,F> mapDatum(Datum<L,F> d, Map<L,L2> labelMapping, L2 defaultLabel) { // TODO: How to copy datum? L2 newLabel = labelMapping.get(d.label()); if (newLabel == null) { newLabel = defaultLabel; } if (d instanceof RVFDatum) { return new RVFDatum<>(((RVFDatum<L, F>) d).asFeaturesCounter(), newLabel); } else { return new BasicDatum<>(d.asFeatures(), newLabel); } }
@Override public CoreLabel makeToken(String[] keys, String[] values) { CoreLabel l = new CoreLabel(keys, values); return l; }
/** Allows choices of how to format Label. * * @param format An instance of the OutputFormat enum (the same as for a CoreLabel) * @return A String representation of the label, including marking copy nodes with primes (') */ public String toString(CoreLabel.OutputFormat format) { return label.toString(format) + toPrimes(); }
/** * Inits a new BasicDocument by reading in the text from the given Reader. * * @see #init(String,String,boolean) */ public static <L> BasicDocument<L> init(Reader textReader, String title, boolean keepOriginalText) throws IOException { return init(DocumentReader.readText(textReader), title, keepOriginalText); }
/** * Create a new <code>TaggedWord Label</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 TaggedWord(oldLabel); }
/** * Returns a String representation of this BasicDatum (lists features and * labels). */ @Override public String toString() { return "RVFDatum[id="+id+", features=" + asFeaturesCounter() + ",label=" + label() + "]"; }
/** * 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); }
/** * Return a default sentence for the language (for testing) */ @Override public ArrayList<Word> defaultTestSentence() { return SentenceUtils.toUntaggedList("\u951f\u65a4\u62f7", "\u951f\u65a4\u62f7", "\u5b66\u6821", "\u951f\u65a4\u62f7", "\u5b66\u4e60", "\u951f\u65a4\u62f7"); }
/** * 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); }