@Override public void setIndex(int index) { label.setIndex(index); }
/** * Set the index for the current node. */ protected void setIndex(int index) { label.setIndex(index); }
/** * Loops back through all the datums inserted for the most recent word * and inserts statistics about the word they are a part of. This needs to * be post hoc because the CoreLabel lists coming from testing data sets * are pre-segmented (so treating each of those CoreLabels as a "word" lets * us cheat and get 100% classification accuracy by just looking at whether * we're at the beginning of a "word"). * * @param iobList * @param currentWord * @param wordStartIndex */ private static void fillInWordStatistics(List<CoreLabel> iobList, String currentWord, int wordStartIndex) { for (int j = wordStartIndex; j < iobList.size(); j++) { CoreLabel tok = iobList.get(j); tok.setIndex(j - wordStartIndex); tok.setWord(currentWord); } }
word.setWord(fields.get(CoNLLX_WordField)); word.setTag(fields.get(CoNLLX_POSField)); word.setIndex(tgWords.size() + 1); CoreLabel pos = new CoreLabel(); pos.setTag(fields.get(CoNLLX_POSField)); rootLabel.setValue("ROOT"); rootLabel.setWord("ROOT"); rootLabel.setIndex(0); IndexedWord dependencyRoot = new IndexedWord(rootLabel); for (int i = 0; i < tgWords.size(); i++) {
boundaryDatum.setIndex(0); boundaryDatum.setWord(""); addWhitespace = false;
token.setIndex(index); token.setValue(leaf.value()); token.setWord(leaf.value());
label.setIndex(i); i++;
/** * Create a mock node, to be added to the dependency tree but which is not part of the original sentence. * * @param toCopy The CoreLabel to copy from initially. * @param word The new word to add. * @param POS The new part of speech to add. * * @return A CoreLabel copying most fields from toCopy, but with a new word and POS tag (as well as a new index). */ @SuppressWarnings("UnusedDeclaration") private CoreLabel mockNode(CoreLabel toCopy, String word, String POS) { CoreLabel mock = new CoreLabel(toCopy); mock.setWord(word); mock.setLemma(word); mock.setValue(word); mock.setNER("O"); mock.setTag(POS); mock.setIndex(sentenceLength + 5); return mock; }
boundary.setValue(Lexicon.BOUNDARY); boundary.setTag(Lexicon.BOUNDARY_TAG); boundary.setIndex(sentence.size()+1);//1-based indexing used in the parser sentenceB.add(boundary); } else {
token.setIndex(index++); token.setSentIndex(sentences.size()); if (docID != null) {
private int taggedLabeledYield(List<CoreLabel> ty, int termIdx) { if (isPreTerminal()) { // usually this will fill in all the usual keys for a token CoreLabel taggedWord = new CoreLabel(firstChild().label()); // but in case this just came from reading a tree that just has a value for words if (taggedWord.word() == null) { taggedWord.setWord(firstChild().value()); } final String tag = (value() == null) ? "" : value(); // set value and tag to the tag taggedWord.setValue(tag); taggedWord.setTag(tag); taggedWord.setIndex(termIdx); ty.add(taggedWord); return termIdx + 1; } else { for (Tree kid : getChildrenAsList()) termIdx = kid.taggedLabeledYield(ty, termIdx); } return termIdx; }
if (token != null) { token.setSentIndex(sentIndex); token.setIndex(i - sentence.getTokenOffsetBegin() + 1); if (sentence.hasParagraph()) { token.set(ParagraphAnnotation.class, sentence.getParagraph());
@Override public Label newLabel(Label oldLabel) { if (oldLabel instanceof CoreLabel) { return new CoreLabel((CoreLabel)oldLabel); } else { //Map the old interfaces to the correct key/value pairs //Don't need to worry about HasIndex, which doesn't appear in any legacy code CoreLabel label = new CoreLabel(); if (oldLabel instanceof HasWord) label.setWord(((HasWord) oldLabel).word()); if (oldLabel instanceof HasTag) label.setTag(((HasTag) oldLabel).tag()); if (oldLabel instanceof HasOffset) { label.setBeginPosition(((HasOffset) oldLabel).beginPosition()); label.setEndPosition(((HasOffset) oldLabel).endPosition()); } if (oldLabel instanceof HasCategory) label.setCategory(((HasCategory) oldLabel).category()); if (oldLabel instanceof HasIndex) label.setIndex(((HasIndex) oldLabel).index()); label.setValue(oldLabel.value()); return label; } }
/** * Set the index for the current node. */ protected void setIndex(int index) { label.setIndex(index); }
/** * Set the index for the current node. */ protected void setIndex(int index) { label.setIndex(index); }
@Override public void setIndex(int index) { label.setIndex(index); }
/** * Set the index for the current node. */ protected void setIndex(int index) { label.setIndex(index); }
private static int reIndexLeaves(Tree t, int startIndex) { if (t.isLeaf()) { CoreLabel afl = (CoreLabel) t.label(); afl.setIndex(startIndex); startIndex++; } else { for (Tree child : t.children()) { startIndex = reIndexLeaves(child, startIndex); } } return startIndex; }