From a57170e7c2f0f934f1c03eaee1a52173cc7571f9 Mon Sep 17 00:00:00 2001 From: twanvl Date: Mon, 29 Dec 2008 01:34:13 +0000 Subject: [PATCH] Simple spelling checker using the Hunspell library. This time adding the source files :) The checker is used (experimentally) by the magic game file. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1262 0fc631ac-6414-0410-93d0-97cfa31319b6 --- data/magic.mse-game/language | 2 + data/magic.mse-game/script | 15 +++-- src/script/functions/spelling.cpp | 92 +++++++++++++++++++++++++++++++ src/util/spell_checker.cpp | 60 ++++++++++++++++++++ src/util/spell_checker.hpp | 42 ++++++++++++++ 5 files changed, 206 insertions(+), 5 deletions(-) create mode 100644 src/script/functions/spelling.cpp create mode 100644 src/util/spell_checker.cpp create mode 100644 src/util/spell_checker.hpp diff --git a/data/magic.mse-game/language b/data/magic.mse-game/language index 8b9432e5..f6887c60 100644 --- a/data/magic.mse-game/language +++ b/data/magic.mse-game/language @@ -4,6 +4,7 @@ languages := [ English: [ code : "en", + spellcheck_code : "en_US", pt_separator : "/", type_separator : " — ", subtype_separator : " ", @@ -17,6 +18,7 @@ languages := [ Français: [ code : "fr", + spellcheck_code : "", # TODO: get dictionary pt_separator : "/", type_separator : " : " subtype_separator : " et ", diff --git a/data/magic.mse-game/script b/data/magic.mse-game/script index 00101469..45e08daa 100644 --- a/data/magic.mse-game/script +++ b/data/magic.mse-game/script @@ -322,8 +322,8 @@ mana_context := |adds?|pay(ed)?[ ](with|using) ) ([ ]either)? # pay either X or Y - ([ ]]*>[STQXYZIWUBRG0-9/|]+]*>,)* # pay X, Y or Z - ([ ]]*>[STQXYZIWUBRG0-9/|]+]*>[ ](and|or|and/or))* # pay X or Y + ([ ](]*>)?[STQXYZIWUBRG0-9/|]+(]*>)?,)* # pay X, Y or Z + ([ ](]*>)?[STQXYZIWUBRG0-9/|]+(]*>)?[ ](and|or|and/or))* # pay X or Y [ ] ([,.)]|$ # (end of word) |[ ][^ .,]*$ # still typing... @@ -343,6 +343,7 @@ text_filter := # step 1 : remove all automatic tags remove_tag@(tag: "") + remove_tag@(tag: "") + + remove_tag@(tag: "" + mana_filter_t() + ""} ) + # step 5 : add mana & tap symbols replace@( - match: "\b[STQXYZIWUBRG0-9/|]+\b", + match: "\\b[STQXYZIWUBRG0-9/|]+\\b", in_context: mana_context, replace: {"" + mana_filter_t() + ""} ) + # step 5b : add explict mana symbols @@ -410,7 +411,9 @@ text_filter := + "([[:lower:]])" # match this + "(?![)])", # not followed by this replace: { _1 + to_upper(_2) }) + - curly_quotes + curly_quotes + + # step 9 : spellcheck + { check_spelling(language:language().spellcheck_code) } ############################################################## Other boxes @@ -423,7 +426,9 @@ flavor_text_filter := # step 2 : surround by tags { "" + input + "" } + # curly quotes - curly_quotes + curly_quotes + + # spellcheck + { check_spelling(language:language().spellcheck_code) } # Move the cursor past the separator in the p/t and type boxes type_over_pt := replace@(match:"/$", replace:"") diff --git a/src/script/functions/spelling.cpp b/src/script/functions/spelling.cpp new file mode 100644 index 00000000..0d295670 --- /dev/null +++ b/src/script/functions/spelling.cpp @@ -0,0 +1,92 @@ + +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +// ----------------------------------------------------------------------------- : Includes + +#include +#include