Deploy eyecite in a Docker container and expose its core functions as RESTful API endpoints, enabling programmatic access to citation extraction, resolution, annotation, and cleaning.
Based on README.rst and eyecite/init.py, the main user-facing functions are:
get_citations: Extract citations from text.resolve_citations: Cluster and resolve citations to logical referents.annotate_citations: Annotate text with markup around citations.clean_text: Clean and preprocess text for citation extraction.
Optional:
dump_citations: For debugging, returns detailed metadata for each citation.
Proposed endpoints (all accept/return JSON):
-
POST /extract- Input:
{ "text": "...", "options": {...} } - Output:
{ "citations": [...] } - Calls:
get_citations
- Input:
-
POST /resolve- Input:
{ "citations": [...], "options": {...} } - Output:
{ "clusters": {...} } - Calls:
resolve_citations
- Input:
-
POST /annotate- Input:
{ "text": "...", "annotations": [...], "options": {...} } - Output:
{ "annotated_text": "..." } - Calls:
annotate_citations
- Input:
-
POST /clean- Input:
{ "text": "...", "steps": [...] } - Output:
{ "cleaned_text": "..." } - Calls:
clean_text
- Input:
-
POST /extract-resolve- Input:
{ "text": "...", "options": {...} } - Output:
{ "clusters": {...} } - Calls:
get_citations+resolve_citations
- Input:
-
(Optional)
POST /dump- Input:
{ "text": "...", "options": {...} } - Output:
{ "citations": [...] } - Calls:
dump_citations
- Input:
- Use FastAPI (recommended for Python, async, OpenAPI support) or Flask.
- Add a
Dockerfileto build the container. - Add a
requirements.txtor updatepyproject.tomlfor API dependencies.
-
API Server
- Create
api/directory withmain.py(FastAPI app). - Implement endpoints, mapping JSON requests to eyecite functions.
- Validate and serialize input/output (handle citation objects, spans, etc.).
- Create
-
Dockerization
- Write a
Dockerfile:- Use official Python base image.
- Install eyecite and API dependencies.
- Set entrypoint to run the API server (e.g.,
uvicorn api.main:app).
- Write a
-
Testing
- Add example requests for each endpoint.
- Add unit/integration tests for API.
-
Documentation
- Document endpoints in
README.mdor via OpenAPI (FastAPI auto-generates). - Provide usage examples (e.g., with
curlor Python requests).
- Document endpoints in
-
Deployment
- Optionally add a
docker-compose.ymlfor local development. - Push image to a registry if needed.
- Optionally add a
eyecite/
api/
main.py
Dockerfile
requirements.txt
PLAN.md
README.md
...
- Consider exposing tokenizer selection and options via API.
- For large texts, support file uploads or streaming if needed.
- Ensure security best practices (limit request size, sanitize input).
- Optionally, add authentication for production deployments.