code: def annotate():
      global pipelineCache
  
      properties = request.args.get("properties", "")
      lang = request.args.get("pipelineLanguage", "")
      text = list(request.form.keys())[0]
  
      if lang not in pipelineCache:
          pipelineCache[lang] = stanza.Pipeline(
              lang=lang, use_gpu=False
          )
  
      res = pipelineCache[lang](text)
  
      annotated_sentences = []
      for sentence in res.sentences:
          tokens = []
          deps = []
          for word in sentence.words:
              tokens.append(
                  {
                      "index": word.id,
                      "word": word.text,
                      "lemma": word.lemma,
                      "pos": word.xpos,
                      "upos": word.upos,
                      "feats": word.feats,
                      "ner": word.parent.ner
                      if word.parent.ner is None
                      or word.parent.ner == "O"
                      else word.parent.ner[2:],
                  }
              )
              deps.append(
                  {
                      "dep": word.deprel,
                      "governor": word.head,
                      "governorGloss": sentence.words[
                          word.head - 1
                      ].text,
                      "dependent": word.id,
                      "dependentGloss": word.text,
                  }
              )
          annotated_sentences.append(
              {"basicDependencies": deps, "tokens": tokens}
          )
          if (
              hasattr(sentence, "constituency")
              and sentence.constituency is not None
          ):
              annotated_sentences[-1]["parse"] = str(
                  sentence.constituency
              )
  
      return json.dumps({"sentences": annotated_sentences})
  
file_path: stanza/stanza/pipeline/demo/demo_server.py
imports: from flask import Flask, request, abort
  import json
  import stanza
  import os
label_desc: Use image node_id 4 for calling a global function with example usage: annotate() and returns: json