SMFShop > Modifications

Mod: Bad Spelling Tax

(1/3) > >>

feeble:
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: --- // The bonus for each word...
$points += ($modSettings['shopPointsPerWord'] * str_word_count($plaintext));
// ...and bonus for each letter
$points += ($modSettings['shopPointsPerChar'] * strlen($plaintext));
--- End code ---

Add After

--- Code: --- 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);
}

}
--- End code ---


If you have any issues, please let me know.

Daniel15:
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 :)

feeble:
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?

Daniel15:

--- Quote ---Seems like SMF's implementation on the Spell Checker is very basic, do you know if there will be improvements in 2.0?
--- End quote ---
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...

perplexed:
 ;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

Navigation

[0] Message Index

[#] Next page

Go to full version