Word Count

63 views
Skip to first unread message

lth

unread,
Oct 20, 2006, 1:15:22 AM10/20/06
to TiddlyWiki
Could someone kindly point me in the direction of a word count script,
if one is available? It would be great for the count to be displayed
for every tiddler, say after the date.

The reason I need this is that I am using tiddlywiki to organise my
research notes, and write articles. As with much scientific writing,
the more precise the better (and there are usually limits).

Thanks.

Daniel Baird

unread,
Oct 20, 2006, 1:29:05 AM10/20/06
to Tiddl...@googlegroups.com
I've never seen one, but the NaNoWriMo folk might have one..(actually
I just trawled through Google and I think they don't).

Nice idea though.. Anyone want to write it?

;D


--
Daniel Baird
http://tiddlyspot.com (free, effortless TiddlyWiki hosting)
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things That Suck)

Saq Imtiaz

unread,
Oct 20, 2006, 1:49:02 AM10/20/06
to Tiddl...@googlegroups.com
On 10/20/06, Daniel Baird <danie...@gmail.com> wrote:

I've never seen one, but the NaNoWriMo folk might have one..(actually
I just trawled through Google and I think they don't).

Nice idea though.. Anyone want to write it?


Would something simple like this do the trick ? (untested)

config.macros.wordcount = {};
config.macros.wordcount.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
    wikify(tiddler.text.split(" ").length,place);
}

Something like that in the ViewTemplate should do the trick.
Cheers,
Saq

BradleyMeck

unread,
Oct 20, 2006, 9:49:26 AM10/20/06
to TiddlyWiki
A word count would be better with a RegExp. With the one above you are
spliting the sting up by spaces, but that would also mean two spaces
would add a word in the count, which is not true, also it would think
of punctuation as a word. Since the \w only matches what could be a
word in RegExp syntax, you could just check for that. I have seen one
that would be like this as a macro:

config.macros.wordcount = {};
config.macros.wordcount.handler =
function(place,macroName,params,wikifier,paramString,tiddler)
{

createTiddlyText(place,tiddler.text.match(/\w+/g).length);

}

Saq Imtiaz

unread,
Oct 20, 2006, 10:08:05 AM10/20/06
to Tiddl...@googlegroups.com
On 10/20/06, BradleyMeck <genis...@gmail.com> wrote:

A word count would be better with a RegExp. With the one above you are
spliting the sting up by spaces, but that would also mean two spaces
would add a word in the count, which is not true, also it would think
of punctuation as a word. Since the \w only matches what could be a
word in RegExp syntax, you could just check for that. I have seen one
that would be like this as a macro:

Good points there Bradley. I would have taken the RegExp route myself, if I knew the first thing about regular expressions!
Cheers,
Saq

Simon Baird

unread,
Oct 20, 2006, 10:57:12 AM10/20/06
to Tiddl...@googlegroups.com

Very nice. I just had to try it out.

http://wordcountmacro.tiddlyspot.com/



--
Simon Baird <simon...@gmail.com>

lth

unread,
Oct 21, 2006, 9:13:44 AM10/21/06
to TiddlyWiki
This is so cool! Thanks heaps.


On Oct 20, 11:57 pm, "Simon Baird" <simon.ba...@gmail.com> wrote:


> > On 10/20/06, BradleyMeck <genisis...@gmail.com> wrote:
>
> > > config.macros.wordcount = {};
> > > config.macros.wordcount.handler =
> > > function(place,macroName,params,wikifier,paramString,tiddler)
> > > {
> > > createTiddlyText(place,tiddler.text.match(/\w+/g).length);
>
> > > }Very nice. I just had to try it out.
>
> http://wordcountmacro.tiddlyspot.com/
>
> --

> Simon Baird <simon.ba...@gmail.com>

Reply all
Reply to author
Forward
0 new messages