This version is out of date, covering development from v9.5.0 to v9.7.3. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

WordCount


Attribute Data Type: 

Attribute Default Value: 

Attribute Group: 

Attribute Purpose: 

Attribute Inherited from Preferences?   

Attribute UI-configurable? 

Attribute Read-Only? 

Attribute Intrinsic? 

Attribute First Added: 

Attribute Last Altered: 

 number   [other number-type attributes]

 (not set - 0)

 Textual   [other Textual Group attributes]

 Calculated data

 No

 No

 Yes   [other read-only attributes]

 No

 Baseline

 9.5.2,9.7.3


The number of discrete words in the current note's $Text (read-only).

See $TextLength for the total character count).

$WordCount is not language aware. Essentially it is tuned for the heuristics of English language. Therefore it may not work well with languages that use word-spacing conventions drastically unlike English.

For those needing a word count in a non-English language/script/locale, one approach is to consider String.split(regex), populating the regex with word break characters that may differ from English. Note, in this context punctuation doesn't matter only the alternatives to spaces/non-breaking spaces that a given language may use.

Word count is as much science as art. For instance, is 'UNESCO' one word, six words—or seven if you include the 'and' omitted from the acronym. Within a single country or a single language tradition there may be consensus on such points but it may not hold true more widely.

However, for English text, $WordCount should be considered accurate.

From v9.5.2, $WordCount now works better in Chinese and several other languages. Word count, even in English still remains something of an art. For some languages, such as Chinese, $TextLength—the character count of $Text—may be more useful, if only one type of (language) script is being used in the note. The word count for mixed-script text is always likely to have some inaccuracy as language typing to sub-string level, e.g. discrete parts of $Text, does not occur.

From v9.7.3, if $WordCount is a displayed attribute, editing the text pane periodically updates the displayed word count

Legacy note

In very early versions the attribute name was 'Wordcount' and the program allows either spelling. However, the old version is deprecated.