# 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](/v1/tools/text-count-words/versions/1.0.0) 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 4096
- `include_word_counts` (boolean, optional): default `false`

## Output

- `word_count` (integer, required): min 0; max 4096
- `average_word_code_points` (string, required)
- `longest_word` (string, required): max length 4096
- `longest_word_code_points` (integer, required): min 0; max 4096
- `word_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:

```json
{
  "text": "one two"
}
```

Response:

```json
{
  "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](/docs#connect)), then call `execute` with:

```json
{
  "id": "text-count-words",
  "version": "1.0.0",
  "input": {
    "text": "one two"
  }
}
```

### HTTP (no key)

```sh
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](/v1/tools/text-count-words/versions/1.0.0).

### CLI

```sh
node cli.mjs run text-count-words 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Text reading stats](/tools/text-reading-stats): Return word, sentence, and paragraph counts plus a rounded-up reading-time estimate at a chosen pace.
- [Text shingle similarity](/tools/text-shingle-similarity): Exact shingle-set resemblance (Jaccard) and containment of two texts, with counts and shared shingles.
- [Bleu ngrams count](/tools/bleu-ngrams-count): Count BLEU clipped n-gram matches and totals per order for tokenized segments, with optional clipping tables.
- [Citation batch check](/tools/citation-batch-check): Check an ordered batch of citations (span+quote or quote anchors) against supplied sources; returns the first failure.
- [Citation anchor check](/tools/citation-anchor-check): Check a quote anchor (exact text plus prefix/suffix) matches exactly one place in a supplied source version.
- [Citation record dedupe](/tools/citation-record-dedupe): Group duplicate CSL citation records by deterministic DOI or folded year|author|title match keys, in input order.
