Word Letter Frequency
Quick start
- Identify the input text (typically one word or a short phrase). Default behavior lowercases the text and ignores non-letters so repeated letters like
a/Aare merged. - Run
scripts/count_letters.py "<text>"to get a frequency table. Use the optional flags when needed:--case-sensitivekeeps uppercase and lowercase separate.--include-non-alphacounts digits/punctuation as-is.--jsonreturns machine-friendly JSON for downstream processing.
- Summarize the counts for the user. Include clarifying notes (e.g., whether you ignored punctuation) when relevant.
Script reference
scripts/count_letters.py
Lightweight CLI/utility that powers this skill. It exposes two layers:
- CLI usage:
python3 scripts/count_letters.py "balloon" --json - Import usage:
from scripts.count_letters import count_lettersand callcount_letters(text, case_sensitive=False, include_non_alpha=False)to get acollections.Counter.
Sample CLI output (default options):
$ python3 scripts/count_letters.py "balloon"
Character Count
--------- -----
a 1
b 1
l 2
o 2
n 1
Sample JSON output (good for embedding directly into responses):
$ python3 scripts/count_letters.py "AaB!" --case-sensitive --include-non-alpha --json
{"A": 1, "a": 1, "B": 1, "!": 1}
Response patterns
- Concise summary: “
ballooncontainsb×1, a×1, l×2, o×2, n×1(case-insensitive, punctuation ignored).” - Tabular snippet: Mirror the script’s table for readability. Mention any options you used.
- JSON / dict: When the user wants structured data, reuse the script’s
--jsonflag.
Edge cases & tips
- Make sure to state how you treated uppercase letters and punctuation, especially when the counts differ depending on options.
- If the input contains no alphabetic characters and
--include-non-alphais not set, the script intentionally reports “(no characters were counted)”. Explain why in the response. - For multiple words, either run the script once on the full phrase (default) or note that the skill focuses on short strings; if the request expands to full documents, escalate to a general text-analysis workflow instead.
Scan to join WeChat group