本文整理汇总了Java中edu.stanford.nlp.ling.Sentence.add方法的典型用法代码示例。如果您正苦于以下问题:Java Sentence.add方法的具体用法?Java Sentence.add怎么用?Java Sentence.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.ling.Sentence
的用法示例。
在下文中一共展示了Sentence.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: myExtractor
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
private static Sentence<TaggedWord> myExtractor(Tree t, Sentence<TaggedWord> ty) {
Tree[] kids = t.children();
// this inlines the content of t.isPreTerminal()
if (kids.length == 1 && kids[0].isLeaf()) {
if (t.label() instanceof HasTag) {
// System.err.println("Object is: " + ((CategoryWordTag) t.label()).toString("full"));
ty.add(new TaggedWord(kids[0].label().value(), ((HasTag) t.label()).tag()));
} else {
// System.err.println("Object is: " + StringUtils.getShortClassName(t.label()) + " " + t.label());
ty.add(new TaggedWord(kids[0].label().value(), t.label().value()));
}
} else {
for (int i = 0; i < kids.length; i++) {
myExtractor(kids[i], ty);
}
}
return ty;
}
示例2: yield
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
/**
* Gets the yield of the tree. The <code>Label</code> of all leaf nodes
* is returned
* as a list ordered by the natural left to right order of the
* leaves. Null values, if any, are inserted into the list like any
* other value.
* <p><i>Implementation notes:</i> c. 2003: This has been rewritten to thread, so only one List
* is used. 2007: This method was duplicated to start to give type safety to Sentence.
* This method will now make a Word for any Leaf which does not itself implement HasWord, and
* put the Word into the Sentence, so the Sentence elements MUST implement HasWord.
*
* @param y The list in which the yield of the tree will be placed.
* Normally, this will be empty when the routine is called, but
* if not, the new yield is added to the end of the list.
* @return a <code>List</code> of the data in the tree's leaves.
*/
@SuppressWarnings("unchecked")
public <X extends HasWord> Sentence<X> yield(Sentence<X> y) {
if (isLeaf()) {
Label lab = label();
// cdm: this is new hacked in stuff in Mar 2007 so we can now have a
// well-typed version of a Sentence, whose objects MUST implement HasWord
if (lab instanceof HasWord) {
y.add((X) lab);
} else {
y.add((X) new Word(lab));
}
} else {
Tree[] kids = children();
for (int i = 0; i < kids.length; i++) {
kids[i].yield(y);
}
}
return y;
}
示例3: listToSentence
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
/**
* @param strings
* @return
*/
private Sentence<? extends HasWord> listToSentence( List<String> strings) {
Sentence<HasWord> sentence = new Sentence<HasWord>();
for (String str : strings)
sentence.add(new Word(str));
return sentence;
}
示例4: wordify
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
private static Sentence<Word> wordify(List wList) {
Sentence<Word> s = new Sentence<Word>();
for (Object obj : wList) {
s.add(new Word(obj.toString()));
}
return s;
}
示例5: addLast
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
private static Sentence<Word> addLast(Sentence<Word> s) {
Sentence<Word> s2 = new Sentence<Word>(s);
//s2.add(new StringLabel(Lexicon.BOUNDARY));
s2.add(new Word(Lexicon.BOUNDARY));
return s2;
}