Skip to main content
analyzeText runs a comprehensive analysis on a Persian string. The result is a deeply structured object: statistics, ratios, readability, language detection, sentiment, keywords, style, and editorial suggestions. Convenience helpers exist for one-shot lookups.
The main function is analyzeText, not textAnalyzer.

Main function

analyzeText(text, options?)

The result is deeply nested — there is no flat { characters, words, lines } shape.

Result shape

The individual interfaces are all exported.

Convenience helpers

getTextSummary(text)

getTextComplexity(text)

getTextSentiment(text)

getTextKeywords(text, limit?)

cleanText(text) & normalizeText(text)

Use cleanText for display polish; normalizeText for equality comparisons across user variations.

Performance

analyzeText is the heaviest utility in the library — it runs ~10 sub-analyses. Debounce for real-time per-keystroke usage. For batch jobs that need only one signal, prefer the dedicated helpers.

Pitfalls

  • The function is analyzeText, not textAnalyzer.
  • Return shape is deeply nested. Access .statistics.totalWords, not .words.
  • isPurePersian: true requires no Arabic-specific letters and no other-language tokens; mixed posts return false.
  • Sentiment is rule-based. Acceptable for triage; do not present as fine-grained sentiment grading.

Source

src/modules/textAnalyzer/index.ts, constants.ts · Tests: test/textAnalyzer.spec.ts