本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token.getBegin方法的典型用法代码示例。如果您正苦于以下问题:Java Token.getBegin方法的具体用法?Java Token.getBegin怎么用?Java Token.getBegin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token
的用法示例。
在下文中一共展示了Token.getBegin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: argAnnotationBegins
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
/**
* Returns true, if the argument component annotation begins at this token
*
* @param t token
* @param jCas jcas
* @return boolean
*/
public static ArgumentComponent argAnnotationBegins(Token t, JCas jCas)
{
List<ArgumentComponent> argumentAnnotations = new ArrayList<>();
argumentAnnotations
.addAll(JCasUtil.selectCovering(jCas, Claim.class, t.getBegin(), t.getEnd()));
argumentAnnotations
.addAll(JCasUtil.selectCovering(jCas, Backing.class, t.getBegin(), t.getEnd()));
argumentAnnotations
.addAll(JCasUtil.selectCovering(jCas, Premise.class, t.getBegin(), t.getEnd()));
argumentAnnotations
.addAll(JCasUtil.selectCovering(jCas, Rebuttal.class, t.getBegin(), t.getEnd()));
argumentAnnotations
.addAll(JCasUtil.selectCovering(jCas, Refutation.class, t.getBegin(), t.getEnd()));
if (!argumentAnnotations.isEmpty() && argumentAnnotations.get(0).getBegin() == t
.getBegin()) {
return argumentAnnotations.get(0);
}
return null;
}
示例2: findVerbs
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
private void findVerbs(JCas jcas, Sentence sentence) {
List<CC> concepts = JCasUtil.selectCovered(jcas, CC.class, sentence);
if (concepts.size() >= 2) {
for (CC c1 : concepts) {
for (CC c2 : concepts) {
if (c1 != c2 && c1.getEnd() < c2.getBegin()) {
List<PToken> tokens = new ArrayList<PToken>();
boolean hasVerb = false;
for (Token t : JCasUtil.selectCovered(Token.class, sentence)) {
if (t.getBegin() > c1.getEnd() && t.getEnd() < c2.getBegin()) {
tokens.add(this.parent.getToken(t));
if (t.getPos().getPosValue().startsWith("V"))
hasVerb = true;
}
}
if (tokens.size() > 0 && tokens.size() < 10 && hasVerb)
this.addLink(c1, c2, tokens);
}
}
}
}
}
示例3: process
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas aJCas)
throws AnalysisEngineProcessException
{
for (Sentence sent : JCasUtil.select(aJCas, Sentence.class)) {
TextClassificationSequence sequence = new TextClassificationSequence(aJCas,
sent.getBegin(), sent.getEnd());
sequence.addToIndexes();
List<Token> tokens = JCasUtil.selectCovered(aJCas, Token.class, sent);
for (Token token : tokens) {
TextClassificationTarget target = new TextClassificationTarget(aJCas, token.getBegin(),
token.getEnd());
target.setId(tcId++);
target.setSuffix(token.getCoveredText());
target.addToIndexes();
TextClassificationOutcome outcome = new TextClassificationOutcome(aJCas,
token.getBegin(), token.getEnd());
outcome.setOutcome(getTextClassificationOutcome(aJCas, target));
outcome.addToIndexes();
}
}
}
示例4: process
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas aJCas)
throws AnalysisEngineProcessException
{
List<Token> tokens = new ArrayList<Token>(JCasUtil.select(aJCas, Token.class));
for (Token token : tokens) {
TextClassificationTarget unit = new TextClassificationTarget(aJCas, token.getBegin(),
token.getEnd());
unit.setId(tcId++);
unit.setSuffix(token.getCoveredText());
unit.addToIndexes();
TextClassificationOutcome outcome = new TextClassificationOutcome(aJCas,
token.getBegin(), token.getEnd());
outcome.setOutcome("X");
outcome.addToIndexes();
}
}
示例5: process
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
Collection<VP> verbPhrases = JCasUtil.select(jCas, VP.class);
for (VP vp : verbPhrases) {
//System.out.println("\n\nVP: " + vp.getCoveredText());
Token head = GrammarUtils.getHeadVerb(vp, jCas, true);
if (head == null) {
// skip cases where head could not be identified
continue;
}
//System.out.println("head: " + head.getCoveredText());
if (JCasUtil.selectCovered(ClassificationAnnotation.class, head).isEmpty()) {
ClassificationAnnotation classAnnot = new ClassificationAnnotation(jCas, head.getBegin(),
head.getEnd());
classAnnot.setTask("VERB");
classAnnot.addToIndexes();
//System.out.println("selected verb: " + classAnnot.getCoveredText());
}
}
}
示例6: getCas1
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void getCas1(JCasBuilder aBuilder, JCas aJCas)
{
Token token1 = aBuilder.add("Hallo", Token.class);
POS pos1 = new POS(aJCas, token1.getBegin(), token1.getEnd());
pos1.setPosValue("I");
pos1.addToIndexes();
token1.setPos(pos1);
Token token2 = aBuilder.add("Welt", Token.class);
POS pos2 = new POS(aJCas, token2.getBegin(), token2.getEnd());
pos2.setPosValue("N");
pos2.addToIndexes();
token2.setPos(pos2);
Token token3 = aBuilder.add("!", Token.class);
POS pos3 = new POS(aJCas, token3.getBegin(), token3.getEnd());
pos3.setPosValue("SENT");
token3.setPos(pos3);
pos3.addToIndexes();
}
示例7: getTokenSpan
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
/**
* Returns a list of tokens starting with firstToken and ending with lastToken (incl.)
*
* @param jCas jCas
* @param firstToken first token of the span
* @param lastToken last token of the span
* @return list (never empty, contains at least one token if firstToken = lastToken)
* @throws IllegalArgumentException if last token precedes first token
* @throws NullPointerException if firstToken or lastToken are null
*/
public static List<Token> getTokenSpan(JCas jCas, Token firstToken, Token lastToken)
{
if (firstToken == null) {
throw new NullPointerException("firstToken is null");
}
if (lastToken == null) {
throw new NullPointerException("lastToken is null");
}
if (firstToken.getBegin() > lastToken.getBegin()) {
throw new IllegalArgumentException("firstToken (begin: " + firstToken.getBegin()
+ ") appears after lastToken (begin: " + lastToken.getBegin() + ")");
}
List<Token> result = new ArrayList<Token>();
for (Token t : JCasUtil.select(getInitialView(jCas), Token.class)) {
if (t.getBegin() >= firstToken.getBegin() && t.getBegin() <= lastToken.getBegin()) {
result.add(t);
}
}
return result;
}
示例8: setTokenSentenceAddress
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
private void setTokenSentenceAddress(JCas aJCas)
{
int sentNMumber = 1;
for (Sentence sentence : select(aJCas, Sentence.class)) {
int lineNumber = 1;
for (Token token : selectCovered(Token.class, sentence)) {
AnnotationUnit unit = new AnnotationUnit(token.getBegin(), token.getEnd(), false,
token.getCoveredText());
units.add(unit);
if (lineNumber == 1) {
sentenceUnits.put(unit, sentence.getCoveredText());
}
unitsLineNumber.put(unit, sentNMumber + "-" + lineNumber);
lineNumber++;
}
sentNMumber++;
}
}
示例9: testTokenBoundedStackedSpanWithFeatureValue
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Test
public void testTokenBoundedStackedSpanWithFeatureValue() throws Exception
{
JCas jcas = makeJCasOneSentence();
for (Token t : select(jcas, Token.class)) {
NamedEntity ne1 = new NamedEntity(jcas, t.getBegin(), t.getEnd());
ne1.setValue("NE");
ne1.addToIndexes();
NamedEntity ne2 = new NamedEntity(jcas, t.getBegin(), t.getEnd());
ne2.setValue("NE");
ne2.addToIndexes();
}
writeAndAssertEquals(jcas,
WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
示例10: testTokenBoundedStackedLookAlike
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Test
public void testTokenBoundedStackedLookAlike() throws Exception
{
JCas jcas = makeJCasOneSentence();
int n = 0;
for (Token t : select(jcas, Token.class)) {
NamedEntity ne = new NamedEntity(jcas, t.getBegin(), t.getEnd());
ne.setValue("NOTSTACKED[" + n + "]");
ne.addToIndexes();
n++;
}
writeAndAssertEquals(jcas,
WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
示例11: process
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
for (Sentence sentence : select(jCas, Sentence.class)) {
List<Instance<String>> instances = new ArrayList<>();
List<Token> tokens = selectCovered(jCas, Token.class, sentence);
for (Token token : tokens) {
Instance<String> instance = new Instance<>();
for (FeatureExtractor1<Token> extractor : this.featureExtractors) {
if (extractor instanceof CleartkExtractor) {
instance.addAll((((CleartkExtractor) extractor).extractWithin(jCas, token, sentence)));
}
else {
instance.addAll(extractor.extract(jCas, token));
}
}
try {
instance.setOutcome(selectCovered(jCas, GoldAspectTarget.class, token).get(0).getAspectTargetType());
} catch (IndexOutOfBoundsException e) {
//e.printStackTrace();
}
instances.add(instance);
}
if (this.isTraining()) {
this.dataWriter.write(instances);
} else {
List<String> labels = this.classify(instances);
Iterator<Token> tokensIter = tokens.iterator();
for (String label : labels) {
Token t = tokensIter.next();
AspectTarget target = new AspectTarget(jCas, t.getBegin(), t.getEnd());
target.setAspectTargetType(label);
target.addToIndexes();
}
}
}
}
示例12: hasSpaceBefore
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
/**
* Returns true if the token has a preceding whitespace in the original document
*
* @param token token
* @param jCas jcas
* @return boolen
*/
public static boolean hasSpaceBefore(Token token, JCas jCas)
{
// select previous token(s)
List<Token> prevTokens = JCasUtil.selectPreceding(jCas, Token.class, token, 1);
Paragraph paragraph = JCasUtil.selectCovering(jCas, Paragraph.class, token).iterator()
.next();
return !prevTokens.isEmpty() && (prevTokens.iterator().next().getEnd() != token.getBegin())
&& (token.getBegin() != paragraph.getBegin());
}
示例13: sentenceStartsOnToken
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
/**
* Returns a covering sentence if it starts at the token, null otherwise
*
* @param t token
* @return sentence or null
*/
public static Sentence sentenceStartsOnToken(Token t)
{
List<Sentence> sentences = JCasUtil.selectCovering(Sentence.class, t);
return (!sentences.isEmpty() && sentences.get(0).getBegin() == t.getBegin()) ?
sentences.get(0) :
null;
}
示例14: PToken
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
public PToken(Token t) {
this.text = t.getCoveredText();
this.pos = t.getPos() != null ? t.getPos().getPosValue() : null;
this.lemma = t.getLemma() != null ? t.getLemma().getValue() : null;
List<NamedEntity> nes = JCasUtil.selectCovered(NamedEntity.class, t);
if (nes.size() > 0)
this.neTag = nes.get(0).getValue();
DocumentMetaData meta = (DocumentMetaData) t.getCAS().getDocumentAnnotation();
this.documentId = meta.getDocumentId();
this.start = t.getBegin();
this.end = t.getEnd();
this.docLength = t.getCAS().getDocumentText().length();
}
示例15: PToken
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
public PToken(Token t) {
this.text = t.getCoveredText().replaceAll("\\p{C}", " ").replaceAll(" ", " ");
this.pos = t.getPos() != null ? t.getPos().getPosValue() : null;
this.stem = t.getStem() != null ? t.getStem().getValue() : null;
this.lemma = t.getLemma() != null ? t.getLemma().getValue() : null;
DocumentMetaData meta = (DocumentMetaData) t.getCAS().getDocumentAnnotation();
this.documentId = meta.getDocumentId();
this.start = t.getBegin();
this.end = t.getEnd();
this.docLength = t.getCAS().getDocumentText().length();
}