Esempio n. 1
0
 def evaluate(self, corpus):  
   """Tests this speller on a corpus, returns a SpellingResult"""
   numCorrect = 0
   numTotal = 0
   testData = corpus.generateTestCases()
   for sentence in testData:
     if sentence.isEmpty():
       continue
     errorSentence = sentence.getErrorSentence()
     hypothesis = self.correctSentence(errorSentence)
     if sentence.isCorrection(hypothesis):
       numCorrect += 1
     numTotal += 1
   return SpellingResult(numCorrect, numTotal)
Esempio n. 2
0
 def evaluate(self, corpus):
     """Tests this speller on a corpus, returns a SpellingResult"""
     numCorrect = 0
     numTotal = 0
     testData = corpus.generateTestCases(
     )  #list of sentence objects with only 1 error in sentence. Will have 3 sentences if there were 3 errors in the sentence. 1 for each error.
     for sentence in testData:
         if sentence.isEmpty():
             continue
         errorSentence = sentence.getErrorSentence()
         #print errorSentence
         hypothesis = self.correctSentence(errorSentence)
         if sentence.isCorrection(hypothesis):
             numCorrect += 1
         numTotal += 1
     return SpellingResult(numCorrect, numTotal)