Exemplo n.º 1
0
 /** Create a new link annotation. Already adds the chain to the CAS. */
 private AnnotationFS newLink(
     JCas aJCas, int aBegin, int aEnd, AnnotationFeature aFeature, String aLabelValue) {
   String baseName = StringUtils.substringBeforeLast(getAnnotationTypeName(), CHAIN) + LINK;
   Type linkType = CasUtil.getType(aJCas.getCas(), baseName);
   AnnotationFS newLink = aJCas.getCas().createAnnotation(linkType, aBegin, aEnd);
   BratAjaxCasUtil.setFeature(newLink, aFeature, aLabelValue);
   aJCas.getCas().addFsToIndexes(newLink);
   return newLink;
 }
  /**
   * Generate one or multiple TokenSequences from the given document. If {@code
   * PARAM_MODEL_ENTITY_TYPE} is set, an instance is generated from each segment annotated with the
   * given type. Otherwise, one instance is generated from the whole document.
   *
   * @param aJCas
   * @return
   * @throws FeaturePathException
   */
  protected Collection<TokenSequence> generateTokenSequences(JCas aJCas)
      throws FeaturePathException {
    Collection<TokenSequence> tokenSequences;
    CAS cas = aJCas.getCas();
    Type tokenType = CasUtil.getType(cas, typeName);

    if (modelEntityType == null) {
      /* generate only one tokenSequence */
      tokenSequences = new ArrayList<>(1);
      tokenSequences.add(generateTokenSequence(aJCas, tokenType, useLemma, minTokenLength));
    } else {
      /* generate tokenSequences for every segment (e.g. sentence) */
      tokenSequences = new ArrayList<>();
      for (AnnotationFS segment : CasUtil.select(cas, CasUtil.getType(cas, modelEntityType))) {
        tokenSequences.add(generateTokenSequence(segment, tokenType));
      }
    }

    return tokenSequences;
  }
Exemplo n.º 3
0
 @Override
 public Type getAnnotationType(CAS cas) {
   return CasUtil.getType(cas, annotationTypeName);
 }