本文整理汇总了Java中opennlp.tools.parser.AbstractBottomUpParser.INC_NODE属性的典型用法代码示例。如果您正苦于以下问题:Java AbstractBottomUpParser.INC_NODE属性的具体用法?Java AbstractBottomUpParser.INC_NODE怎么用?Java AbstractBottomUpParser.INC_NODE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类opennlp.tools.parser.AbstractBottomUpParser
的用法示例。
在下文中一共展示了AbstractBottomUpParser.INC_NODE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSentence
private Parse parseSentence(final Sentence sentence, final Collection<WordToken> tokens) {
final String text = sentence.getCoveredText();
final Parse parse = new Parse(text, new Span(0, text.length()), AbstractBottomUpParser.INC_NODE, 1, 0);
// Add in the POS
int index = 0;
for (final WordToken token : tokens) {
final Span span = new Span(token.getBegin() - sentence.getBegin(), token.getEnd() - sentence.getBegin());
parse.insert(new Parse(text, span, AbstractBottomUpParser.TOK_NODE, 0, index));
index++;
}
// Parse the sentence
return parser.parse(parse);
}
示例2: parseSentence
/**
* Parses the sentence.
*
* @param sentence
* the sentence
* @param tokens
* the tokens
* @return the parses the
*/
private Parse parseSentence(final Sentence sentence, final Collection<WordToken> tokens) {
final String text = sentence.getCoveredText();
final Parse parse = new Parse(text, new Span(0, text.length()), AbstractBottomUpParser.INC_NODE, 1, 0);
// Add in the POS
int index = 0;
for (final WordToken token : tokens) {
final Span span = new Span(token.getBegin() - sentence.getBegin(), token.getEnd() - sentence.getBegin());
parse.insert(new Parse(text, span, AbstractBottomUpParser.TOK_NODE, 0, index));
index++;
}
// Parse the sentence
return parser.parse(parse);
}
示例3: process
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
String text = jCas.getDocumentText();
List<SENTENCE_TYPE> sentenceList = inputTypesHelper.getSentences(jCas);
for (SENTENCE_TYPE sentence : sentenceList) {
Parse parse = new Parse(
text,
new Span(sentence.getBegin(), sentence.getEnd()),
AbstractBottomUpParser.INC_NODE,
1,
null);
List<TOKEN_TYPE> tokenList = inputTypesHelper.getTokens(jCas, sentence);
for (TOKEN_TYPE token : tokenList) {
parse.insert(new Parse(
text,
new Span(token.getBegin(), token.getEnd()),
AbstractBottomUpParser.TOK_NODE,
0,
0));
}
if (useTagsFromCas) {
this.casTagger.setTokens(tokenList);
}
parse = this.parser.parse(parse);
// if the sentence was successfully parsed, add the tree to the
// sentence
if (parse.getType() == AbstractBottomUpParser.TOP_NODE) {
outputTypesHelper.addParse(jCas, parse, sentence, tokenList);
}
// add the POS tags to the tokens
if (!useTagsFromCas) {
setPOSTags(parse, tokenList.iterator(), jCas);
}
}
}