home / skills / bdambrosio / cognitive_workbench / word-count
This skill counts words in text to assess length and determine if summarization is needed before further processing.
npx playbooks add skill bdambrosio/cognitive_workbench --skill word-countReview the files below or copy the command above to add this skill to your agents.
---
name: word-count
type: python
description: "Count words in text. Use to determine length of a document, e.g. to determine if it needs to be summarized before further use"
---
# word-count
Simple deterministic word counting for text analysis.
## Input
- `target`: Note ID or variable containing text to count
## Output
Success (`status: "success"`):
- `value`: String with word count (e.g., "Word count: 6")
- `extra.count`: Integer count
## Behavior
- Simple whitespace-based counting
- Fast and reliable
- Works on any text content
## Planning Notes
- Use to check document length before processing
- Useful for determining if summarization is needed
## Example
```json
{"type":"word-count","target":"$text","out":"$count"}
```
This skill provides a simple, deterministic word count for any text input. It returns both a human-readable string and a numeric count, making it easy to integrate into pipelines that need quick length checks. Use it to decide whether a document should be summarized, split, or processed further.
The skill performs a fast whitespace-based tokenization to count words in the provided text. You supply a target (note ID or variable containing text) and it outputs a string like "Word count: 6" plus an integer in extra.count. It is intentionally simple and reliable, without language-specific tokenization or punctuation rules.
Does the skill handle languages with non-space tokenization?
No. It uses simple whitespace-based counting and does not apply language-specific tokenization for languages that require it.
What output format does it return?
On success it returns a string like "Word count: X" in value and the integer count in extra.count.