本文整理匯總了Java中edu.stanford.nlp.trees.Tree.preTerminalYield方法的典型用法代碼示例。如果您正苦於以下問題:Java Tree.preTerminalYield方法的具體用法?Java Tree.preTerminalYield怎麽用?Java Tree.preTerminalYield使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.stanford.nlp.trees.Tree
的用法示例。
在下文中一共展示了Tree.preTerminalYield方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hasSuspectedImperativeParseTreeError
import edu.stanford.nlp.trees.Tree; //導入方法依賴的package包/類
/**
* Checks for suspected imperative parse tree errors. In recipes, most
* sentences are supposed to be imperatives, so if the first tag is a
* noun or an adjective, we will mark it as incorrect.
*
* @param tree Parse tree to investigate
* @return True if there is a suspected error, False otherwise
*/
private static boolean hasSuspectedImperativeParseTreeError(Tree tree) {
List<Label> preleaves = tree.preTerminalYield();
if (preleaves.get(0).value().startsWith("N") || preleaves.get(0).value().startsWith("J")
|| preleaves.get(0).value().equals("CD") || preleaves.get(0).value().startsWith("RB")) {
return true;
}
return false;
}
示例2: initialize
import edu.stanford.nlp.trees.Tree; //導入方法依賴的package包/類
@Override
public void initialize(int sourceInputId,
Sequence<IString> source) {
Tree parseTree = CoreNLPCache.get(sourceInputId).get(TreeAnnotation.class);
this.posTags = parseTree.preTerminalYield();
}
示例3: isSuspectedDeclarativeSentence
import edu.stanford.nlp.trees.Tree; //導入方法依賴的package包/類
/**
* Checks for suspected declarative sentences. In recipes, these will
* be few, but we can safely assume sentences where the first word is
* a determiner or a pronoun are declarative, as those are hard
* tags to mislabel.
*
* @param tree Parse tree to investigate
* @return True if the sentence is suspected to be declarative, False otherwise
*/
private static boolean isSuspectedDeclarativeSentence(Tree tree) {
List<Label> preleaves = tree.preTerminalYield();
if (preleaves.get(0).value().equals("DT") || preleaves.get(0).value().startsWith("PR")) {
return true;
}
return false;
}