Skip to main content
Glama
README.md
# textforge

Tidy text, count words, find keywords and pull out summaries. Pure stdlib, no downloads.

English and Spanish stopwords included — handy as the prep work before any real NLP.

## Install

```sh
pip install git+https://github.com/Alfredo-ctrl/textforge.git
```

## Use it from the terminal

```sh
# tidy a string
textforge clean --text "  Hello,   WORLD!  "
textforge clean --input notes.txt --output notes_clean.txt

# tokens, sentences, frequencies
textforge tokens --text "The quick brown fox"
textforge sentences --input article.txt
textforge freq --input article.txt -n 10 --stopwords
textforge ngrams --input article.txt -n 2

# keywords and stats
textforge keywords --input article.txt -n 10
textforge stats --input article.txt
textforge describe --input article.txt

# extractive summary: the 3 most informative sentences
textforge summary --input article.txt -n 3

# slugify a title
textforge slug --text "Análisis y Minería de Datos"
```

Text comes from `--text`, `--input` (a file) or stdin, in that order. Every command prints JSON.

## Use it from Python

```python
from textforge import clean_text, tokenize, word_freq, keywords, stats, summarize

clean_text("  Hello,   WORLD!  ")  # 'hello, world!'
tokenize("The quick brown fox")  # ['The', 'quick', 'brown', 'fox']
word_freq("dog dog cat", n=2)  # [('dog', 2), ('cat', 1)]
keywords("El gato persiguió al ratón...", n=5)
stats("Some text here. And more.")  # words, sentences, reading time...
summarize("Long article text. More sentences. Even more.", n=2)
```

## MCP server

Any MCP client can use textforge as tools:

```sh
textforge mcp
```

It speaks MCP over stdio and exposes `clean_text`, `tokenize`, `sentences`, `word_freq`, `ngrams`, `keywords`, `stats`, `summarize`, `describe`, `slugify`. Example client config:

```json
{
  "mcpServers": {
    "textforge": {"command": "textforge", "args": ["mcp"]}
  }
}
```

## License

See [LICENSE](LICENSE).