LibriVox
Forums

* FAQ    * Search
* Login   * Register
It is currently October 16th, 2017, 8:58 pm


Post new topic Reply to topic  Page 1 of 3  [ 39 posts ] 
Go to page 1, 2, 3  Next

Author Message
Offline
Post Posted:: February 26th, 2010, 6:23 am 

Joined: November 7th, 2009, 1:55 pm
Posts: 690
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/10084493006 ... creenshots

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.

Top
 Profile  
Offline
Post Posted:: February 26th, 2010, 7:07 am 
LibriVox Admin Team

Joined: April 17th, 2008, 8:41 am
Posts: 22087
Location: Kent, England
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


Top
 Profile  
Offline
Post Posted:: February 26th, 2010, 10:20 am 
LibriVox Admin Team

Joined: October 24th, 2007, 12:17 pm
Posts: 7945
Location: Germany
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.

_________________
Hokuspokus

Deutsche Buchvorschläge/Buchdiskussion * Prosa-Sammlung * Dschinnistan * Liste kurzer deutscher Texte * Legamus! * Hauptsache Bücher


Top
 Profile  
Offline
Post Posted:: February 26th, 2010, 11:07 am 

Joined: November 7th, 2009, 1:55 pm
Posts: 690
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


Top
 Profile  
Offline
Post Posted:: February 26th, 2010, 1:06 pm 

Joined: March 9th, 2009, 7:47 am
Posts: 12825
Location: French in Denmark
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


Top
 Profile  
Post Posted:: February 26th, 2010, 1:14 pm 
Thanks. Installed. It sounds very useful.


Top
  
Offline
Post Posted:: March 1st, 2010, 10:28 am 

Joined: November 7th, 2009, 1:55 pm
Posts: 690
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


Top
 Profile  
Offline
Post Posted:: April 17th, 2010, 12:49 pm 

Joined: March 9th, 2009, 7:47 am
Posts: 12825
Location: French in Denmark
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


Top
 Profile  
Offline
Post Posted:: April 17th, 2010, 12:56 pm 
LibriVox Admin Team

Joined: November 22nd, 2005, 10:22 am
Posts: 11690
Location: Great Britain
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).

Quote:
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[i].selectionStart != undefined && a[i].selectionStart != a[i].selectionEnd) { t = a[i].value.substring(a[i].selectionStart, a[i].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!


Top
 Profile  
Offline
Post Posted:: April 17th, 2010, 1:02 pm 

Joined: March 9th, 2009, 7:47 am
Posts: 12825
Location: French in Denmark
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


Top
 Profile  
Offline
Post Posted:: April 17th, 2010, 1:08 pm 

Joined: November 7th, 2009, 1:55 pm
Posts: 690
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


Top
 Profile  
Offline
Post Posted:: April 17th, 2010, 1:20 pm 
LibriVox Admin Team

Joined: November 22nd, 2005, 10:22 am
Posts: 11690
Location: Great Britain
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!


Top
 Profile  
Offline
Post Posted:: April 17th, 2010, 2:09 pm 

Joined: November 7th, 2009, 1:55 pm
Posts: 690
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


Top
 Profile  
Offline
Post Posted:: April 17th, 2010, 2:31 pm 

Joined: November 7th, 2009, 1:55 pm
Posts: 690
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 ... ordinators

regards
Phil


Top
 Profile  
Offline
Post Posted:: April 18th, 2010, 12:05 am 

Joined: March 9th, 2009, 7:47 am
Posts: 12825
Location: French in Denmark
peegee wrote:
It looks like it would be good to add a link from this page too http://wiki.librivox.org/index.php/Tips ... ordinators

regards
Phil

I completely agree, thanks!

_________________
Nadine

Les enfants du capitaine Grant

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


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next



Who is online

Users browsing this forum: icequeen and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group