반응형
Recent Posts
Recent Comments
관리 메뉴

개발잡부

[python] 오탈자 교정 - SymSpellpy 본문

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

 

 

 

 

반응형

'Python' 카테고리의 다른 글

[python] 날짜계산 (datetime)  (0) 2024.02.06
[python] DB data to json  (0) 2023.09.04
[python] .txt 파일 라인 카운트  (1) 2023.05.19
[python] 데이터검증  (0) 2023.05.17
[python] API 응답시간 확인  (0) 2023.05.04
Comments