It is possible to get the word count of specific articles, or even sections of articles, for display purposes?
I thought it might a a magic word, like PAGENAME or REVISIONID, but I'm not finding anything.
Steven Hilton wrote:
It is possible to get the word count of specific articles, or even sections of articles, for display purposes?
I thought it might a a magic word, like PAGENAME or REVISIONID, but I'm not finding anything.
There's no built-in method for this, no.
-- brion vibber (brion @ pobox.com)
On 7/17/05, Brion Vibber brion@pobox.com wrote:
Steven Hilton wrote:
It is possible to get the word count of specific articles, or even sections of articles, for display purposes?
I thought it might a a magic word, like PAGENAME or REVISIONID, but I'm not finding anything.
There's no built-in method for this, no.
-- brion vibber (brion @ pobox.com)
Okay. I locally modified Language.php, Parser.php and MagicWord.php and have some semblance of a word count magic word. It's really just a one-liner in the right place.
-bash-2.05b$ diff -c Parser.php.bak Parser.php *** Parser.php.bak Sun Jul 17 19:23:56 2005 --- Parser.php Sun Jul 17 19:56:10 2005 *************** *** 1868,1873 **** --- 1868,1875 ---- return $this->mTitle->getText(); case MAG_PAGENAMEE: return $this->mTitle->getPartialURL(); + case MAG_PAGEWORDCOUNT: + return preg_match_all("/\s+/", $wgArticle->getContent(1), $junk_out); case MAG_REVISIONID: return $wgArticle->getRevIdFetched(); case MAG_NAMESPACE:
Not sure how it plays with Templates and non-basic articles.
Would this be useful to the project in general, or has this approach been tried before?
Just counting words as something split on white space wouldn't work for MediaWiki since not all languages split words on white space and even English sometimes spits words on other things than white space or ', "it's" expands to "it is" and it therefor two words.
mediawiki-l@lists.wikimedia.org