Try this next time you have word counts to do

Comments about LibriVox? Suggestions to improve things? News?
peegee
Posts: 690
Joined: November 7th, 2009, 1:55 pm

Post by peegee » February 26th, 2010, 6:23 am

I recently had my first experience of setting up the Magic Window and, I don't know about you, but I found the word counts a bit tedious.

Since I have a sore throat at the moment and I am unable to record, :cry: and I'm a bit of a dabbler in computers, :wink: I knocked up a little script which may make the job a bit easier.

The script runs against the HTML ebooks on Gutenberg.
- you click the paragraph where you want to start the count,
- it asks you the target number of words,
- it quickly goes through every paragraph from that point onwards and counts the words and the running total
- it stops when it reaches the target, or the end of the chapter if before
- the page is temporarily changed to display the word counts right there at the end of each paragraph
- you can repeat this as many times as you like, each time you click a paragraph the temporary page changes are removed

In the spirit of a picture being worth a thousand words, I've posted a few screenshots to illustrate it:
http://picasaweb.google.com/100844930061266895472/WordCountScreenshots

If you would like to try it out, you will first need the GreaseMonkey add-on for Firefox (skip this step for Chrome):
https://addons.mozilla.org/en-US/firefox/addon/748

Firefox : Once you have GreaseMonkey installed, go here to install my word counter script.
http://userscripts.org/scripts/show/69969

Chrome: go here to install the Chrome version (GreaseMonkey not needed)
http://userscripts.org/scripts/show/70234

After that all you need to do is visit Project Gutenberg and choose the HTML ebook you want to count.

It's a bit limited because its only available for Firefox/Chrome (there's no reason it couldn't work on other web browsers but they would need to have a GreaseMonkey equivalent), and it only works on the Gutenberg online HTML books, not the text or zipped HTML, or other formats. If there's any interest I'm sure it would be possible to extend it's reach (though I would rather spend my spare time recording than scripting :) .

If you care to give it a go I hope it helps you out!

If you have any problems or need more specific help then please post here or PM me and I'll do what I can to help.

enjoy!
Phil
Last edited by peegee on March 1st, 2010, 10:26 am, edited 1 time in total.

RuthieG
LibriVox Admin Team
Posts: 22049
Joined: April 17th, 2008, 8:41 am
Location: Kent, England
Contact:

Post by RuthieG » February 26th, 2010, 7:07 am

That sounds extremely clever, and I am sure it will be really useful for book co-ordinators. Well done! :)

Ruth

P.S. Hope the throat is better soon!
My LV catalogue page | RuthieG's CataBlog of recordings | Tweet: @RuthGolding

Hokuspokus
LibriVox Admin Team
Posts: 8004
Joined: October 24th, 2007, 12:17 pm
Location: Germany
Contact:

Post by Hokuspokus » February 26th, 2010, 10:20 am

I use Word Count Plus with Firefox.
https://addons.mozilla.org/en-US/firefox/addon/4718
It works on HTML and txt.

Another useful Addon is Foxytunes.
http://www.foxytunes.com/firefox/download/
Gives you play buttons in the magic Window and on our catalog pages.
Has been mentioned several times before, but you can't talk about good things too often.

This post has 60 words ;-)

Good wishes for your throat, peegee.

peegee
Posts: 690
Joined: November 7th, 2009, 1:55 pm

Post by peegee » February 26th, 2010, 11:07 am

Thanks Hokuspokus.

I used the Word Count Plus add-on; it was OK for counting a whole chapter, but for splitting long chapters into readable chunks I found it tedious to have to keep selecting text over and over again. That's what prompted me to write the script which I posted here. I just wanted to be able to tell it to count, say, 3500 words and show me how much of the text that was.

regards
Phil

neckertb
Posts: 12819
Joined: March 9th, 2009, 7:47 am
Location: French in Denmark

Post by neckertb » February 26th, 2010, 1:06 pm

I'm looking forward to trying it, thanks Phil! :D
Nadine

Les enfants du capitaine Grant

Live in a death + 70 country? Have a look at Legamus

icyjumbo

Post by icyjumbo » February 26th, 2010, 1:14 pm

Thanks. Installed. It sounds very useful.

peegee
Posts: 690
Joined: November 7th, 2009, 1:55 pm

Post by peegee » March 1st, 2010, 10:28 am

Just a quick note to say I have also got this script working on Google Chrome.

I've edited the original post to reflect that. The Chrome version of the script is here, just click on the Install button!
http://userscripts.org/scripts/show/70234

regards
Phil

neckertb
Posts: 12819
Joined: March 9th, 2009, 7:47 am
Location: French in Denmark

Post by neckertb » April 17th, 2010, 12:49 pm

Just ran it for the first time, so I thought I'd post my comments:


BRILLIANT!
1. I managed to install it right away
2. I got it to work first try
3. It goes soooo much faster

I vote for putting this in the Wiki!

Thanks a lot Phil :D
Nadine

Les enfants du capitaine Grant

Live in a death + 70 country? Have a look at Legamus

Cori
LibriVox Admin Team
Posts: 11990
Joined: November 22nd, 2005, 10:22 am
Location: Great Britain
Contact:

Post by Cori » April 17th, 2010, 12:56 pm

In Opera, creating a new bookmark, with the code below, will do the same sort of thing (that is, count the words in a highlighted piece of text.)

I used "Word Count" for the bookmark name, and then put the code (which I did NOT write, but forget who to credit to, sorry, unknown geek!) into the address box (in the 'details' section).
javascript:(function(){var t;if (window.getSelection) t = window.getSelection();else if (document.selection) t = document.selection.createRange();if (t.text != undefined) t = t.text;if(!t || t == ""){ a = document.getElementsByTagName("textarea"); for(i=0; i<a.length; i++) { if(a.selectionStart != undefined && a.selectionStart != a.selectionEnd) { t = a.value.substring(a.selectionStart, a.selectionEnd); break; } }}if(!t || t == "")alert("please select some text");else alert("word count: " + t.toString().match(/(\S+)/g).length);})()

It's placed in my 'Personal Bar' along with a similar bit of code for Deliciousing stuff, and a few other bits and bobs.
There's honestly no such thing as a stupid question -- but I'm afraid I can't rule out giving a stupid answer : : To Posterity and Beyond!

neckertb
Posts: 12819
Joined: March 9th, 2009, 7:47 am
Location: French in Denmark

Post by neckertb » April 17th, 2010, 1:02 pm

OK, some people know more about computers than I do... Still, your info, Cori, together with Phil's script would be very useful t have in the Wiki?
Nadine

Les enfants du capitaine Grant

Live in a death + 70 country? Have a look at Legamus

peegee
Posts: 690
Joined: November 7th, 2009, 1:55 pm

Post by peegee » April 17th, 2010, 1:08 pm

Hey thanks for the great feedback Nadine, glad it worked for you.

Cori, the point of the script I wrote is that you don't have to select any text at all, just click on the paragraph where you want to start counting. I think Opera supports greasemonkey-style scripts, I'll take a look and see if I can get it working. Watch this space :wink:

regards
Phil

Cori
LibriVox Admin Team
Posts: 11990
Joined: November 22nd, 2005, 10:22 am
Location: Great Britain
Contact:

Post by Cori » April 17th, 2010, 1:20 pm

Ah, okay. I tend to highlight the chapter / page I'm counting, and then just want to know how many words in that ... yours is a bit smarter about the counting. :)
There's honestly no such thing as a stupid question -- but I'm afraid I can't rule out giving a stupid answer : : To Posterity and Beyond!

peegee
Posts: 690
Joined: November 7th, 2009, 1:55 pm

Post by peegee » April 17th, 2010, 2:09 pm

Cori,

Good news, the Chrome version works in Opera too, though it's not quite the one-click install ...

If you want to try it out:
  • To enable user JavaScript, use Tools > Preferences > Advanced > Content > JavaScript options, and select the directory where you will put your User JavaScript files (probably best if its a new folder with nothing else in it).
  • then go to the script http://userscripts.org/scripts/show/70234
  • click the Install button to get the script in a new tab in Opera.
  • from the menu click File > Save As to save it into the folder you chose in the first step (probably best to just keep the suggested file-name - whatever name you choose it MUST end in .user.js
That's it, it should be installed now. No need to restart Opera just go to a Gutenberg HTML book, click on any paragraph and you will get the prompt to start counting...

This worked for me on Opera 10.1 in Linux (10.5 not available for Linux yet).

If you get any problems post here or PM me and I'll try to help.

happy counting :D

regards
Phil

peegee
Posts: 690
Joined: November 7th, 2009, 1:55 pm

Post by peegee » April 17th, 2010, 2:31 pm

Nadine,

I have a wiki account, so I will put this info on there. I'll try to make a start on it tomorrow. :D

It looks like it would be good to add a link from this page too http://wiki.librivox.org/index.php/Tips_for_Book_Coordinators

regards
Phil

neckertb
Posts: 12819
Joined: March 9th, 2009, 7:47 am
Location: French in Denmark

Post by neckertb » April 18th, 2010, 12:05 am

peegee wrote: It looks like it would be good to add a link from this page too http://wiki.librivox.org/index.php/Tips_for_Book_Coordinators

regards
Phil
I completely agree, thanks!
Nadine

Les enfants du capitaine Grant

Live in a death + 70 country? Have a look at Legamus

Post Reply