com.johnsnowlabs.nlp.annotators.spell.context
Adds a new class of words to correct, based on regex.
Adds a new class of words to correct, based on regex.
Name of the class
Regex to add
Maximal distance to the word
Adds a new class of words to correct, based on a vocabulary.
Adds a new class of words to correct, based on a vocabulary.
Name of the class
Vocabulary as a list
Maximal distance to the word
Batch size for the training in NLM (Default: 24
).
What case combinations to try when generating candidates (Default: CandidateStrategy.ALL
).
Min number of times the word need to appear in corpus to not be considered of a special class (Default: 15.0
).
Min number of times a compound word should appear to be included in vocab (Default: 5
).
Configproto from tensorflow, serialized into byte array.
Configproto from tensorflow, serialized into byte array. Get with config_proto.SerializeToString()
Number of epochs to train the language model (Default: 2
).
Threshold perplexity for a word to be considered as an error (Default: 10f
).
Final learning rate for the LM (Default: 0.0005f
).
input annotations columns currently used
Gets annotation column name going to generate
Gets annotation column name going to generate
Initial learning rate for the LM (Default: .7f
).
Input Annotator Types: TOKEN
Input Annotator Types: 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
Number of classes to use during factorization of the softmax output in the LM (Default: 2000
).
Maximum number of candidates for every word (Default: 6
).
Maximum length for a sentence - internal use during training (Default: 250
)
Maximum size for the window used to remember history prior to every correction (Default: 5
).
Min number of times a token should appear to be included in vocab (Default: 3.0
).
Output Annotator Types: TOKEN
Output Annotator Types: TOKEN
Overrides required annotators column if different than default
Overrides required annotators column if different than default
Overrides annotation column name when transforming
Overrides annotation column name when transforming
List of parsers for special classes (Default: List(new DateToken, new NumberToken)
).
Tradeoff between the cost of a word error and a transition in the language model (Default: 18.0f
).
requirement for pipeline transformation validation.
requirement for pipeline transformation validation. It is called on fit()
required uid for storing annotator to disk
required uid for storing annotator to disk
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
Percentage of datapoints to use for validation (Default: .1f
).
The path to the file containing the weights for the levenshtein distance.
Maximum distance for the generated candidates for every word (Default: 3
).
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 a deep-learning based Noisy Channel Model Spell Algorithm. Correction candidates are extracted combining context information and word information.
For instantiated/pretrained models, see ContextSpellCheckerModel.
Spell Checking is a sequence to sequence mapping problem. Given an input sequence, potentially containing a certain number of errors,
ContextSpellChecker
will rank correction sequences according to three things:For an in-depth explanation of the module see the article Applying Context Aware Spell Checking in Spark NLP.
For extended examples of usage, see the article Training a Contextual Spell Checker for Italian Language, the Spark NLP Workshop and the ContextSpellCheckerTestSpec.
Example
For this example, we use the first Sherlock Holmes book as the training dataset.
NorvigSweetingApproach and SymmetricDeleteApproach for alternative approaches to spell checking