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 isanalyzeText, nottextAnalyzer.
Main function
analyzeText(text, options?)
{ characters, words, lines } shape.
Result shape
Convenience helpers
getTextSummary(text)
getTextComplexity(text)
getTextSentiment(text)
getTextKeywords(text, limit?)
cleanText(text) & normalizeText(text)
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, nottextAnalyzer. - Return shape is deeply nested. Access
.statistics.totalWords, not.words. isPurePersian: truerequires no Arabic-specific letters and no other-language tokens; mixed posts returnfalse.- 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