Text count words
text-count-words · version 1.0.0 · Text · free, no key needed
Count words and return their code-point average, longest word, and optional capped per-word frequencies.
Use when you need to: how many words are in this passage · count each word in supplied prose · calculate average word length.
Decide before calling
Read the versioned contract and the supported scope below. Reuse text-count-words@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use text-count-words@1.0.0 for how many words are in this passage. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- how many words are in this passage
- count each word in supplied prose
- calculate average word length
- find the longest whitespace delimited word
- return word frequencies for this text
- measure words using Unicode whitespace
Not supported
- dictionary or linguistic word recognition
- Unicode UAX #29 word segmentation
- case-folded word frequency grouping
Behavior
- Words are maximal non-empty runs of code points not having White_Space in Unicode 15.1.0 PropList.txt.
- This is not Unicode Standard Annex #29 word segmentation.
- Longest ties select the earliest word; average is a reduced numerator/denominator code-point fraction, or 0/1 when empty.
- include_word_counts defaults to false; true returns first-occurrence-ordered exact-string frequencies and is limited to 256 distinct entries.
Input
text(string, required): max length 4096include_word_counts(boolean, optional): defaultfalse
Output
word_count(integer, required): min 0; max 4096average_word_code_points(string, required)longest_word(string, required): max length 4096longest_word_code_points(integer, required): min 0; max 4096word_counts(null or array of object, required)standard_version(string, required)data_version(string, required)
Limits
- max input bytes: 4096
- max code points: 4096
- max iterations: 20480
- max word count entries: 256
- max output bytes: 24576
Example
Request input:
{
"text": "one two"
}
Response:
{
"result": {
"word_count": 2,
"average_word_code_points": "3/1",
"longest_word": "one",
"longest_word_code_points": 3,
"word_counts": null,
"standard_version": "Unicode 15.1.0",
"data_version": "unicode-15.1.0-white-space"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "text-count-words",
"version": "1.0.0",
"input": {
"text": "one two"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/text-count-words/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"text":"one two"}'
The machine-readable contract is at /v1/tools/text-count-words/versions/1.0.0.
CLI
node cli.mjs run text-count-words 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Text reading stats: Return word, sentence, and paragraph counts plus a rounded-up reading-time estimate at a chosen pace.
- Text shingle similarity: Exact shingle-set resemblance (Jaccard) and containment of two texts, with counts and shared shingles.
- Bleu ngrams count: Count BLEU clipped n-gram matches and totals per order for tokenized segments, with optional clipping tables.
- Citation batch check: Check an ordered batch of citations (span+quote or quote anchors) against supplied sources; returns the first failure.
- Citation anchor check: Check a quote anchor (exact text plus prefix/suffix) matches exactly one place in a supplied source version.
- Citation record dedupe: Group duplicate CSL citation records by deterministic DOI or folded year|author|title match keys, in input order.