Python
[python] 오탈자 교정 - SymSpellpy
닉의네임
2023. 7. 2. 16:00
반응형
symspellpy 테스트 해보고
구글 코랩 접속 -> 새노트
We can use load_dictionary():
모듈 설치하고
pip install symspellpy
from itertools import islice
import pkg_resources
from symspellpy import SymSpell
sym_spell = SymSpell()
dictionary_path = pkg_resources.resource_filename(
"symspellpy", "frequency_dictionary_en_82_765.txt"
)
sym_spell.load_dictionary(dictionary_path, 0, 1)
# Print out first 5 elements to demonstrate that dictionary is
# successfully loaded
print(list(islice(sym_spell.words.items(), 5)))
We can use load_bigram_dictionary():
from itertools import islice
import pkg_resources
from symspellpy import SymSpell
sym_spell = SymSpell()
dictionary_path = pkg_resources.resource_filename(
"symspellpy", "frequency_bigramdictionary_en_243_342.txt"
)
sym_spell.load_bigram_dictionary(dictionary_path, 0, 2)
# Print out first 5 elements to demonstrate that dictionary is
# successfully loaded
print(list(islice(sym_spell.bigrams.items(), 5)))
from itertools import islice
from symspellpy import SymSpell
sym_spell = SymSpell()
dictionary_path = <path/to/dictionary>
sym_spell.load_dictionary(dictionary_path, 0, 1, separator="$")
# Print out first 5 elements to demonstrate that dictionary is
# successfully loaded
print(list(islice(sym_spell.words.items(), 5)))
from itertools import islice
from symspellpy import SymSpell
sym_spell = SymSpell()
dictionary_path = <path/to/dictionary>
sym_spell.load_bigram_dictionary(dictionary_path, 0, 1, separator="$")
# Print out first 5 elements to demonstrate that dictionary is
# successfully loaded
print(list(islice(sym_spell.bigrams.items(), 5)))
from symspellpy import SymSpell
sym_spell = SymSpell()
corpus_path = <path/to/plain/text/file>
sym_spell.create_dictionary(corpus_path)
print(sym_spell.words)
https://symspellpy.readthedocs.io/en/latest/examples/index.html
Examples — symspellpy 6.7.7 documentation
symspellpy.readthedocs.io
Examples — symspellpy 6.7.7 documentation
symspellpy.readthedocs.io
반응형