german-stanza

# Running German Stanza¶

Download this NB from https://gatenlp.github.io/python-gatenlp/german-stanza.ipynb

Requirements:

- Python 3.7 or later
- `pip install ipykernel ipython notebook gatenlp stanza`

In [1]:

    from gatenlp import Document
    import stanza
    from gatenlp.lib_stanza import apply_stanza
    from IPython.display import display

In [2]:

    text = """
    Die Meinung der LehrerInnen ist uns wichtig.
    """

In [3]:

    doc = Document(text)

In [4]:

    # If necessary, first download the Stanza model (uncomment)
    # stanza.download("de")

    # Load the german stanza model
    nlp = stanza.Pipeline(lang="de", use_gpu=False)

    INFO:stanza:Loading these models for language: de (German):
    =======================
    | Processor | Package |
    -----------------------
    | tokenize  | gsd     |
    | mwt       | gsd     |
    | pos       | gsd     |
    | lemma     | gsd     |
    | depparse  | gsd     |
    | sentiment | sb10k   |
    | ner       | conll03 |
    =======================

    INFO:stanza:Use device: cpu
    INFO:stanza:Loading: tokenize
    INFO:stanza:Loading: mwt
    INFO:stanza:Loading: pos
    INFO:stanza:Loading: lemma
    INFO:stanza:Loading: depparse
    INFO:stanza:Loading: sentiment
    INFO:stanza:Loading: ner
    INFO:stanza:Done loading processors!

In [5]:

    # Run stanza on the gatenlp document and convert annotations to gatenlp representation
    doc = apply_stanza(nlp, doc)

In [6]:

    # Show the annotated document
    display(doc)

ID: CPCZPZTAZK