Save a text annotation from input
420693
function saveText() {
  if (input.value.trim().length > 0) {
    let clientX = parseInt(input.style.left, 10);
    let clientY = parseInt(input.style.top, 10);
    let svg = findSVGAtPoint(clientX, clientY);
    if (!svg) {
      return;
    }

    let { documentId, pageNumber } = getMetadata(svg);
    let rect = svg.getBoundingClientRect();
    let annotation = Object.assign({
        type: 'textbox',
        size: _textSize,
        color: _textColor,
        content: input.value.trim()
      }, scaleDown(svg, {
        x: clientX - rect.left,
        y: clientY -  rect.top,
        width: input.offsetWidth,
        height: input.offsetHeight
      })
    );

    PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
      .then((annotation) => {
        appendChild(svg, annotation);
      });
  }
  
  closeInput();
}
237262
private static String annotatateContent(JCas jcas, Object contentObj,
            int start) {
        LOG.trace("annotate: " + reflectionToString(contentObj));

        int end = start;
        StringBuilder internalSb = new StringBuilder();

        if (contentObj instanceof String) {
            String c = (String) contentObj;
            internalSb.append(c);
            end += c.length();

        } else if (contentObj instanceof Cons) {
            Cons cons = (Cons) contentObj;

            for (Object o : cons.getContent()) {
                String parse = annotatateContent(jcas, o, end);
                end += parse.length();
                internalSb.append(parse);
            }

            BioEntityMention entity = new BioEntityMention(jcas, start, end);
            entity.setSpecificType(cons.getSem());
            entity.setComponentId(GeniaCorpusCollectionReader.COMPONENT_ID);
            entity.setTextualRepresentation(cons.getLex());
            entity.addToIndexes();
        }

        return internalSb.toString();
    }
1000523
private String getAnnotations(String id, long component)
  {
    String result = "";
    String incoming = "", outgoing = "";
    int nri = 1, nro = 1;

    if(referentOfToken.get(id) != null)
    {
      for (long l : referentOfToken.get(id).keySet())
      {
        if (referentList.get((int) l) != null && referentList.get((int) l).component == component
          && referentList.get((int) l).annotations != null && referentList.get((int) l).annotations.size() > 0)
        {
          int num = referentOfToken.get(id).get(l);
          if (num == 0 || num == 2)
          {
            for (SerializableAnnotation an : referentList.get((int) l).annotations)
            {
              if (nri == 1)
              {
                incoming = ", &lt;b&gt;incoming Annotations&lt;/b&gt;: " + an.getName() + "=" + an.getValue();
                nri--;
              }
              else
              {
                incoming += ", " + an.getName() + "=" + an.getValue();
              }
            }
          }
          if (num == 1 || num == 2)
          {
            for (SerializableAnnotation an : referentList.get((int) (long) l).annotations)
            {
              if (nro == 1)
              {
                outgoing = ", &lt;b&gt;outgoing Annotations&lt;/b&gt;: " + an.getName() + "=" + an.getValue();
                nro--; // remove l+"- "+
              }
              else
              {
                outgoing += ", " + an.getName() + "=" + an.getValue();
              }
            }
          }
        }
      }
    }
    if (nro < 1)
    {
      result += outgoing;
    }
    if (nri < 1)
    {
      result += incoming;
    }
    return result;
  }
684972
def encode_annotation(obj):
    """"""
    warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_annotation",
                  DeprecationWarning)
    return bioc.biocxml.encoder.encode_annotation(obj)
342078
public static void annotateChunkText(CoreMap chunk, Class tokenTextKey)
  {
    List<CoreLabel> chunkTokens = chunk.get(CoreAnnotations.TokensAnnotation.class);
    String text = getTokenText(chunkTokens, tokenTextKey);
    chunk.set(CoreAnnotations.TextAnnotation.class, text);
  }
1337743
def handle_annotation_list(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        
        annotation = tokens['name']
        self.raise_for_redefined_annotation(line, position, annotation)
        self.annotation_to_local[annotation] = set(tokens['values'])
        return tokens
905073
void annotation( AnnotatedDescrBuilder<?> adb ) {
        AnnotationDescrBuilder<?> annotation = null;

        try {
            if (speculateFullAnnotation()) {
                boolean buildState = exprParser.isBuildDescr();
                exprParser.setBuildDescr(true);
                exprParser.fullAnnotation(adb);
                exprParser.setBuildDescr(buildState);
            } else {

                // '@'
                Token at = match(input,
                        DRL6Lexer.AT,
                        null,
                        null,
                        DroolsEditorType.SYMBOL);
                if (state.failed)
                    return;

                // identifier
                String fqn = qualifiedIdentifier();
                if (state.failed)
                    return;

                if (state.backtracking == 0) {
                    annotation = adb.newAnnotation(fqn);
                    helper.setStart(annotation,
                            at);
                }

                try {
                    if (input.LA(1) == DRL6Lexer.LEFT_PAREN) {
                        String value = chunk(DRL6Lexer.LEFT_PAREN,
                                DRL6Lexer.RIGHT_PAREN,
                                -1).trim();
                        if (state.failed)
                            return;
                        if (state.backtracking == 0) {
                            annotation.value(value);
                        }
                    }
                } finally {
                    if (state.backtracking == 0) {
                        helper.setEnd(annotation);
                    }
                }
            }

        } catch (RecognitionException re) {
            reportError(re);
        }
    }
1014972
def parse_annotation(obj: dict) -> BioCAnnotation:
    """"""
    ann = BioCAnnotation()
    ann.id = obj['id']
    ann.infons = obj['infons']
    ann.text = obj['text']
    for loc in obj['locations']:
        ann.add_location(BioCLocation(loc['offset'], loc['length']))
    return ann
933959
def setInputFormatText( self, text ):
        
        try:
            self._inputFormat = XLineEdit.InputFormat[nativestring(text)]
        except KeyError:
            pass
1087342
function expandAnnotation (tx, anno, sel) {
  if (!sel || !sel._isSelection) throw new Error('Argument "selection" is required.')
  if (!anno || !anno.isAnnotation()) throw new Error('Argument "anno" is required and must be an annotation.')
  let annoSel = anno.getSelection()
  let newAnnoSel = annoSel.expand(sel)
  anno._updateRange(tx, newAnnoSel)
  return anno
}
1133243
def get_annotation(self, key, result_format='list'):
        
        value = self.get('_annotations_by_key', {}).get(key)
        if not value:
            return value

        if result_format == 'one':
            return value[0]

        return value
1038199
function truncateAnnotation (tx, anno, sel) {
  if (!sel || !sel._isSelection) throw new Error('Argument "selection" is required.')
  if (!anno || !anno.isAnnotation()) throw new Error('Argument "anno" is required and must be an annotation.')
  let annoSel = anno.getSelection()
  let newAnnoSel = annoSel.truncateWith(sel)
  anno._updateRange(tx, newAnnoSel)
  return anno
}
363267
def _stream_annotation(file_name, pb_dir):
    
    # Full url of annotation file
    url = posixpath.join(config.db_index_url, pb_dir, file_name)

    # Get the content
    response = requests.get(url)
    # Raise HTTPError if invalid url
    response.raise_for_status()

    # Convert to numpy array
    ann_data = np.fromstring(response.content, dtype=np.dtype('<u1'))

    return ann_data
572842
function(input) {
  this.doc = makeBlock('Document', 1, 1);
  this.tip = this.doc;
  this.refmap = {};
  var lines = input.replace(/\n$/,'').split(/\r\n|\n|\r/);
  var len = lines.length;
  for (var i = 0; i < len; i++) {
    this.incorporateLine(lines[i], i+1);
  }
  while (this.tip) {
    this.finalize(this.tip, len - 1);
  }
  this.processInlines(this.doc);
  return this.doc;
}
1242654
def annotate(self, sent):
    
    preds = []
    words = []
    for word, fv in self.sent2examples(sent):
      probs = self.predictor(fv)
      tags = probs.argsort()
      tag = self.ID_TAG[tags[-1]]

      words.append(word)
      preds.append(tag)

    # fix_chunks(preds)
    annotations = zip(words, preds)
    return annotations
601211
private void loadAnnotateParameters() {
    annotateParser.addArgument("-m", "--model").required(true)
        .help("Pass the model to do the tagging as a parameter.\n");
    annotateParser.addArgument("--clearFeatures").required(false)
        .choices("yes", "no", "docstart").setDefault(Flags.DEFAULT_FEATURE_FLAG)
        .help(
            "Reset the adaptive features every sentence; defaults to 'no'; if -DOCSTART- marks"
                + " are present, choose 'docstart'.\n");
    annotateParser.addArgument("-l", "--language").required(false)
        .choices("ca", "de", "en", "es", "eu", "fr", "gl", "it", "nl", "pt",
            "ru")
        .help(
            "Choose language; it defaults to the language value in incoming NAF file.\n");
    annotateParser.addArgument("-o", "--outputFormat").required(false)
        .choices("conll03", "conll02", "naf", "opennlp")
        .setDefault(Flags.DEFAULT_OUTPUT_FORMAT)
        .help("Choose output format; it defaults to NAF.\n");
    annotateParser.addArgument("--lexer").choices("numeric")
        .setDefault(Flags.DEFAULT_LEXER).required(false)
        .help("Use lexer rules for NERC tagging; it defaults to false.\n");
    annotateParser.addArgument("--dictTag").required(false)
        .choices("tag", "post").setDefault(Flags.DEFAULT_DICT_OPTION).help(
            "Choose to directly tag entities by dictionary look-up; if the 'tag' option is chosen, "
                + "only tags entities found in the dictionary; if 'post' option is chosen, it will "
                + "post-process the results of the statistical model.\n");
    annotateParser.addArgument("--dictPath").required(false)
        .setDefault(Flags.DEFAULT_DICT_PATH).help(
            "Provide the path to the dictionaries for direct dictionary tagging; it ONLY WORKS if --dictTag "
                + "option is activated.\n");
  }
1251331
private boolean appendText(final String indent, final Element element, final StringBuilder sb) {
        if (sb != null) {
            if (element.getTagName().indexOf(":annotation") < 0 && element.getTagName().indexOf(":documentation") < 0) {
                sb.append(String.format(ELEMENT_LOG, indent, element.getTagName(), element.getAttribute("name")));
                return true;
            }
        }
        return false;
    }