Comments (5)
Sure, the steps to generating a new language are fairly straight forward:
- Download the set of words that should be added to the dictionary
- I have used the WordFrequency Project but not sure all languages are present there
- Load that file into a dictionary; this will depend on your source. The key, is to turn this into a dictionary in the form: key=word, val=frequency as an int.
If your data in in a dictionary form, you can load it like so:
from spellchecker import SpellChecker
spell = SpellChecker(language=None)
spell.word_frequency.load_dictionary(file_to_dictionary)
spell.export(location_for_export)
If you only have txt files with words, etc, you can just load those words directly and have spellchecker build the word frequency for you:
from spellchecker import SpellChecker
spell = SpellChecker(language=None)
spell.word_frequency.load_text_file(path_to_text_file)
spell.export(location_for_export)
Once you have exported the dictionary (really a word frequency list), you can then load that dictionary when you wish to use spellchecker:
from spellchecker import SpellChecker
spell = SpellChecker(language=None, local_dictionary=location_from_export)
from pyspellchecker.
Thanx for the clear instructions,I had successfully loaded my text file.
Now the problem is it does not give me correct answers
eg:
for word in misspelled:
# Get the one most likely
answer
print(spell.correction(word))
it should return the correct or most likely word,but sometimes it gives me wrong word in the misspelled,
or it returns the whole misspelled string.
Thank you.
from pyspellchecker.
That is likely due to a few different possible issues.
- If you do not have frequency, i.e., everything is set to 1 (or the same thing). Try something like:
# return those that are within the specified distance
print(spell.candidates(word))
- If the distance between the word you are trying to correct is greater than 2, then it will not work and it will return the word, as is.
Honestly, I have never tried this with non-latin character languages so I am unsure how it will perform.
from pyspellchecker.
@MukhtarShaima Let me know if you are still having issues, otherwise, I am going to close this one!
Thanks!
from pyspellchecker.
Hi,
From my understanding, we can load JSON formatted dictionaries or text documents that will be used for building the frequency list.
I would like to directly use the word frequency lists available here (Word Frequency): https://github.com/hermitdave/FrequencyWords/tree/master/content/2018/fi
These are txt files containing frequencies. Is there a way to directly load such files or do I need to convert them to JSON first?
Thanks for your help!
from pyspellchecker.
Related Issues (20)
- jsonDecode Error when initializing SpellChecker Class HOT 9
- dictionary inconsistency HOT 2
- KeyError:
- No correction on misspelled words HOT 1
- case_sensitive=True gives unexpected results HOT 6
- load_words is not prioritized HOT 1
- Common misspellings are not included HOT 2
- nan flagged as should not check HOT 1
- Look into a different data source to build dictionaries HOT 1
- When will v0.7.0 be released?
- PEP 517 and PEP 621 support HOT 1
- installing from source instructions outdated HOT 1
- Not Working in Python 3.11 HOT 1
- Missing countries in german language HOT 4
- Add py.typed
- PyPI entry points to wrong package HOT 1
- Incorrect word "thiss" in English dictionary HOT 3
- Incomplete words
- Error in load file function HOT 1
- Dozens of words are detected as wrong in German, though very common HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyspellchecker.