Author Topic: Mod: Bad Spelling Tax  (Read 13414 times)

Offline feeble

Mod: Bad Spelling Tax
« on: July 02, 2007, 06:17:48 pm »
This mod require Spellchecking to be enabled and working correctly.

What it does: For every word that is spelt incorrectly, user loses 2 times Per Word Bonus.

WARNING: If you make this change, you might find that SMFShop will have issues uninstalling and updating to future version. To correct this, you will need to take this out when you go and uninstall or patch.

open Sources/Post.php
Find
Code: [Select]
// The bonus for each word...
$points += ($modSettings['shopPointsPerWord'] * str_word_count($plaintext));
// ...and bonus for each letter
$points += ($modSettings['shopPointsPerChar'] * strlen($plaintext));

Add After
Code: [Select]
if(!empty($modSettings['enableSpellChecking']) && function_exists('pspell_new')){
// Okay, this looks funny, but it actually fixes a weird bug.
ob_start();
$old = error_reporting(0);

// See, first, some windows machines don't load pspell properly on the first try.  Dumb, but this is a workaround.
pspell_new('en');

// Next, the dictionary in question may not exist.  So, we try it... but...
$pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER);
error_reporting($old);
ob_end_clean();

// Most people don't have anything but english installed... so we use english as a last resort.
if (!$pspell_link)
$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);

$known_words = array('smf', 'php', 'mysql', 'www', 'gif', 'jpeg', 'png', 'http', 'smfisawesome', 'grandia', 'terranigma', 'rpgs');

$plaintextExploded = explode(" ", $plaintext);
foreach($plaintextExploded as $k => $v) {
   if (!(pspell_check($pspell_link, $v) || in_array($v,$known_words)))
  $points -= ($modSettings['shopPointsPerWord']*2);
}

}


If you have any issues, please let me know.

Offline Daniel15

Re: Mod: Bad Spelling Tax
« Reply #1 on: July 03, 2007, 01:44:49 pm »
Haha... Quite a funny modification, good work Feeble  O0

The problem I see is that the spell checker does not recognise all words, so it may think that something is misspelt when it actually isn't. Anyways, this is still a good modification, and some people will definitely like it :)

Offline feeble

Re: Mod: Bad Spelling Tax
« Reply #2 on: July 03, 2007, 04:08:34 pm »
It does have its issues thats for sure.

As names and such will more then likely be considered wrong.
I'm pretty sure Daniel15 is grammatically wrong.

Also, as with your mod, it only adjusts point on new posts and not actually after you edit them.

I figure thou, the words it gets right will off set users noticing the words it checks wrong.

Seems like SMF's implementation on the Spell Checker is very basic, do you know if there will be improvements in 2.0?

Offline Daniel15

Re: Mod: Bad Spelling Tax
« Reply #3 on: July 08, 2007, 01:30:29 pm »
Quote
Seems like SMF's implementation on the Spell Checker is very basic, do you know if there will be improvements in 2.0?
I haven't checked, but I don't think much has changed.
Apart from implementing our own SMF spell checker, it's not really that easy to improve it. The pspell implementation in PHP isn't that flexible at all...

Offline perplexed

Re: Mod: Bad Spelling Tax
« Reply #4 on: July 10, 2007, 07:57:33 pm »
 ;D that's very funny Feeble, I would love to do this but I have a feeling some people might get a little upset... but I still might  >:D
Estne volumen in toga, an solum tibi libet me videre?

Offline JRSofty

Re: Mod: Bad Spelling Tax
« Reply #5 on: July 11, 2007, 10:35:56 pm »
I love it. I might actually implement something like that on my own site.

I really get ticked off by people who enter comments using SMS/IM type spelling.

I figure if someone is going to take the time to post on a forum they should at least make it so people can understand them :D

Offline feeble

Re: Mod: Bad Spelling Tax
« Reply #6 on: July 12, 2007, 02:11:40 pm »
I love it. I might actually implement something like that on my own site.

I really get ticked off by people who enter comments using SMS/IM type spelling.

I figure if someone is going to take the time to post on a forum they should at least make it so people can understand them :D
If you need help editing it at all, let me know.

I've been thinking about writing a mod to do with something like this to improve SMF Spellchecker and/or have something similar to the "Smartiness" Mod from vbulliten(if you make to many mistakes you get banned for a couple of days)

Offline Martin

Re: Mod: Bad Spelling Tax
« Reply #7 on: July 26, 2007, 01:04:17 am »
Nice mod, and yeah, you should make the Smartness system (maybe even make it possible to enable/disable the points and ban system for it) for SMF, it would be really useful for some forums (including mine).

Offline h1t3m

Re: Mod: Bad Spelling Tax
« Reply #8 on: December 23, 2007, 07:06:23 pm »
,,nbm

Offline `TheSentinel

Re: Mod: Bad Spelling Tax
« Reply #9 on: August 04, 2008, 03:00:40 am »
Why not use this except make a good spelling mod !

That gives a certain amount of credit per correctly spelled word.

I'd do it myself, but I'm new to php & smf forums.

Offline Honey Love

Re: Mod: Bad Spelling Tax
« Reply #10 on: September 07, 2012, 07:37:00 pm »
I have a couple of questions;

Will this be effected by the Spell Check Custom Words mod, and is it effected by the UK/US variations? For example, colour vs color and centre vs center?

I'd hate to dock our users because we're from different spelling backgrounds :|