Generate template and extract variables from texts. In other words, template-analysis makes reverse template (untemplate).
Currently, this supports analyzing one or more texts.
from template_analysis import analyze
result = analyze([
"A dog is a good pet",
"A cat is a good pet",
"A cat is a pretty pet",
"A bird is a great pet",
])
result.to_format_string() # => "A {0} is a {1} pet"
result.args[0] # => ["dog", "good"]
result.args[1] # => ["cat", "good"]
result.args[2] # => ["cat", "pretty"]
result.args[3] # => ["bird", "great"]- 1. Untemplate two texts.
- 2. Untemplate multiple / complex texts.
- 3. Untemplate nested / tree-structured texts.
- 4. Support several features for scraping.
- 5. Implement a more efficient algorithm.
This repository uses lefthook to run the same checks as CI locally, so problems surface before they reach CI.
# Install dependencies
uv sync
# Install the Git hooks (once; requires lefthook on your PATH)
lefthook installOnce installed, the hooks run automatically:
- pre-commit:
uv run poe check - pre-push:
uv run poe checkanduv run poe test
You can also run the checks manually:
uv run poe check
uv run poe testCI still runs the full matrix (see .github/workflows/); the hooks only bring that
feedback earlier on your machine.
See CHANGELOG.md for release history and upgrade notes.
The 3-Clause BSD License. See also LICENSE file.




