REST API
The reader can be used through the REST API. After building the docker image, launch a container using the following command:
Navigate to localhost:9000/api to interactively explore the API through the OpenAPI 3.0 specification.
Python library
We also provide a Python library as a simple way to build applications that interact with the Odinson REST API. You can either connect to an existing odinson-rest service or launch one using docker.
Launching and interacting with a service using docker
from lum.odinson.doc import Document, Fields
from lum.odinson.rest.docker import DockerBasedOdinsonAPI
# create a local index
data_dir = "/local/path/to/my/data/dir"
engine = DockerBasedOdinsonAPI(local_path=data_dir)
# load an Odinson document
doc_file = "path/to/odinson/document.json"
doc = Document.from_file(doc_file)
# index the document
engine.index(doc)
# query the index
for res in engine.search(odinson_query="[lemma=be]"):
for span in res.spans():
print(f"{res.document_id} ({res.sentence_index}): {span}")
Validating a rule
from lum.odinson.rest.docker import DockerBasedOdinsonAPI
engine = DockerBasedOdinsonAPI()
# will return False
engine.validate_rule("[")
# will return True
engine.validate_rule("[word=Gonzo]")
engine.close()
Common Workflows
- ??
sbt
Several command aliases
are defined in the build.sbt
. These can be altered and added to at the developers discretion.
- dockerfile
: Command for generating and publishing a docker image (target/docker/stage
).
-
dockerize
: Command for generating and publishing a docker image. -
documentize
: Generatesscaladoc
and copies documentation to thedocs/
directory.