private ArrayList<TaggedWord> getTaggedSentence() { final boolean hasOffset; hasOffset = origWords != null && ! origWords.isEmpty() && (origWords.get(0) instanceof HasOffset); ArrayList<TaggedWord> taggedSentence = new ArrayList<>(); for (int j = 0; j < size - 1; j++) { String tag = finalTags[j]; TaggedWord w = new TaggedWord(sent.get(j), tag); if (hasOffset) { HasOffset offset = (HasOffset) origWords.get(j); w.setBeginPosition(offset.beginPosition()); w.setEndPosition(offset.endPosition()); } taggedSentence.add(w); } return taggedSentence; }
} else { HasOffset first = (HasOffset) sentence.get(0); boundaries.add(first.beginPosition());
/** * 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()); } }
beginOffsets[i] = word.beginPosition(); endOffsets[i] = word.endPosition(); } else {
@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; } }
Label label = firstLeaf.label(); HasOffset ofs = (HasOffset) label; int start = ofs.beginPosition();
ArrayList<TaggedWord> getTaggedSentence() { final boolean hasOffset; hasOffset = origWords != null && origWords.size() > 0 && (origWords.get(0) instanceof HasOffset); ArrayList<TaggedWord> taggedSentence = new ArrayList<TaggedWord>(); for (int j = 0; j < size - 1; j++) { String tag = finalTags[j]; TaggedWord w = new TaggedWord(sent.get(j), tag); if (hasOffset) { HasOffset offset = (HasOffset) origWords.get(j); w.setBeginPosition(offset.beginPosition()); w.setEndPosition(offset.endPosition()); } taggedSentence.add(w); } return taggedSentence; }
ArrayList<TaggedWord> getTaggedSentence() { final boolean hasOffset; hasOffset = origWords != null && origWords.size() > 0 && (origWords.get(0) instanceof HasOffset); ArrayList<TaggedWord> taggedSentence = new ArrayList<>(); for (int j = 0; j < size - 1; j++) { String tag = finalTags[j]; TaggedWord w = new TaggedWord(sent.get(j), tag); if (hasOffset) { HasOffset offset = (HasOffset) origWords.get(j); w.setBeginPosition(offset.beginPosition()); w.setEndPosition(offset.endPosition()); } taggedSentence.add(w); } return taggedSentence; }
ArrayList<TaggedWord> getTaggedSentence() { final boolean hasOffset; hasOffset = origWords != null && origWords.size() > 0 && (origWords.get(0) instanceof HasOffset); ArrayList<TaggedWord> taggedSentence = new ArrayList<>(); for (int j = 0; j < size - 1; j++) { String tag = finalTags[j]; TaggedWord w = new TaggedWord(sent.get(j), tag); if (hasOffset) { HasOffset offset = (HasOffset) origWords.get(j); w.setBeginPosition(offset.beginPosition()); w.setEndPosition(offset.endPosition()); } taggedSentence.add(w); } return taggedSentence; }
} else { HasOffset first = (HasOffset) sentence.get(0); boundaries.add(first.beginPosition());
ArrayList<TaggedWord> getTaggedSentence() { final boolean hasOffset; if (origWords != null && (origWords.get(0) instanceof HasOffset)) { hasOffset = true; } else { hasOffset = false; } ArrayList<TaggedWord> taggedSentence = new ArrayList<TaggedWord>(); for (int j = 0; j < size - 1; j++) { String tag = finalTags[j]; TaggedWord w = new TaggedWord(sent.get(j), tag); if (hasOffset) { HasOffset offset = (HasOffset) origWords.get(j); w.setBeginPosition(offset.beginPosition()); w.setEndPosition(offset.endPosition()); } taggedSentence.add(w); } return taggedSentence; }
/** * 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()); } }
/** * 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()); } }
/** * 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()); } }
/** * 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()); } }
@Override public void annotate(TokenizedString string) { Reader reader = new StringReader(string.toString()); edu.stanford.nlp.process.Tokenizer<?> tokenizer; synchronized (this) { tokenizer = this.factory.getTokenizer(reader); } while (tokenizer.hasNext()) { Object token = tokenizer.next(); if (token instanceof HasOffset) { HasOffset hasOffset = (HasOffset) token; int begin = hasOffset.beginPosition(); int end = hasOffset.endPosition(); string.setWord(begin, end); } } }
@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; } }
public Label newLabel(Label oldLabel) { if (oldLabel instanceof CoreLabel) { return new CoreLabel((CoreLabel)oldLabel); } else { //wsg 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 HasCategory)) label.setCategory(((HasCategory) oldLabel).category()); if((oldLabel instanceof HasOffset)) { label.setBeginPosition(((HasOffset) oldLabel).beginPosition()); label.setEndPosition(((HasOffset) oldLabel).endPosition()); } if((oldLabel instanceof HasCategory)) label.setCategory(((HasCategory) oldLabel).category()); label.setValue(oldLabel.value()); return label; } }
@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; } }
@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; } }