com.johnsnowlabs.nlp.annotators.spell.norvig
Sensitivity on spell checking (Default: true
).
Sensitivity on spell checking (Default: true
). Might affect accuracy
Spell checking algorithm inspired on Norvig model
Spell checking algorithm inspired on Norvig model
External dictionary to be used, which needs "tokenPattern"
(Default: \S+
) for parsing the resource.
External dictionary to be used, which needs "tokenPattern"
(Default: \S+
) for parsing the resource.
... gummy gummic gummier gummiest gummiferous ...
Increase search at cost of performance (Default: false
).
Increase search at cost of performance (Default: false
). Enables extra check for word combinations, More accuracy at performance
Maximum duplicate of characters in a word to consider (Default: 2
).
Maximum duplicate of characters in a word to consider (Default: 2
). Maximum duplicate of characters to account for.
Applies frequency over hamming in intersections (Default: true
).
Applies frequency over hamming in intersections (Default: true
). When false hamming takes priority
Sensitivity on spell checking (Default: true
).
Sensitivity on spell checking (Default: true
). Might affect accuracy
Increase search at cost of performance (Default: false
).
Increase search at cost of performance (Default: false
). Enables extra check for word combinations
Maximum duplicate of characters in a word to consider (Default: 2
).
Maximum duplicate of characters in a word to consider (Default: 2
). Maximum duplicate of characters to account for.
Applies frequency over hamming in intersections (Default: true
).
Applies frequency over hamming in intersections (Default: true
). When false hamming takes priority
input annotations columns currently used
Hamming intersections to attempt (Default: 10
).
Hamming intersections to attempt (Default: 10
).
Gets annotation column name going to generate
Gets annotation column name going to generate
Word reduction limit (Default: 3
).
Word reduction limit (Default: 3
).
Increase performance at cost of accuracy (Default: false
).
Increase performance at cost of accuracy (Default: false
). Faster but less accurate mode
Vowel swap attempts (Default: 6
).
Vowel swap attempts (Default: 6
).
Minimum size of word before ignoring (Default: 3
).
Minimum size of word before ignoring (Default: 3
). Minimum size of word before moving on.
Input annotator type : TOKEN
Input annotator type : TOKEN
columns that contain annotations necessary to run this annotator AnnotatorType is used both as input and output columns if not specified
columns that contain annotations necessary to run this annotator AnnotatorType is used both as input and output columns if not specified
Hamming intersections to attempt (Default: 10
).
Hamming intersections to attempt (Default: 10
).
Output annotator type : TOKEN
Output annotator type : TOKEN
Word reduction limit (Default: 3
).
Word reduction limit (Default: 3
).
Sensitivity on spell checking (Default: true
).
Sensitivity on spell checking (Default: true
). Might affect accuracy
Path to file with properly spelled words, tokenPattern
is the regex pattern to identify them in text,
readAs can be ReadAs.TEXT
or ReadAs.SPARK
, with options passed to Spark reader if the latter is set.
Path to file with properly spelled words, tokenPattern
is the regex pattern to identify them in text,
readAs can be ReadAs.TEXT
or ReadAs.SPARK
, with options passed to Spark reader if the latter is set.
Dictionary needs tokenPattern
regex for separating words.
External dictionary already in the form of ExternalResource, for which the Map member options
has an entry defined for "tokenPattern"
.
External dictionary already in the form of ExternalResource, for which the Map member options
has an entry defined for "tokenPattern"
.
val resource = ExternalResource( "src/test/resources/spell/words.txt", ReadAs.TEXT, Map("tokenPattern" -> "\\S+") ) val spellChecker = new NorvigSweetingApproach() .setInputCols("token") .setOutputCol("spell") .setDictionary(resource)
Increase search at cost of performance (Default: false
).
Increase search at cost of performance (Default: false
). Enables extra check for word combinations
Maximum duplicate of characters in a word to consider (Default: 2
).
Maximum duplicate of characters in a word to consider (Default: 2
). Maximum duplicate of characters to account for. Defaults to 2.
Applies frequency over hamming in intersections (Default: true
).
Applies frequency over hamming in intersections (Default: true
). When false hamming takes priority
Overrides required annotators column if different than default
Overrides required annotators column if different than default
Hamming intersections to attempt (Default: 10
).
Hamming intersections to attempt (Default: 10
).
Overrides annotation column name when transforming
Overrides annotation column name when transforming
Word reduction limit (Default: 3
).
Word reduction limit (Default: 3
).
Increase performance at cost of accuracy (Default: false
).
Increase performance at cost of accuracy (Default: false
). Faster but less accurate mode
Vowel swap attempts (Default: 6
).
Vowel swap attempts (Default: 6
).
Minimum size of word before ignoring (Default: 3
).
Minimum size of word before ignoring (Default: 3
). Minimum size of word before moving on.
Increase performance at cost of accuracy (Default: false
).
Increase performance at cost of accuracy (Default: false
). Faster but less accurate mode
requirement for pipeline transformation validation.
requirement for pipeline transformation validation. It is called on fit()
takes a Dataset and checks to see if all the required annotation types are present.
takes a Dataset and checks to see if all the required annotation types are present.
to be validated
True if all the required types are present, else false
Vowel swap attempts (Default: 6
).
Vowel swap attempts (Default: 6
).
Minimum size of word before ignoring (Default: 3
).
Minimum size of word before ignoring (Default: 3
). Minimum size of word before moving on.
A list of (hyper-)parameter keys this annotator can take. Users can set and get the parameter values through setters and getters, respectively.
Required input and expected output annotator types
Trains annotator, that retrieves tokens and makes corrections automatically if not found in an English dictionary.
The Symmetric Delete spelling correction algorithm reduces the complexity of edit candidate generation and dictionary lookup for a given Damerau-Levenshtein distance. It is six orders of magnitude faster (than the standard approach with deletes + transposes + replaces + inserts) and language independent. A dictionary of correct spellings must be provided with
setDictionary
either in the form of a text file or directly as an ExternalResource, where each word is parsed by a regex pattern.Inspired by Norvig model and SymSpell.
For instantiated/pretrained models, see NorvigSweetingModel.
For extended examples of usage, see the Spark NLP Workshop and the NorvigSweetingTestSpec.
Example
In this example, the dictionary
"words.txt"
has the form ofThis dictionary is then set to be the basis of the spell checker.
ContextSpellCheckerApproach for a DL based approach
SymmetricDeleteApproach for an alternative approach to spell checking