Text statistics are a powerful feature that provide statistics about text in a document. By default, there are numerous text statistics available, even including things like readability scores. Syntax languages can also choose to customize the statistics by supplying additional ones such as commented-line counts, etc.
Built-In Statistics
The IText
- Line count
- Whitespace line count
- Sentence count
- Word count
- Syllable count
- Character count
- Whitespace character count
- Letter count
- Consonant count
- Vowel count
- Average words / sentence
- Average syllables / word
- Average letters / word
- Flesch reading ease score
- Flesch-Kincaid grade level
See the IText
Getting Statistics for a Snapshot
The IText
This code shows how to get the statistics for the current snapshot of a document:
Getting Statistics for a String
Text statistics can also be generated for a String
variable by creating an instance of the Text
This code shows how to generate the built-in statistics for a String
variable named text
:
Registering a Custom Statistics Factory for a Syntax Language
In some syntax languages, some of those statistics may not be useful or you may wish to add other statistics, such as comment coverage. Adding new statistics is easy.
First, make a class that inherits Text
Second, in your Text
Third, override the Get
Fourth, make a class that implements IText
Finally, we you need to associate the IText
Your custom statistics should be ready for use after that.