Tiddler Statisticas

I believe there are scripts available to calculate the statistics for a tiddler, but I cannot seem to locate them. If you have written such a script or know of a link to a solution, please share it here.

image.png

NOTE i: For one tiddler page has no meaning (but for whole wiki it can be number of non-system tiddlers)
NOTE ii: A form of this can be seen in edit mode
MOTE iii: A complete form can be displayed on clicked word counts button at the bottom of tiddler.

I have indeed made some similar attempts for the codemirror6 plugin

I remember the EditorCounter plugin also has a similar function, but it is not specific enough.

2 Likes

Try this:
https://tiddlytools.com/#TiddlyTools%2FTemplates%2FSize

When a tiddler is being edited, it will show a summary total of lines (separated by \n), words (separated by whitespace or \n), and bytes for ALL fields in the tiddler.

Clicking on the summary shows a table with the same statistics, broken out for each field of the tiddler, plus the total number of lines/words/bytes used by tiddler fieldnames.

enjoy,
-e

3 Likes

Both are great! Many thanks.

Eric,

I Just looked at this now, and see it is of great value to a designer. Bringing to gether all fields etc… very nice.

However if I am an author I primarily want it to display only the size details of the text field, in the editor.

  • However I am currently building a book athorship wiki that leverages Streams, so there will be a heirachy of nodes below I want counted as well. I wonder if there is an easy way to include a filter (that obtaines all child tiddlers) such that I can see lines, words and bytes of the combined total.

I have not yet reviewed your code to see if I can retrofit so thought I would ask first.

Rather than trying to retrofit my existing TiddlyTools/Templates/Size code, here’s some code that gives you the totals for the text field of all the tiddlerx matching a specified filter:

<$let tids="[prefix<currentTiddler>]"
	 count={{{ [subfilter<tids>count[]] }}}
	 bytes={{{ [subfilter<tids>] :map[{!!text}length[]] +[sum[]] }}}
	 lines={{{ [subfilter<tids>] :map[{!!text}splitregexp[\n]count[]] +[sum[]] }}}
	 words={{{ [subfilter<tids>] :map[{!!text}splitregexp[\n]splitregexp[\s+]count[]] +[sum[]] }}}>
<<count>> tiddlers, <<bytes>> bytes, <<words>> words, <<lines>> lines

Notes:

  • tids is the filter syntax for selecting the tiddlers you want to total. In the above example, I’ve used [prefix<currentTiddler>] on the assumption that “child” tiddlers are named by using the “parent” tiddler title as a prefix. If this is not how your child tiddlers are named, you will need to adjust the filter accordingly.
  • count is the number of tiddlers being summarized
  • bytes gets the length of each tiddler’s text field and then sums them to get the total
  • lines gets the number of lines of text in each tiddler by splitting on the newlines
  • words gets the number of words of text in each tiddler by splitting on the newlines and then splitting on whitespace in each line

To have this code invoked in each tiddler, place it in a separate tiddler (e.g.,MyTiddlerStats), and tag it with $:/tags/EditTemplate.

enjoy,
-e

1 Like

Thanks Eric. I will apply that soon, very helpful.