2012-07-07 4 views
8

맞춤법 오류 및 결합 된 단어 (예 : 'I love you'vs 'Iloveyou')를 맞춤법 검사해야하는 TSV (탭으로 구분 된 값) 파일이 있습니다.자동 고침 맞춤법 검사기

내 컴퓨터에 Aspell을 설치했으며 aspell() 기능을 사용하여 R을 통해 실행할 수 있습니다.

files <- "train2.tsv" 
res <- aspell(files) 
str(res) 
summary(res) 

그러나 R로 실행 한 결과는 맞춤법이 틀린 단어 목록과 가능한 제안 일뿐입니다.

> summary(res) 
Possibly mis-spelled words: 
[1] "amant"  "contaneir" "creat"  "ddition"  "EssaySet"  "EssayText" "experiament" "expireiment" "expirement" 
[10] "Fipst"  "infomation" "Inorder"  "measureing" "mintued"  "neccisary" "officialy" "renuminering" "rinsen"  
[19] "sticlenx"  "sucessfully" "tipe"   "vineager"  "vinigar"  "yar" 

> str(res) 
Classes ‘aspell’ and 'data.frame':  27 obs. of 5 variables: 
$ Original : chr "EssaySet" "EssayText" "expirement" "expireiment" ... 
$ File  : chr "train2.tsv" "train2.tsv" "train2.tsv" "train2.tsv" ... 
$ Line  : int 1 1 3 3 3 3 3 3 6 6 ... 
$ Column  : int 4 27 27 108 132 222 226 280 120 156 ... 
$ Suggestions:List of 27 
    ..$ : chr "Essay Set" "Essay-Set" "Essayist" "Essays" ... 
    ..$ : chr "Essay Text" "Essay-Text" "Essayist" "Sedatest" ... 
    ..$ : chr "experiment" "excrement" "excitement" "experiments" ... 
    ..$ : chr "experiment" "experiments" "experimenter" "excrement" ... 
    ..$ : chr "Amandy" "am ant" "am-ant" "Amanda" ... 
    ..$ : chr "year" "ya" "Yard" "yard" ... 

맞춤법 오류가있는 단어를 자동으로 수정하는 방법이 있습니까? 다음 작업을 수행 할 수있는 것처럼

답변

8

그것은 같습니다 문서를 통해

s = load_up_users_dictionary() 

for word in text_to_check: 
    if word not in s: 
     new_words = s.suggest(word) 
     replace_incorrect_word(word, new_words[0])#Pick the first word from the returned list. 

그냥 빨리 눈을하고는 자동으로 제안 된 올바른 맞춤법을 사용하도록해야 할 것이 무엇처럼 보인다.

http://0x80.pl/proj/aspell-python/index-c.html

편집 : 는 파이썬 코드를 찾고되지 않을 수도 실현,하지만이 문제는 파이썬 태그 된 파이썬 함께 할 수있는 가장 쉬운 방법이 될 것입니다. 아마 그것을하는 더 효율적인 방법이 있을지 모르지만 늦게지고 있고 이것이 처음부터 생각났습니다.

+0

나는 NLP를위한 좋은 라이브러리가 있다는 것을 알고 있기 때문에 python 태그를 붙 였고 R에서 아무 것도 나오지 않으면 좋은 백업이 될 것이라고 생각했기 때문에 감사합니다. – screechOwl

+0

좋아요, 위의 의미에서 위는 간단한 방법입니다. 설명서에 숨겨진 보석이있을 것입니다. – sean