News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

New Idea

Started by DoctorToxn, March 27, 2005, 04:30:51 PM

Previous topic - Next topic

DoctorToxn

I was just browsing your forum and say that there were like 226148 topics in the forum.  And I was wondering, how many words that are in those 226148.  I think in the next release, that there should be a "Total Words" statistic.  I think that would be cool if it didn't take too long to compile and display.  Just an idea.

BuilderDan

Oldiesmann

I think this would be better as a mod, but PHP does have a built-in function that sort of does this - see http://www.php.net/str_word_count for more details.
Michael Eshom
Christian Metal Fans

Grudge

Indeed, this is very hard to keep track of. Every time a post is edited/deleted you'd need to update the total. Also, counting all the totals at once would be overwealming on anything except a small board. One thing you could easily do is look at the size of the messages table, and "guess" the amount of words based on the physical size it occupies.
I'm only a half geek really...

Oldiesmann

#3
Now that you mention it, this could get a bit complicated. It would indeed be a killer for large boards to count words for existing messages, and then you'd have to strip out everything you didn't want counted as a word (HTML code, bbcode tags and smiley codes) before counting them. Otherwise, you could just add something to the post2() function to have it count the words everytime a new post was made or one was edited.
Michael Eshom
Christian Metal Fans

DoctorToxn

I know that it could get very confusing in the coding in recounting EVERY view especially in large forums.  So what about having a second post function that counts and adds that number to an existing number in a SQL row.  Same with editing, Add or subtract the number of words edited or added to that SQL row. (Like a counter, Except with subtraction also.)

BuilderDan

Grudge

It's that infamous trade off between effort and usefulness. Sure, you could do that, but it would be a hell of a lot of work for very little benefit. Personally, I'd just work out the average words per message once, then times that by the number of messages you have - not accurate but a reasonable guess.
I'm only a half geek really...

DoctorToxn

Can you do that in php?

BuilderDan

Grudge

Well, what I would do is create a little PHP script that you run once you have a fairly busy board, which will count up the total words in ALL your messages, and divide this by the number of messages, to give you an average words/message figure. Now, you could then just use this figure to display the total amount of words on your board by doing something like:
$totalWords = $modSettings['totalPosts'] * 24.646;

Where 24.646 would be whatever the average amount was. You could run the little PHP script every so often to get a more accurate value (Indeed you could store this "value" in the SMF settings table)

The problem is the little PHP script would not be an easy write if you had lots of messages (>5000). You'd need to have it fetch maybe 500 at a time and add code to stop it timing out, as it would be a demanding job I suspect. Think this is best going in Mod Requests as it's not going to make it as a built in feature I'm afraid :)
I'm only a half geek really...

DoctorToxn

Well thanks.  I might do that sometime.  It was just an idea.

BuilderDan

Amacythe

Quote from: Grudge on March 27, 2005, 06:12:31 PM
It's that infamous trade off between effort and usefulness. Sure, you could do that, but it would be a hell of a lot of work for very little benefit. Personally, I'd just work out the average words per message once, then times that by the number of messages you have - not accurate but a reasonable guess.

After all, who's going to go through every post and count the words to prove your stats wrong? ;)

DoctorToxn

Quote from: Amacythe on March 27, 2005, 07:59:34 PM
After all, who's going to go through every post and count the words to prove your stats wrong? ;)

Good point.

BuilderDan

Advertisement: