Extracts n-grams (sequential word combinations) from text for linguistic analysis and feature extraction. Use via MCP in Cursor or Windsurf, or call GET /v1/text/ngrams directly. Example: "the quick brown fox" → bigrams ["the quick", "quick brown", "brown fox"]. Returns structured JSON with configurable n-gram size and preprocessing options.
curl "https://tinyfn.io/v1/text/ngrams" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/text/ngrams', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/text/ngrams',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's text analysis tools:
{
"mcpServers": {
"tinyfn-text": {
"url": "https://tinyfn.io/mcp/text",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
N-grams are contiguous sequences of n words from text. Unigrams are single words, bigrams are word pairs, trigrams are three-word sequences. They're essential for language modeling, feature extraction, and text similarity analysis.
Specify the n parameter (2 for bigrams, 3 for trigrams) when calling the tool. The API processes your text and returns all sequential word combinations of the specified length as a structured array.
Yes, the tool includes preprocessing options to normalize case, remove punctuation, and handle special characters. Configure these settings to match your analysis requirements.
The tool supports n-gram sizes from 1 (unigrams) up to reasonable limits based on text length. Larger n-grams become increasingly sparse and less useful for most applications.
Absolutely. N-grams create feature vectors for comparing document similarity, detecting plagiarism, or training language models. Many AI agents use n-gram features for text classification tasks.
Get your free API key and start using Generate Ngrams in seconds.
Get Free API Key