@Override public CoreLabel makeToken(String[] keys, String[] values) { CoreLabel l = new CoreLabel(keys, values); return l; }
@Override public CoreLabel makeToken(CoreLabel labelToBeCopied) { CoreLabel l = new CoreLabel(labelToBeCopied); return l; }
/** * Default constructor; uses {@link CoreLabel} default constructor */ public IndexedWord() { label = new CoreLabel(); }
public static List<CoreLabel> toCoreLabelList(String... words) { List<CoreLabel> tokens = new ArrayList<>(words.length); for (String word : words) { CoreLabel cl = new CoreLabel(); cl.setWord(word); tokens.add(cl); } return tokens; }
public static List<CoreLabel> toCoreLabelList(List<String> words) { List<CoreLabel> tokens = new ArrayList<>(words.size()); for (String word : words) { CoreLabel cl = new CoreLabel(); cl.setWord(word); tokens.add(cl); } return tokens; }
@Override public Label newLabel(String labelStr) { CoreLabel label = new CoreLabel(); label.setValue(labelStr); return label; }
public Configuration(Configuration config) { stack = new ArrayList<>(config.stack); buffer = new ArrayList<>(config.buffer); tree = new DependencyTree(config.tree); sentence = new CoreLabel(config.sentence); }
public static List<CoreLabel> toCoreLabelList(String[] words, String[] tags) { assert tags.length == words.length; List<CoreLabel> tokens = new ArrayList<>(words.length); for (int i = 0, sz = words.length; i < sz; i++) { CoreLabel cl = new CoreLabel(); cl.setWord(words[i]); cl.setTag(tags[i]); tokens.add(cl); } return tokens; }
public static List<HasWord> toWordList(String... words) { List<HasWord> sent = new ArrayList<>(); for (String word : words) { CoreLabel cl = new CoreLabel(); cl.setValue(word); cl.setWord(word); sent.add(cl); } return sent; }
private static CoreLabel makeStartLabel(String label) { CoreLabel root = new CoreLabel(); root.set(CoreAnnotations.ValueAnnotation.class, label); root.set(CoreAnnotations.IndexAnnotation.class, 0); return root; }
@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; }
private static CoreLabel initCoreLabel(String token) { CoreLabel label = new CoreLabel(); label.set(CoreAnnotations.TextAnnotation.class, token); label.set(CoreAnnotations.ValueAnnotation.class, token); return label; }
private static CoreLabel initCoreLabel(String token, String posTag) { CoreLabel label = new CoreLabel(); label.set(CoreAnnotations.TextAnnotation.class, token); label.set(CoreAnnotations.ValueAnnotation.class, token); label.set(CoreAnnotations.PartOfSpeechAnnotation.class, posTag); return label; }
private static CoreLabel initCoreLabel(String token) { CoreLabel label = new CoreLabel(); label.setWord(token); label.setValue(token); label.set(CoreAnnotations.TextAnnotation.class, token); label.set(CoreAnnotations.ValueAnnotation.class, token); return label; }
/** Copies the CoreLabel cl with the new word part */ private static CoreLabel copyCoreLabel(CoreLabel cl, String part, int beginPosition, int endPosition) { CoreLabel newLabel = new CoreLabel(cl); newLabel.setWord(part); newLabel.setValue(part); newLabel.setBeginPosition(beginPosition); newLabel.setEndPosition(endPosition); newLabel.set(OriginalTextAnnotation.class, part); return newLabel; }
/** Copies the CoreLabel cl with the new word part */ private static CoreLabel copyCoreLabel(CoreLabel cl, String part, int beginPosition, int endPosition) { CoreLabel newLabel = new CoreLabel(cl); newLabel.setWord(part); newLabel.setValue(part); newLabel.setBeginPosition(beginPosition); newLabel.setEndPosition(endPosition); newLabel.set(OriginalTextAnnotation.class, part); return newLabel; }
private static void convertToCoreLabels(Tree tree) { Label l = tree.label(); if (! (l instanceof CoreLabel)) { CoreLabel cl = new CoreLabel(); cl.setValue(l.value()); tree.setLabel(cl); } for (Tree kid : tree.children()) { convertToCoreLabels(kid); } }
private static void convertToCoreLabels(Tree tree) { Label l = tree.label(); if (! (l instanceof CoreLabel)) { CoreLabel cl = new CoreLabel(); cl.setValue(l.value()); tree.setLabel(cl); } for (Tree kid : tree.children()) { convertToCoreLabels(kid); } }
static Tree createNode(Tree top, String label, Tree ... children) { CoreLabel headLabel = (CoreLabel) top.label(); CoreLabel production = new CoreLabel(); production.setValue(label); production.set(TreeCoreAnnotations.HeadWordLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadWordLabelAnnotation.class)); production.set(TreeCoreAnnotations.HeadTagLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadTagLabelAnnotation.class)); Tree newTop = new LabeledScoredTreeNode(production); for (Tree child : children) { newTop.addChild(child); } return newTop; }