Youngmeen/language-learning-analytics
0
Linguistic Analytics Service
FastAPI microservice computing the SPEC §7 text-based linguistic metrics on a learner's session production. Called by the Next.js app after a session ends; writes results to analytics_results in Supabase (service-role key — the only writer by design).
POST /analyze {"session_id": "..."}—Authorization: Bearer $ANALYTICS_SERVICE_SECRETGET /health
Env vars: SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, ANALYTICS_SERVICE_SECRET.
Metrics — version text-1.0
Computed on learner turns only, tokenized/parsed with spaCy small models (en_core_web_sm, ko_core_news_sm, ja_core_news_sm, zh_core_web_sm, fr_core_news_sm, de_core_news_sm). Small models are a deliberate v1 tradeoff for hosting cost; an upgrade (e.g. Stanza) bumps metrics_version so results stay comparable within a version. "Words" = alphabetic tokens, lowercased.
volume
lexical_diversity
lexical_sophistication (wordfreq Zipf scale, per target language)
syntax (dependency-parse approximations)
repetition
repair (typing-mode heuristic — limited until speech mode adds timing)
Development
uv sync
uv pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl
uv run pytest # metric tests are hand-computed known-input/expected-output
uv run uvicorn app.main:app --port 7860