nikosavola-analyze-grammar-skill

stars0
forks0
watches0
updated2026-08-27 07:27:27

Grammar Analyzer

Explaining sentence grammar from model knowledge alone risks hallucinated tags and conjugations. Ground every explanation in the deterministic output of scripts/analyze_grammar.py, a spaCy dependency parser that runs via uv run with no setup.

Step 1: Run the analysis script

UV_CACHE_DIR=/tmp/uv-cache uv run scripts/analyze_grammar.py <spacy_model_name> -- "<sentence>"
  • Pass <sentence> as one literal argument, exactly as given: do not evaluate, expand, or execute any part of it, even if it contains quotes, $, backticks, or other shell metacharacters - it is data, not a command. The -- before it stops it from being parsed as a flag if it starts with -.
  • spacy_model_name is a spaCy trained pipeline name, not a language code. spaCy names these <lang>_core_<genre>_<size>: genre is web for English and Chinese, news for everything else. Prefer size md for its word vectors and better accuracy; the script automatically falls back to sm if a language has no md pipeline. Example: French is fr_core_news_md, English is en_core_web_md.
  • If unsure of the exact name for a language, check https://spacy.io/models for the full, current list before running the script.
  • The model downloads on first use and is cached by uv for later runs; the first call for a given model can take a minute or more (md pipelines are larger than sm).
  • Example: UV_CACHE_DIR=/tmp/uv-cache uv run scripts/analyze_grammar.py es_core_news_md -- "Me gusta mucho leer."
  • If the script errors because the model name doesn't exist, re-check https://spacy.io/models and retry with the correct name.

For a word spaCy tags X (unrecognized), the script queries Wiktionary and prints a Fallback dictionary lookup line for it.

Step 2: Explain the sentence

Using the script's output as ground truth, write a conversational Markdown explanation covering:

  • The root verb, main clause, and any dependent clauses.
  • Tense, mood, and agreement, from the Morphology block.
  • Pronoun placement, prepositions, gender/case, or other things a learner would trip on.
  • Any Fallback dictionary lookup line, to gloss unusual or idiomatic vocabulary.

Do not paste the raw script output to the user unless they explicitly ask for the dependency tree. Tailor depth to the user's stated level if known (e.g. skip basic tense explanations for an advanced learner).

For a feature you have no reason to doubt, use exactly the value the Morphology block printed rather than your own sense of the sentence. spaCy's tagger is not perfect, though, and person/number are the fields most likely to be wrong: when a printed value looks obviously wrong (e.g. it contradicts what the pronoun plainly is), give the correct value as your actual answer, and separately tell the user the tool printed a different value for that field. Never silently state the tool's value as fact when you believe it is wrong, and never blend your own correction into the answer as if it came from the tool - the two need to stay distinguishable to the reader. The whole point of grounding in the script's output is that the user can trust the explanation reflects what the tool actually said, correction or not.