Commit 27d89089 authored by twanvl's avatar twanvl

documented check_spelling function

parent ce720961
Function: check_spelling
--Usage--
> check_spelling(some_tagged_string, language:language_code)
Check the spelling of a piece of text, and mark errors with @<error-spelling>@ tags.
--Dictionaries--
The language code must correspond to a dictionary in the @dictionaries@ data directory (usually @%MSE_DIR%\data\dictionaries@).
A dictionary consists of two files, @language.dic@ and @language.aff@.
Magic Set Editor is compatible with Hunspell dictionaries, which are also used by Open Office and Firefox.
These dictionaries can be found on [[http://wiki.services.openoffice.org/wiki/Dictionaries|the Open Office website]].
--Parameters--
! Parameter Type Description
| @input@ [[type:tagged string]] String to check.
| @language@ [[type:string]] Language code.<br/>
The language code consists of an [[http://en.wikipedia.org/wiki/ISO_639|ISO language code]] and an [[http://en.wikipedia.org/wiki/ISO_3166-1|ISO country code]] separated by an underscore.
| @extra_dictionary@ [[type:string]] (optional)
Name of an additional dictionary to use. This dictionary could be specific to the game file.
The name should be of the form @"my-game.mse-game/dictionary"@,
in which case MSE looks for the file @"my-game.mse-game/dictionary.en_US.dic"@ where @"en_US"@ is the language code.
| @extra_match@ [[type:function]] (optional)
Function that returns @true@ for additional words that are spelled correctly.
This can be used for codes like @"+1/+1"@ on magic cards.
--Examples--
> check_spelling("Can I have an appple?", language:"en_US")
> == "Can I have an <error-spelling:en_US>appple</error-spelling:en_US>?"
In the second example any text matching the [[type:regex]] @"x[a-z]*"@, i.e. any word beginning with the letter x, is not considered an error:
> check_spelling("xyzzyx", language:"en_US")
> == "<error-spelling:en_US>xyzzyx</error-spelling:en_US>"
> check_spelling("xyzzyx", language:"en_US", extra_match: match@(match:"x[a-z]*"))
> == "xyzzyx"
...@@ -23,8 +23,6 @@ These functions are built into the program, other [[type:function]]s can be defi ...@@ -23,8 +23,6 @@ These functions are built into the program, other [[type:function]]s can be defi
| [[fun:reverse]] Reverse a string, @"aBc" -> "cBa"@. | [[fun:reverse]] Reverse a string, @"aBc" -> "cBa"@.
| [[fun:trim]] Remove leading and trailing whitespace from a string, @" abc " -> "abc"@. | [[fun:trim]] Remove leading and trailing whitespace from a string, @" abc " -> "abc"@.
| [[fun:substring]] Extract a part of a string. | [[fun:substring]] Extract a part of a string.
| [[fun:format]] Format a number as a string (printf).
| [[fun:curly_quotes]] Make quotes curly.
| [[fun:replace]] Replace text matching a regular expression. | [[fun:replace]] Replace text matching a regular expression.
| [[fun:filter_text]] Keep only the text matching a regular expression. | [[fun:filter_text]] Keep only the text matching a regular expression.
| [[fun:break_text]] Break text into parts each matching a regular expression. | [[fun:break_text]] Break text into parts each matching a regular expression.
...@@ -33,6 +31,8 @@ These functions are built into the program, other [[type:function]]s can be defi ...@@ -33,6 +31,8 @@ These functions are built into the program, other [[type:function]]s can be defi
| [[fun:contains]] Does a string contain another one? | [[fun:contains]] Does a string contain another one?
| [[fun:match]] Does a string match a regular expression? | [[fun:match]] Does a string match a regular expression?
| [[fun:regex_escape]] Escape a string for use in a regular expression. | [[fun:regex_escape]] Escape a string for use in a regular expression.
| [[fun:curly_quotes]] Make quotes curly.
| [[fun:check_spelling]] Check text for spelling errors.
! [[type:tagged_string|Tags]] <<< ! [[type:tagged_string|Tags]] <<<
| [[fun:tag_contents]] Change the contents of a specific tag. | [[fun:tag_contents]] Change the contents of a specific tag.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment