当前位置: 首页>>代码示例>>Java>>正文


Java Token.getEnd方法代码示例

本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token.getEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Token.getEnd方法的具体用法?Java Token.getEnd怎么用?Java Token.getEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token的用法示例。


在下文中一共展示了Token.getEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: argAnnotationEnds

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
/**
 * Returns true, if the argument component annotation ends at this token
 *
 * @param t    token
 * @param jCas jcas
 * @return boolean
 */
public static boolean argAnnotationEnds(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()));

    return !argumentAnnotations.isEmpty() && argumentAnnotations.get(0).getEnd() == t.getEnd();
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:25,代码来源:ArgumentPrinterUtils.java

示例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);
					}
				}
			}
		}
	}
 
开发者ID:UKPLab,项目名称:emnlp2017-cmapsum-corpus,代码行数:26,代码来源:RelationExtractorVerb.java

示例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();
        }

    }
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:27,代码来源:TcPosTaggingWrapper.java

示例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();
    }
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:21,代码来源:EachTokenAsUnitAnnotator.java

示例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());
		}
	}
}
 
开发者ID:annefried,项目名称:sitent,代码行数:22,代码来源:VerbSelectorAnnotator.java

示例6: process

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas aJCas)
	throws AnalysisEngineProcessException
{
	for (Token t : select(aJCas, Token.class)) {
		//This corresponds roughly to what is happening in MorphaAnnotator.
		String token = t.getCoveredText();
		String lemma;
		if (t.getPos() != null) {
			lemma = morphology.lemmatize(new WordTag(token, t.getPos().getPosValue()))
					.lemma();
		}
		else {
			lemma = morphology.stem(token);
		}
		if (lemma == null) {
               lemma = token;
           }
		Lemma l = new Lemma(aJCas, t.getBegin(), t.getEnd());
		l.setValue(lemma);
		l.addToIndexes();
		t.setLemma(l);
	}
}
 
开发者ID:tudarmstadt-lt,项目名称:sentiment,代码行数:25,代码来源:StanfordLemmatizer.java

示例7: 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) {
		Token head = GrammarUtils.getHeadVerb(vp, jCas, true);
		if (head == null) {
			// skip cases where head could not be identified
			continue;
		}
		if (JCasUtil.selectCovered(ClassificationAnnotation.class, head).isEmpty()) {
			ClassificationAnnotation classAnnot = new ClassificationAnnotation(jCas, head.getBegin(),
					head.getEnd());
			classAnnot.setTask("VERB");
			classAnnot.addToIndexes();
		}
	}
}
 
开发者ID:annefried,项目名称:syntSemFeatures,代码行数:18,代码来源:VerbSelectorAnnotator.java

示例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++;
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:19,代码来源:WebannoTsv3Writer.java

示例9: 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();
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:TestCasDiff.java

示例10: getCas2

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void getCas2(JCasBuilder aBuilder, JCas aJCas)
{
    Token token1 = aBuilder.add("Hallo", Token.class);
    POS pos1 = new POS(aJCas, token1.getBegin(), token1.getEnd());
    pos1.setPosValue("O");
    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();
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:TestCasDiff.java

示例11: testTokenBoundedBioLookAlike

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Test
public void testTokenBoundedBioLookAlike() 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(((n == 0) ? "B-" : "I-") + "NOTBIO!");
        ne.addToIndexes();
        n++;
    }
    
    writeAndAssertEquals(jcas, 
            WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
 
开发者ID:webanno,项目名称:webanno,代码行数:17,代码来源:WebAnnoTsv3WriterTestBase.java

示例12: 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();
            }
        }
    }
}
 
开发者ID:uhh-lt,项目名称:LT-ABSA,代码行数:37,代码来源:AspectAnnotator.java

示例13: 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();
}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:15,代码来源:PToken.java

示例14: 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();
	}
 
开发者ID:UKPLab,项目名称:emnlp2017-cmapsum-corpus,代码行数:14,代码来源:PToken.java

示例15: extract

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
public Set<Feature> extract(JCas jcas, TextClassificationTarget target)
    throws TextClassificationException
{
    super.extract(jcas, target);
    Set<Feature> features = new HashSet<Feature>();

    FrequencyDistribution<String> documentNgrams = null;

    Token token = get(jcas, target);

    if (token.getBegin() >= 0) {
        TextClassificationTarget prev = new TextClassificationTarget(jcas, token.getBegin(),
                token.getEnd());

        documentNgrams = NGramUtils.getAnnotationNgrams(jcas, prev, ngramLowerCase,
                filterPartialStopwordMatches, 1, 1, stopwords);
    }
    else {
        documentNgrams = new FrequencyDistribution<String>();
    }

    for (String topNgram : topKSet.getKeys()) {

        if (documentNgrams.getKeys().contains(topNgram)) {
            features.add(new Feature(getFeaturePrefix() + "_" + topNgram, 1));
        }
        else {
            features.add(new Feature(getFeaturePrefix() + "_" + topNgram, 0, true));
        }
    }
    return features;
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:33,代码来源:TokenContext.java


注:本文中的de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token.getEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。