com.johnsnowlabs.nlp.annotators.spell.norvig
internal types to show Rows as a relevant StructType Should be deleted once Spark releases UserDefinedTypes to @developerAPI
internal types to show Rows as a relevant StructType Should be deleted once Spark releases UserDefinedTypes to @developerAPI
takes a document and annotations and produces new annotations of this annotator's annotation type
takes a document and annotations and produces new annotations of this annotator's annotation type
Annotations that correspond to inputAnnotationCols generated by previous annotators if any
any number of annotations processed for every input annotation. Not necessary one to one relationship
Sensitivity on spell checking (Default: true
).
Sensitivity on spell checking (Default: true
). Might affect accuracy
variants of variants of a word
requirement for annotators copies
requirement for annotators copies
Wraps annotate to happen inside SparkSQL user defined functions in order to act with org.apache.spark.sql.Column
Wraps annotate to happen inside SparkSQL user defined functions in order to act with org.apache.spark.sql.Column
udf function to be applied to inputCols using this annotator's annotate function as part of ML transformation
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.
Override for additional custom schema checks
Override for additional custom schema checks
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
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
Given requirements are met, this applies ML transformation within a Pipeline or stand-alone Output annotation will be generated as a new column, previous annotations are still available separately metadata is built at schema level to record annotations structural information outside its content
Given requirements are met, this applies ML transformation within a Pipeline or stand-alone Output annotation will be generated as a new column, previous annotations are still available separately metadata is built at schema level to record annotations structural information outside its content
Dataset[Row]
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
).
Number of words in the dictionary
Number of words in the dictionary
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
This annotator retrieves tokens and makes corrections automatically if not found in an English dictionary. Inspired by Norvig model and SymSpell.
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.
This is the instantiated model of the NorvigSweetingApproach. For training your own model, please see the documentation of that class.
Pretrained models can be loaded with
pretrained
of the companion object:The default model is
"spellcheck_norvig"
, if no name is provided. For available pretrained models please see the Models Hub.For extended examples of usage, see the Spark NLP Workshop and the NorvigSweetingTestSpec.
Example
ContextSpellCheckerModel for a DL based approach
SymmetricDeleteModel for an alternative approach to spell checking