Norvig¶
Spelling corrector written by Peter Norvig: How to Write a Spelling Corrector
Parameters¶
-
on (Union[str, List])
Fields to use for fitting the spelling corrector on.
-
lower (bool) – defaults to
True
Attributes¶
- type
Examples¶
>>> from cherche import query, data
>>> documents = data.load_towns()
>>> corrector = query.Norvig(on = ["title", "article"], lower=True)
>>> corrector.add(documents)
Query Norvig
Vocabulary: 967
>>> corrector(q="tha citi af Parisa is in Fronce")
'the city of paris is in france'
>>> corrector(q=["tha citi af Parisa is in Fronce", "parisa"])
['the city of paris is in france', 'paris']
Methods¶
call
Correct spelling errors in a given query.
Parameters
- q (Union[List[str], str])
- kwargs
add
Fit Nervig spelling corrector.
Parameters
- documents (Union[List[Dict], str])
correct
Most probable spelling correction for word.
Parameters
- word (str)
reset
Wipe dictionary.