本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence.setEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Sentence.setEnd方法的具体用法?Java Sentence.setEnd怎么用?Java Sentence.setEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence
的用法示例。
在下文中一共展示了Sentence.setEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSelectImplicitComponent
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
@Test
public void testSelectImplicitComponent()
throws Exception
{
Sentence s1 = new Sentence(jCas);
s1.setBegin(this.tokenThis.getBegin());
s1.setEnd(this.tokenIs.getEnd());
s1.addToIndexes();
Sentence s = new ArrayList<Sentence>(JCasUtil.select(jCas, Sentence.class)).get(0);
// it ignore implicit (zero-length) component -- here at [0, 0], sentence starts at 0
ArgumentComponent implicitComponent = new ArgumentComponent(jCas, 0, 0);
implicitComponent.addToIndexes();
assertEquals(0, JCasUtil2.selectOverlapping(ArgumentComponent.class, s, jCas).size());
}
示例2: convertSentences
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
private void convertSentences(JCas aJCas, TextCorpus aCorpusData,
Map<String, Token> aTokens)
{
if (aCorpusData.getSentencesLayer() == null) {
// No layer to read from.
return;
}
for (int i = 0; i < aCorpusData.getSentencesLayer().size(); i++) {
eu.clarin.weblicht.wlfxb.tc.api.Token[] sentencesTokens = aCorpusData
.getSentencesLayer().getTokens(aCorpusData.getSentencesLayer().getSentence(i));
Sentence outSentence = new Sentence(aJCas);
outSentence.setBegin(aTokens.get(sentencesTokens[0].getID()).getBegin());
outSentence.setEnd(aTokens.get(sentencesTokens[sentencesTokens.length - 1].getID())
.getEnd());
outSentence.addToIndexes();
}
}
示例3: terminateSentence
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
private void terminateSentence(Sentence sentence, Token token, StringBuffer docText)
{
sentence.setEnd(token.getEnd());
sentence.addToIndexes();
logger.log(Level.FINE,
"Sentence:[" + docText.substring(sentence.getBegin(), sentence.getEnd()) + "]\t"
+ sentence.getBegin() + "\t" + sentence.getEnd());
}
示例4: createSentence
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
/**
* Add sentence layer to CAS
*/
private void createSentence(JCas aJCas, List<Integer> firstTokenInSentence,
Map<String, Token> tokensStored)
{
for (int i = 0; i < firstTokenInSentence.size(); i++) {
Sentence outSentence = new Sentence(aJCas);
// Only last sentence, and no the only sentence in the document (i!=0)
if (i == firstTokenInSentence.size() - 1 && i != 0) {
outSentence.setBegin(tokensStored.get("t_" + firstTokenInSentence.get(i)).getEnd());
outSentence.setEnd(tokensStored.get("t_" + (tokensStored.size())).getEnd());
outSentence.addToIndexes();
break;
}
if (i == firstTokenInSentence.size() - 1 && i == 0) {
outSentence.setBegin(tokensStored.get("t_" + firstTokenInSentence.get(i))
.getBegin());
outSentence.setEnd(tokensStored.get("t_" + (tokensStored.size())).getEnd());
outSentence.addToIndexes();
}
else if (i == 0) {
outSentence.setBegin(tokensStored.get("t_" + firstTokenInSentence.get(i))
.getBegin());
outSentence.setEnd(tokensStored.get("t_" + firstTokenInSentence.get(i + 1))
.getEnd());
outSentence.addToIndexes();
}
else {
outSentence.setBegin(
tokensStored.get("t_" + firstTokenInSentence.get(i)).getEnd() + 1);
outSentence
.setEnd(tokensStored.get("t_" + firstTokenInSentence.get(i + 1)).getEnd());
outSentence.addToIndexes();
}
}
}
示例5: testSelectOverlapping
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
@Test
public void testSelectOverlapping()
throws Exception
{
{
Sentence s1 = new Sentence(jCas);
s1.setBegin(this.tokenThis.getBegin());
s1.setEnd(this.tokenIs.getEnd());
s1.addToIndexes();
Sentence s2 = new Sentence(jCas);
s2.setBegin(this.tokenA.getBegin());
s2.setEnd(this.tokenDot.getEnd());
s2.addToIndexes();
}
List<Sentence> sentences = new ArrayList<Sentence>(
JCasUtil.select(jCas, Sentence.class));
assertEquals(2, sentences.size());
// annotation that covers "is" and "a" (each from different sentence)
ArgumentComponent argumentComponent = new ArgumentComponent(jCas);
argumentComponent.setBegin(tokenIs.getBegin());
argumentComponent.setEnd(this.tokenA.getEnd());
argumentComponent.addToIndexes();
Collection<ArgumentComponent> argumentComponents = JCasUtil
.select(jCas, ArgumentComponent.class);
assertEquals(1, argumentComponents.size());
ArgumentComponent component = argumentComponents.iterator().next();
List<Token> coveredTokens = JCasUtil.selectCovered(Token.class, component);
assertEquals(2, coveredTokens.size());
assertEquals(this.tokenIs.getBegin(), coveredTokens.get(0).getBegin());
assertEquals(this.tokenA.getBegin(), coveredTokens.get(1).getBegin());
Sentence sent1 = sentences.get(0);
Sentence sent2 = sentences.get(0);
// !!! selectCovered won't find the ArgumentComponent annotation, as it crosses
// the boundaries!!
assertEquals(0, JCasUtil.selectCovered(ArgumentComponent.class, sent1).size());
assertEquals(0, JCasUtil.selectCovering(ArgumentComponent.class, sent1).size());
assertEquals(0, JCasUtil.selectCovered(ArgumentComponent.class, sent2).size());
assertEquals(0, JCasUtil.selectCovering(ArgumentComponent.class, sent2).size());
// now we select overlapping -- we get the same component from both sentences
assertEquals(1, JCasUtil2.selectOverlapping(ArgumentComponent.class, sent1, jCas).size());
assertEquals(1, JCasUtil2.selectOverlapping(ArgumentComponent.class, sent2, jCas).size());
// and this is indeed the "component" that overlaps both sentences
assertEquals(component,
JCasUtil2.selectOverlapping(ArgumentComponent.class, sent1, jCas).iterator()
.next());
assertEquals(component,
JCasUtil2.selectOverlapping(ArgumentComponent.class, sent2, jCas).iterator()
.next());
}
示例6: terminateSentence
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
/**
* Creates {@link Sentence} Annotation, sets the sentence end.
* @param sentence the current {@link Sentence} annotation
* @param token the last {@link Token} in the sentence
*/
private void terminateSentence(Sentence sentence, Token token) {
sentence.setEnd(token.getEnd());
sentence.addToIndexes();
}