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/
- 1.0.0, latest (1.0.0/Dockerfile) - spaCy version 1.9.0
docker run -p 5000:3000 jlundan/spacy-nodejs-alpine
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/"
}
}
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"
}
]
}]
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.
docker build -t [tag]:[version] --build-arg SPACY_VERSION=[spacy version] .