A basic Client for SpaCy API Server implemented in Go
Notes:
- Was tested with docker image of the server: jgontrum/spacyapi:en_v2
Run Go get to download this package:
go get github.com/ceh137/spacy_go_client
Import package into files you would like to use in:
package main
import (
spy "github.com/ceh137/spacy_go_client"
)
Two simple steps:
- Create
SpacyClient
. - Use it to call methods
func main() {
sc := spy.SpacyClient{
Model: spy.EnModel,
Url: "localhost:8080",
}
sentDeps, _ := sc.GetSentDeps("Some text")
ents, _ := sc.GetEnts("Some text")
deps, _ := sc.GetDeps("Some text", true, true)
}
To understand the terminology better please refer to the original SpaCy Documentation
Feel free to use these constants to set the model in your client:
const (
EnModel = "en"
DeModel = "de"
EsModel = "es"
FrModel = "fr"
PtModel = "pt"
ItModel = "it"
NlModel = "nl"
)
Returns Sentences and Dependency parses
Returns Sentences from text
Returns Entities found in text
Returns Dependencies found in text
Returns the version od spacy on your server
Returns available on your server models