Sign inSign up

jlundan/spacy-nodejs-alpine

By jlundan

•Updated about 9 years ago

A docker container which runs spaCy behind NodeJS API

Image
0

1.2K

jlundan/spacy-nodejs-alpine repository overview

This docker container runs spaCy⁠ behind NodeJS API allowing clients to communicate with spaCy via HTTP requests.

Prebuilt Docker images are available at https://hub.docker.com/r/jlundan/spacy-nodejs-alpine/⁠

⁠Examples

⁠Running
docker run -p 5000:3000 jlundan/spacy-nodejs-alpine
⁠Get some info about the API
curl http://localhost:5000

You should receive following kind of response

{
  "title": "spaCy JSON service",
  "spacyInfo": {
    "name": "spacy",
    "version": "1.9.0",
    "website": "https://spacy.io/"
  }
}
⁠Processing a sentence
curl -X POST --data '{"input": "This is a test."}' \
    -H "Content-Type: application/json" http://localhost:5000

You should receive following response

[{
  "text": "This is a test.",
  "len": 5,
  "tokens": [
    "This",
    "is",
    "a",
    "test",
    "."
  ],
  "noun_phrases": [
    "a test"
  ],
  "parse_tree": [
    {
      "word": "is",
      "lemma": "be",
      "NE": "",
      "POS_fine": "VBZ",
      "POS_coarse": "VERB",
      "arc": "ROOT",
      "modifiers": [
        {
          "word": "This",
          "lemma": "this",
          "NE": "",
          "POS_fine": "DT",
          "POS_coarse": "DET",
          "arc": "nsubj",
          "modifiers": []
        },
        {
          "word": "test",
          "lemma": "test",
          "NE": "",
          "POS_fine": "NN",
          "POS_coarse": "NOUN",
          "arc": "attr",
          "modifiers": [
            {
              "word": "a",
              "lemma": "a",
              "NE": "",
              "POS_fine": "DT",
              "POS_coarse": "DET",
              "arc": "det",
              "modifiers": []
            }
          ]
        },
        {
          "word": ".",
          "lemma": ".",
          "NE": "",
          "POS_fine": ".",
          "POS_coarse": "PUNCT",
          "arc": "punct",
          "modifiers": []
        }
      ]
    }
  ],
  "parse_list": [
    {
      "word": "This",
      "lemma": "this",
      "NE": "",
      "POS_fine": "DT",
      "POS_coarse": "DET"
    },
    {
      "word": "is",
      "lemma": "be",
      "NE": "",
      "POS_fine": "VBZ",
      "POS_coarse": "VERB"
    },
    {
      "word": "a",
      "lemma": "a",
      "NE": "",
      "POS_fine": "DT",
      "POS_coarse": "DET"
    },
    {
      "word": "test",
      "lemma": "test",
      "NE": "",
      "POS_fine": "NN",
      "POS_coarse": "NOUN"
    },
    {
      "word": ".",
      "lemma": ".",
      "NE": "",
      "POS_fine": ".",
      "POS_coarse": "PUNCT"
    }
  ]
}]
⁠Processing multiple sentences
curl -X POST --data '{"input": ["This is a test.", "This is another test, it has \"quotes\" in it."]}' \
    -H "Content-Type: application/json" http://localhost:5000

The response is similar than with processing single sentence. Responses are returned for each sentence in the input array in the same order input sentences were given.

⁠Building
docker build -t [tag]:[version] --build-arg SPACY_VERSION=[spacy version] .

Tag summary

Content type

Image

Digest

Size

122.4 MB

Last updated

about 9 years ago

docker pull jlundan/spacy-nodejs-alpine