public void testCoreLabelListToString() { List<CoreLabel> clWords = new ArrayList<>(); List<CoreLabel> clValues = new ArrayList<>(); List<CoreLabel> clWordTags = new ArrayList<>(); List<CoreLabel> clValueTags = new ArrayList<>(); for (int i = 0; i < words.length; ++i) { CoreLabel cl = new CoreLabel(); cl.setWord(words[i]); clWords.add(cl); cl = new CoreLabel(); cl.setValue(words[i]); clValues.add(cl); cl = new CoreLabel(); cl.setWord(words[i]); cl.setTag(tags[i]); clWordTags.add(cl); cl = new CoreLabel(); cl.setValue(words[i]); cl.setTag(tags[i]); clValueTags.add(cl); } assertEquals(expectedValueOnly, SentenceUtils.listToString(clWords, true)); assertEquals(expectedValueOnly, SentenceUtils.listToString(clValues, true)); assertEquals(expectedTagged, SentenceUtils.listToString(clWordTags, false, separator)); assertEquals(expectedTagged, SentenceUtils.listToString(clValueTags, false, separator)); }
/** * 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; }
@Override public void setTag(String tag) { label.setTag(tag); }