Constructor
new ComplexEvaluator(className)
ComplexEvaluator constructor
Name | Type | Description |
---|---|---|
className | string | The class name of this evaluator. |
Extends
Members
PUNCTUATION :string
String containing all the characters considered as punctuation marks (currently ".,;:")
- string
checkAccents :boolean
Whether accented letters must be considered equivalent or not.
- boolean
checkDoubleSpaces :boolean
Whether to check or not the extra spaces added between words.
- boolean
checkPunctuation :boolean
Whether to check or not dots, commas and other punctuation marks when comparing texts.
- boolean
checkScope :number
When an eror is detected in the analyzed expression, this variable indicates the number of
characters the checking pointer will be moved forward and back looking for a coincident
expression.
For example, comparing the answer "one lardzy dog" with the correct answer "one lazy dog"
will detect an error at position 6 (an "r" instead of "z"). If checkSteps
is set to 2 or
greater, the "zy dog" expression at position 8 will be found and evaluated as valid, while
a value of 1 or less will not found any coincident expression beyond the error position, thus
evaluating all the remaining sentence as erroneous.
- number
checkSteps :number
Number of times to repeat the evaluation process if an error is found, eliminating in each
cycle the extra characters that caused the error.
- number
checkcase :boolean
Whether uppercase and lowercase expressions must be considered equivalent or not.
- boolean
className :string
The type of evaluator.
- string
collator :external:Collator
The Intl.Collator object used to compare strings, when available.
detail :boolean
Whether to detail or not the location of errors found on the analyzed text.
- boolean
initiated :boolean
Whether this evaluator has been initialized or not.
- boolean
Methods
checkText(text, match) → {boolean}
Checks the given text against a set of valid matches
Name | Type | Description |
---|---|---|
text | string | The text to be checked |
match | string | | The valid expression or expressions with which to compare. |
true
if the checked expression is valid,false
otherwise.
- Type:
- boolean
compareSegment(src, ls, ok, lok, attr, iterate) → {boolean}
Compares two segments of text.
This function should make recursive calls.
Name | Type | Description |
---|---|---|
src | string | Text to be compared |
ls | number | Offset in |
ok | string | Text to match against. |
lok | number | Offset in |
attr | Array.<number> | Array of integers that will be filled with information about the |
iterate | boolean | When |
true
if the comparison was valid.
- Type:
- boolean
countFlagsOk(flags) → {number}
Counts the number of flags on the provided array that are zero.
Name | Type | Description |
---|---|---|
flags | Array.<number> |
- Type:
- number
evalText(text, match) → {Array.<number>}
Evaluates the given text against a set of valid matches, returning an array of flags useful
to indicate where the mistakes are located.
Name | Type | Description |
---|---|---|
text | string | The text to be checked |
match | string | | The valid expression or expressions with which to compare. |
- An array of flags (one number for character) indicating whether each
position is erroneous or ok.
- Type:
- Array.<number>
getAttributes() → {object}
Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.
- The resulting object, with minimal attrributes
- Type:
- object
getClearedText(src, skipped) → {string}
Removes double spaces and erroneous characters from a given text expression.
Name | Type | Description |
---|---|---|
src | string | The text to be processed. |
skipped | Array.<boolean> | An array of boolean indicating which characters should be removed |
- Type:
- string
isOk(flags) → {boolean}
Checks if the given array of flags (usually returned by evalText
) can be considered as a
valid or erroneous answer.
Name | Type | Description |
---|---|---|
flags | Array.<number> |
true
when there is at least one flag and all flags are 0 (meaning no error).
- Type:
- boolean
setProperties($xml)
Loads the object settings from a specific JQuery XML element
Name | Type | Description |
---|---|---|
$xml | external:jQuery | The jQuery XML element to parse |