Tinderbox Forum

Counting words in an outline's note and all its child notes

I’m aware that you can use the $WordCount attribute to display the number of words in a note’s text.

Is there a way to get a word count of:

  1. A note’s text +
  2. The text in all of the indented child notes underneath #1

It would be great if this word count could also include the text that makes up a note’s title.

Just for some background, I use Workflowy for some of my writing and I have a JavaScript bookmarklet that performs a word count for #1 and #2 based on the outline element that I have selected.

I started using a Tinderbox outline for some of this writing and would like to count words written in a similar fashion. I’d prefer it be a manual process that I invoke but I would also settle for something automatic that runs in the background.

Any suggestions appreciated.

#1 Try $WordCount.

#2. These need a little action code.

WordCount of just (immediate) children, stored in the note’s $MyNumber:

$MyNumber = sum(children, $WordCount);

Same, but including the current note:

$MyNumber = $WordCount + (sum(children, $WordCount));

Or, WordCount of just all descendants, stored in the note’s $MyNumber:

$MyNumber = sum(descendants, $WordCount);

Same, but including the current note:

$MyNumber = $WordCount + (sum(descendants, $WordCount));

Does that help?

Mark - Thanks for those suggestions. I’ll try them out and let everyone know the results in this thread.

Also edited my initial post to make things a bit clearer. Ideally, for the parent note and it’s child note(s) I’d like to get a summed word count for each note’s title and text.

For example, a nested word count of the following outline:

Parent Note

  • Title - 5 words
  • Text - 10 words

Child Note 1

  • Title - 5 words
  • Text - 20 words

Child Note 2

  • Title - 10 words
  • Text - 20 words

Would result in a word count of 70 words.

Sorry about any unclarity in my initial post.

The difference here is that you’re introducing the note title ($Name) as part of the count. In Tinderbox, $Name and $Text are discrete attributes but $WordCount only counts words in $Text. As $Text has a word count, there hasn’t, up to this point needed to have word counting action.

To get the number of words in $Name (or any string):

$MyNumber=$Name.split(" ").count;

My earlier examples won’t work with this as you’d need to iterate each child/descendant to test the size of $Name. But use an edict (not a rule - it doesn’t need to run all the time) for the notes of interest. Add a user attributes of Number type, $NameWordCount and $TotalWordCount. The edict:

$NameWordCount = $Name.split(" ").count;
$TotalWordCount = $NameWordCount + $WordCount

Update, as needed. Then adapt my earlier codes. thus, the total wordcount of just (immediate) children, stored in the note’s $MyNumber:

$MyNumber = sum(children, $TotalWordCount);

Same, but including the current note:

$MyNumber = $TotalWordCount + (sum(children, $TotalWordCount));

Or, total word count of just all descendants, stored in the note’s $MyNumber:

$MyNumber = sum(descendants, $TotalWordCount);

Same, but including the current note:

$MyNumber = $TotalWordCount + (sum(descendants, $TotalWordCount));

If you fee the app needs an attribute representing the word count of both $Text and $name, then send a feature request to support: info@eastgate.com

Though I’m unclear as to why you need this count, one other approach is simply to use the note $Name as the first paragraph of the note’s $Text.