コード例 #1
0
ファイル: spel.py プロジェクト: okkhoy/gabe-and-joh
 # Import and create spellchecker
 from spellcheck import Spellchecker
 
 spellchecker = Spellchecker()
 
 lines = []
 while True:
     try:
         lines.append(raw_input())
     except EOFError:
         break
 
 text = ' '.join(lines)
 
 
 results = spellchecker.check(text)
 for r in results:
     print r.word + ':', ' '.join(r.candidates[:5])
 
 print
 print results.corrected()
 print 'Corrected text:'
 
 words = []
 i = 0
 for sent in results.corrected():
     for word in sent:
         # Improve this?
         if i > 0 and not word.isalpha():
             words[i-1] = words[i-1] + word
         else:
コード例 #2
0
ファイル: main.py プロジェクト: okkhoy/gabe-and-joh
#!/usr/bin/python
'''
Created on Sep 14, 2009

Main script for running the spell checker.
@author: Gabe Arnold <*****@*****.**>
'''

from sys import argv
from spellcheck import Spellchecker
from input_output import InputParser, OutputGenerator

if __name__ == '__main__':
    xml_file = argv[1]
    output_name = argv[2]
    
    fh = open(xml_file, 'r')
    input = InputParser(fh.read())
    output = OutputGenerator(output_name)
    
    checker = Spellchecker()
    
    for case in input.get_cases():
        corrections = checker.check(case['string'])
        output.append((case['id'], case['string'], corrections))

    output.write()