de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence.getEnd()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence.getEnd()方法的一些代码示例,展示了Sentence.getEnd()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sentence.getEnd()方法的具体详情如下:
包路径:de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence
类名称:Sentence
方法名:getEnd

Sentence.getEnd介绍

暂无

代码示例

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-io-tsv

public int getEnd()
{
  return uimaSentence.getEnd();
}

代码示例来源:origin: webanno/webanno

public int getEnd()
{
  return uimaSentence.getEnd();
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-ui-curation

/**
 * Get a sentence at the end of an annotation
 */
private static Sentence getSentenceByAnnoEnd(List<Sentence> aSentences, int aEnd)
{
  int prevEnd = 0;
  Sentence sent = null;
  for (Sentence sentence : aSentences) {
    if (prevEnd >= aEnd) {
      return sent;
    }
    sent = sentence;
    prevEnd = sent.getEnd();
  }
  return sent;
}

代码示例来源:origin: webanno/webanno

/**
 * Get a sentence at the end of an annotation
 */
private static Sentence getSentenceByAnnoEnd(List<Sentence> aSentences, int aEnd)
{
  int prevEnd = 0;
  Sentence sent = null;
  for (Sentence sentence : aSentences) {
    if (prevEnd >= aEnd) {
      return sent;
    }
    sent = sentence;
    prevEnd = sent.getEnd();
  }
  return sent;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

/**
 * Check if the start/end offsets of an annotation belongs to the same sentence.
 *
 * @return
 */
public static boolean isSameSentence(JCas aJcas, int aStartOffset, int aEndOffset)
{
  for (Sentence sentence : select(aJcas, Sentence.class)) {
    if ((sentence.getBegin() <= aStartOffset && sentence.getEnd() > aStartOffset)
        && aEndOffset <= sentence.getEnd()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-annotation

/**
 * Get the current sentence based on the annotation begin/end offset
 *
 * @param aJCas
 *            the JCas.
 * @param aBegin
 *            the begin offset.
 * @param aEnd
 *            the end offset.
 * @return the sentence.
 */
public static Sentence getCurrentSentence(JCas aJCas, int aBegin, int aEnd)
{
  Sentence currentSentence = null;
  for (Sentence sentence : select(aJCas, Sentence.class)) {
    if (sentence.getBegin() <= aBegin && sentence.getEnd() > aBegin
        && sentence.getEnd() <= aEnd) {
      currentSentence = sentence;
      break;
    }
  }
  return currentSentence;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

/**
 * Get the cureent sentence based on the anotation begin/end offset
 */
public static Sentence getCurrentSentence(JCas aJCas, int aBegin, int aEnd){
  Sentence currentSentence = null;
  for(Sentence sentence :select(aJCas, Sentence.class)){
    if(sentence.getBegin()<=aBegin && sentence.getEnd()>=aEnd){
      currentSentence = sentence;
      break;
    }
  }
  return currentSentence;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

/**
 * Get the sentence number at this specific position
 * @return
 */
public static int getSentenceNumber(JCas aJcas, int aBeginOffset)
{
  int sentenceNumber = 0;
  for (Sentence sentence : select(aJcas, Sentence.class)) {
    if (sentence.getBegin() <= aBeginOffset && aBeginOffset<=sentence.getEnd()) {
      sentenceNumber++;
      break;
    }
    sentenceNumber++;
  }
  return sentenceNumber;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-annotation

/**
 * Get the  sentence based on the annotation begin offset
 *
 * @param aJCas
 *            the JCas.
 * @param aBegin
 *            the begin offset.
 * @return the sentence.
 */
public static Sentence getSentence(JCas aJCas, int aBegin)
{
  Sentence currentSentence = null;
  for (Sentence sentence : select(aJCas, Sentence.class)) {
    if (sentence.getBegin() <= aBegin && sentence.getEnd() > aBegin) {
      currentSentence = sentence;
      break;
    }
  }
  return currentSentence;
}

代码示例来源:origin: webanno/webanno

/**
 * Get the  sentence based on the annotation begin offset
 *
 * @param aJCas
 *            the JCas.
 * @param aBegin
 *            the begin offset.
 * @return the sentence.
 */
public static Sentence getSentence(JCas aJCas, int aBegin)
{
  Sentence currentSentence = null;
  for (Sentence sentence : select(aJCas, Sentence.class)) {
    if (sentence.getBegin() <= aBegin && sentence.getEnd() > aBegin) {
      currentSentence = sentence;
      break;
    }
  }
  return currentSentence;
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.opennlp-asl

@Override
public void init(JCas aJCas)
{
  text = aJCas.getDocumentText();
  sentences = new ArrayList<>();
  for (Sentence sent : select(aJCas, Sentence.class)) {
    Span s = new Span(sent.getBegin(), sent.getEnd());
    sentences.add(s);
  }
}

代码示例来源:origin: webanno/webanno

/**
 * Check if the begin/end offsets are within the same sentence. If the end offset
 * is at the end of the sentence, it is considered to be part of the sentence.
 * Mind that annotations in UIMA are half-open intervals <code>[begin,end)</code>. If there
 * is no sentence covering the offsets, the method returns <code>false</code>.
 *
 * @param aJcas
 *            the JCAs.
 * @param aBegin
 *            the reference offset.
 * @param aEnd
 *            the comparison offset.
 * @return if the two offsets are within the same sentence.
 */
public static boolean isBeginEndInSameSentence(JCas aJcas, int aBegin, int aEnd)
{
  return selectCovering(aJcas, Sentence.class, aBegin, aBegin).stream()
      .filter(s -> s.getBegin() <= aBegin && aBegin < s.getEnd())
      .filter(s -> s.getBegin() <= aEnd && aEnd <= s.getEnd())
      .findFirst()
      .isPresent();
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-core

private List<List<String>> extractTags(JCas jCas)
{
  List<List<String>> posTags = new ArrayList<List<String>>();
  Collection<Sentence> sentences = JCasUtil.select(jCas, Sentence.class);
  for (Sentence s : sentences) {
    List<String> tags = new ArrayList<String>();
    List<TextClassificationOutcome> tcos = JCasUtil.selectCovered(jCas,
        TextClassificationOutcome.class, s.getBegin(), s.getEnd());
    for (TextClassificationOutcome tco : tcos) {
      tags.add(tco.getOutcome());
    }
    posTags.add(tags);
  }
  return posTags;
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.testing-asl

@Override
  public boolean check(JCas aCas, List<Message> aMessages)
  {
    boolean ok = true;
    for (Token t : select(aCas, Token.class)) {
      if (t.getBegin() >= t.getEnd()) {
        aMessages.add(new Message(this, ERROR, "Token with illegal span: %s", t));
        ok = false;
      }
    }

    for (Sentence s : select(aCas, Sentence.class)) {
      if (s.getBegin() >= s.getEnd()) {
        aMessages.add(new Message(this, ERROR, "Sentence with illegal span: %s", s));
        ok = false;
      }
    }
    return ok;
  }
}

代码示例来源:origin: dkpro/dkpro-core

@Override
  public boolean check(JCas aCas, List<Message> aMessages)
  {
    boolean ok = true;
    for (Token t : select(aCas, Token.class)) {
      if (t.getBegin() >= t.getEnd()) {
        aMessages.add(new Message(this, ERROR, "Token with illegal span: %s", t));
        ok = false;
      }
    }

    for (Sentence s : select(aCas, Sentence.class)) {
      if (s.getBegin() >= s.getEnd()) {
        aMessages.add(new Message(this, ERROR, "Sentence with illegal span: %s", s));
        ok = false;
      }
    }
    return ok;
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.tc/dkpro-tc-features-ngram

public static <T extends Annotation> List<String> valuesToText(JCas jcas, Sentence s,
      String annotationClassName)
    throws TextClassificationException
  {
    List<String> texts = new ArrayList<String>();

    try {
      for (Entry<AnnotationFS, String> entry : FeaturePathFactory.select(jcas.getCas(),
          annotationClassName)) {
        if (entry.getKey().getBegin() >= s.getBegin()
            && entry.getKey().getEnd() <= s.getEnd()) {
          texts.add(entry.getValue());
        }
      }
    }
    catch (FeaturePathException e) {
      throw new TextClassificationException(e);
    }
    return texts;
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

private static int getLastSentenceAddress(BratAnnotatorModel aBratAnnotatorModel, JCas jCas,
    JCas userJCas)
{
  Sentence sentence = selectByAddr(userJCas, Sentence.class,
      aBratAnnotatorModel.getLastSentenceAddress());
  List<Sentence> sentences = JCasUtil.selectCovered(jCas, Sentence.class,
      sentence.getBegin(), sentence.getEnd());
  return sentences.get(0).getAddress();
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

/**
 * Get the sentence address for jCas from userJCas.
 */
private static int getSentenceAddress(BratAnnotatorModel aBratAnnotatorModel, JCas jCas,
    JCas userJCas)
{
  int sentenceAddress = BratAjaxCasUtil.selectSentenceAt(userJCas,
      aBratAnnotatorModel.getSentenceBeginOffset(),
      aBratAnnotatorModel.getSentenceEndOffset()).getAddress();
  Sentence sentence = selectByAddr(userJCas, Sentence.class, sentenceAddress);
  List<Sentence> sentences = JCasUtil.selectCovered(jCas, Sentence.class,
      sentence.getBegin(), sentence.getEnd());
  return sentences.get(0).getAddress();
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

private void updateSentenceAddressAndOffsets(JCas jCas, int start)
{
  int address = BratAjaxCasUtil.selectSentenceAt(jCas,
      bratAnnotatorModel.getSentenceBeginOffset(),
      bratAnnotatorModel.getSentenceEndOffset()).getAddress();
  bratAnnotatorModel.setSentenceAddress(BratAjaxCasUtil.getSentenceBeginAddress(jCas,
      address, start, bratAnnotatorModel.getProject(), bratAnnotatorModel.getDocument(),
      bratAnnotatorModel.getWindowSize()));
  Sentence sentence = selectByAddr(jCas, Sentence.class,
      bratAnnotatorModel.getSentenceAddress());
  bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
  bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

private void updateSentenceAddressAndOffsets(JCas jCas, int start)
{
  int address = BratAjaxCasUtil.selectSentenceAt(jCas,
      bratAnnotatorModel.getSentenceBeginOffset(),
      bratAnnotatorModel.getSentenceEndOffset()).getAddress();
  bratAnnotatorModel.setSentenceAddress(BratAjaxCasUtil.getSentenceBeginAddress(jCas,
      address, start, bratAnnotatorModel.getProject(), bratAnnotatorModel.getDocument(),
      bratAnnotatorModel.getWindowSize()));
  Sentence sentence = selectByAddr(jCas, Sentence.class,
      bratAnnotatorModel.getSentenceAddress());
  bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
  bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());
}

相关文章