本文整理汇总了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();
}
示例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: 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);
}
}
示例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();
}
}
}
示例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: 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();
}
示例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();
}
示例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));
}
示例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();
}
}
}
}
示例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();
}
示例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();
}
示例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;
}