Git Product home page Git Product logo

stanza-server's Introduction

Stanza Server

Provides a webservice exposing Stanford Stanza as a webservice.

Usage:

First clone the repository

git clone [email protected]:redlink-gmbh/stanza-server.git

Build the docker image

docker build -t stanza-server .

Run the server via docker

docker run -p 8080:8080 -v ~/stanza_resources/:/root/stanza_resources/ stanza-server

Note:

  • the volume for /root/stanza_resources prevents downloading models on every start

After this you can use the server under http://localhost:8080/process

GPU/CUDA Support

To improve performance, stanza can use a Nvidia-CUDA on a GPU. For CUDA-Support in docker, you have to install nvidia-docker2. After that, start the container with gpu-support enabled:

docker run -p 8080:8080 --gpus all -v ~/stanza_resources/:/root/stanza_resources/ stanza-server

Example Usage:

curl -X POST -H "content-type: application/json" \
    'http://localhost:8080/process' \
    -d '{"lang":"de","text":"Der Hauptsitz von Redlink ist in Salzburg"}'

and the response format:

{
  "sentences": [
    {
      "text": "Der Hauptsitz von Redlink ist in Salzburg",
      "tokens": [
        {
          "id": "1.0-3",
          "text": "Der",
          "start": 0,
          "end": 3
        },
        {
          "id": "2.4-13",
          "text": "Hauptsitz",
          "start": 4,
          "end": 13
        },
        {
          "id": "3.14-17",
          "text": "von",
          "start": 14,
          "end": 17
        },
        {
          "id": "4.18-25",
          "text": "Redlink",
          "start": 18,
          "end": 25,
          "ner": "S-ORG"
        },
        {
          "id": "5.26-29",
          "text": "ist",
          "start": 26,
          "end": 29
        },
        {
          "id": "6.30-32",
          "text": "in",
          "start": 30,
          "end": 32
        },
        {
          "id": "7.33-41",
          "text": "Salzburg",
          "start": 33,
          "end": 41,
          "ner": "S-LOC"
        }
      ],
      "words": [
        {
          "id": "1.0-3",
          "text": "Der",
          "token": "1.0-3",
          "pos": "DET",
          "xpos": "ART",
          "lemma": "der",
          "features": "Case=Nom|Definite=Def|Gender=Masc|Number=Sing|PronType=Art",
          "misc": "start_char=0|end_char=3"
        },
        {
          "id": "2.4-13",
          "text": "Hauptsitz",
          "token": "2.4-13",
          "pos": "NOUN",
          "xpos": "NN",
          "lemma": "Hauptsitz",
          "features": "Case=Nom|Gender=Masc|Number=Sing",
          "misc": "start_char=4|end_char=13"
        },
        {
          "id": "3.14-17",
          "text": "von",
          "token": "3.14-17",
          "pos": "ADP",
          "xpos": "APPR",
          "lemma": "von",
          "features": null,
          "misc": "start_char=14|end_char=17"
        },
        {
          "id": "4.18-25",
          "text": "Redlink",
          "token": "4.18-25",
          "pos": "PROPN",
          "xpos": "NE",
          "lemma": "Redlink",
          "features": "Case=Dat|Gender=Neut|Number=Sing",
          "misc": "start_char=18|end_char=25"
        },
        {
          "id": "5.26-29",
          "text": "ist",
          "token": "5.26-29",
          "pos": "AUX",
          "xpos": "VAFIN",
          "lemma": "sein",
          "features": "Mood=Ind|Number=Sing|Person=3|Tense=Pres|VerbForm=Fin",
          "misc": "start_char=26|end_char=29"
        },
        {
          "id": "6.30-32",
          "text": "in",
          "token": "6.30-32",
          "pos": "ADP",
          "xpos": "APPR",
          "lemma": "in",
          "features": null,
          "misc": "start_char=30|end_char=32"
        },
        {
          "id": "7.33-41",
          "text": "Salzburg",
          "token": "7.33-41",
          "pos": "PROPN",
          "xpos": "NE",
          "lemma": "Salzburg",
          "features": "Case=Dat|Gender=Neut|Number=Sing",
          "misc": "start_char=33|end_char=41"
        }
      ]
    }
  ],
  "entities": [
    {
      "start": 18,
      "end": 25,
      "text": "Redlink",
      "type": "ORG",
      "tokens": [
        "4.18-25"
      ],
      "words": [
        "4.18-25"
      ]
    },
    {
      "start": 33,
      "end": 41,
      "text": "Salzburg",
      "type": "LOC",
      "tokens": [
        "7.33-41"
      ],
      "words": [
        "7.33-41"
      ]
    }
  ]
}

License:

Free use of this software is granted under the terms of the Apache License Version 2.0. See the License for more details.

Open Issues:

  • Stanza can load models for languages (e.g. stanza.download('en')). I would like to have this configureable. For now it only downloads the German and English models are downloaded when it starts.
  • Dependency annotations are not supported yet
  • The analysis pipeline is currently hardcoded. One could make this configurable

stanza-server's People

Contributors

ja-fra avatar westei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.