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


Java Token.getCoveredText方法代码示例

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


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

示例1: process

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
    TreeMatcher treeMatcher = new TreeMatcher(this.tree);
    Iterator<Token> iterator = JCasUtil.iterator(jcas, Token.class);
    Type type = CasUtil.getType(jcas.getCas(), this.annotationType);
    while (iterator.hasNext()) {
        Token token = iterator.next();
        String tokenText = token.getCoveredText();
        tokenText = this.textNormalizer.normalize(tokenText);
        treeMatcher.proceed(token.getBegin(), token.getEnd(), tokenText);
        List<TreeMatch> matches = treeMatcher.getMatches();

        for (TreeMatch match : matches) {
            for (EntryMetadata metadata : match.matchedEntries()) {
                annotate(jcas, type, match, metadata);
            }
        }
    }
}
 
开发者ID:tokenmill,项目名称:dictionary-annotator,代码行数:20,代码来源:DictionaryAnnotator.java

示例2: 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

示例3: 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

示例4: 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

示例5: process

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {

	// we create indices with figure names, figure reference strings and
	// pronouns
	Map<String, Figure> figureMap = new HashMap<String, Figure>();
	for (Figure figure : JCasUtil.select(jcas, Figure.class)) {
		figureMap.put(figure.getCoveredText(), figure);
		figureMap.put(figure.getReference(), figure);
	}
	List<String> pronouns = firstPersonPronouns.get(jcas.getDocumentLanguage());
	if (pronouns == null) {
		pronouns = new LinkedList<String>();
	}

	for (Utterance utterance : JCasUtil.select(jcas, Utterance.class)) {
		Collection<Figure> figures = DramaUtil.getFigures(utterance);
		for (Figure currentFigure : figures) {
			for (Speech speech : JCasUtil.selectCovered(jcas, Speech.class, utterance)) {
				for (Token token : JCasUtil.selectCovered(Token.class, speech)) {
					String surface = token.getCoveredText();
					if (figureMap.containsKey(surface)) {
						FigureMention fm = AnnotationFactory.createAnnotation(jcas, token.getBegin(),
								token.getEnd(), FigureMention.class);
						fm.setFigure(figureMap.get(surface));
					}
				}
				if (figures.size() <= 1)
					for (PR pronoun : JCasUtil.selectCovered(jcas, PR.class, speech)) {
						if (pronouns.contains(pronoun.getCoveredText())) {
							AnnotationFactory.createAnnotation(jcas, pronoun.getBegin(), pronoun.getEnd(),
									FigureMention.class).setFigure(currentFigure);
						}
					}
			}
		}
	}

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:40,代码来源:FigureMentionDetection.java

示例6: process

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
@Override
public void process(JCas jCas)
        throws AnalysisEngineProcessException
{
    for (Token token : JCasUtil.select(jCas, Token.class)) {
        List<ArgumentComponent> covering = ArgumentUtils.removeAppealToEmotion(JCasUtil
                .selectCovering(ArgumentComponent.class, token));

        BIOTokenArgumentAnnotation sequenceLabel = new BIOTokenArgumentAnnotation(jCas);

        if (covering.isEmpty()) {
            sequenceLabel.setTag(O_TAG);
        }
        else if (covering.size() == 1) {
            ArgumentComponent argumentComponent = covering.iterator().next();

            String label = getLabel(argumentComponent, token);

            sequenceLabel.setTag(label);
        }
        else {
            String message = "More than one annotation found for particular word!" + token
                    .getCoveredText() + ", " + covering;
            if (this.lenient) {
                getLogger().warn(message);
            }
            else {
                throw new AnalysisEngineProcessException(new IllegalArgumentException(message));
            }
        }

        sequenceLabel.setBegin(token.getBegin());
        sequenceLabel.setEnd(token.getEnd());
        sequenceLabel.addToIndexes();
    }
}
 
开发者ID:dkpro,项目名称:dkpro-argumentation,代码行数:37,代码来源:ArgumentTokenBIOAnnotator.java

示例7: getMiraLine

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; //导入方法依赖的package包/类
private static StringBuffer getMiraLine(Sentence sentence, AnnotationFeature aLayerFeature,
        AutomationTypeAdapter aAdapter)
    throws CASException
{
    StringBuffer sb = new StringBuffer();

    String tag = "";
    List<String> annotations = new ArrayList<>();
    Map<Integer, String> multAnno = null;
    if (aLayerFeature != null) {
        if (aLayerFeature.getLayer().isMultipleTokens()) {
            multAnno = ((SpanAdapter) aAdapter).getMultipleAnnotation(sentence, aLayerFeature);
        }
        else {
            annotations = aAdapter.getAnnotation(sentence, aLayerFeature);
        }

    }

    int i = 0;
    for (Token token : selectCovered(Token.class, sentence)) {
        String word = token.getCoveredText();

        char[] words = word.toCharArray();

        String prefix1 = "", prefix2 = "", prefix3 = "", prefix4 = "", suffix1 = "", suffix2 = "", suffix3 = "", suffix4 = "";
        if (aLayerFeature == null || aLayerFeature.getLayer().isLockToTokenOffset()) {
            prefix1 = Character.toString(words[0]) + " ";
            prefix2 = (words.length > 1 ? prefix1.trim()
                    + (Character.toString(words[1]).trim().equals("") ? "__nil__" : Character
                            .toString(words[1])) : "__nil__")
                    + " ";
            prefix3 = (words.length > 2 ? prefix2.trim()
                    + (Character.toString(words[2]).trim().equals("") ? "__nil__" : Character
                            .toString(words[2])) : "__nil__")
                    + " ";
            prefix4 = (words.length > 3 ? prefix3.trim()
                    + (Character.toString(words[3]).trim().equals("") ? "__nil__" : Character
                            .toString(words[3])) : "__nil__")
                    + " ";
            suffix1 = Character.toString(words[words.length - 1]) + " ";
            suffix2 = (words.length > 1 ? (Character.toString(words[words.length - 2]).trim()
                    .equals("") ? "__nil__" : Character.toString(words[words.length - 2]))
                    + suffix1.trim() : "__nil__")
                    + " ";
            suffix3 = (words.length > 2 ? (Character.toString(words[words.length - 3]).trim()
                    .equals("") ? "__nil__" : Character.toString(words[words.length - 3]))
                    + suffix2.trim() : "__nil__")
                    + " ";
            suffix4 = (words.length > 3 ? (Character.toString(words[words.length - 4]).trim()
                    .equals("") ? "__nil__" : Character.toString(words[words.length - 4]))
                    + suffix3.trim() : "__nil__")
                    + " ";
        }
        String nl = "\n";

        if (aLayerFeature != null) {
            if (aLayerFeature.getLayer().isMultipleTokens()) {
                tag = multAnno.get(getAddr(token)) == null ? "O" : multAnno.get(getAddr(token));
            }
            else {
                tag = annotations.size() == 0 ? NILL : annotations.get(i);
                i++;
            }

        }
        sb.append(word).append(" ").append(prefix1).append(prefix2).append(prefix3)
            .append(prefix4).append(suffix1).append(suffix2).append(suffix3).append(suffix4)
            .append(tag).append(nl);
    }
    return sb;

}
 
开发者ID:webanno,项目名称:webanno,代码行数:74,代码来源:AutomationUtil.java


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