Commits

João Felipe Santos committed 9ae8edd

ResultsParser now asks user about typos with Damerau-Levenshtein distance 1. Package pyxdameraulevenshtein is required for using this feature.

Comments (0)

Files changed (2)

MainInterfaceQt.py

         self.buttonStart = QtGui.QPushButton('Start', self)
         self.slider = Phonon.VolumeSlider(self)
         self.slider.setAudioOutput(self.audio)
-        self.entry = QtGui.QLineEdit()
+        self.entry = QtGui.QLineEdit(self)
         self.entry.setEnabled(False)
         entryFont = QtGui.QFont("Times", 18)
         self.entry.setFont(entryFont)
 from cPickle import Unpickler
 from SentenceList import SentenceList
 from ConfigParser import ConfigParser
+from pyxdameraulevenshtein import damerau_levenshtein_distance
 import re, string
 
 class ResultsParser:
                     print x
                     y = cleanup(self.sentence_list.sentences[clean_name(s)].lower())
                     print y
-                    n_matches = len(filter(lambda b: b in y, x))
-                    print 'Matches: %d/%d' % (n_matches, len(y))
-                    intels.append(float(n_matches)/len(y))
+                    direct_matches = len(filter(lambda b: b in y, x))
+                    print 'Direct matches: %d/%d' % (direct_matches, len(y))
+                    not_found = filter(lambda b: b not in y, x)
+                    indirect_matches = 0
+                    for nf in not_found:
+                        similar = filter(lambda b: damerau_levenshtein_distance(b,nf) == 1, y)
+                        if len(similar) > 1:
+                            answer = raw_input('Indirect match: %s / %s. Accept? [y/N] ' % (nf, similar))
+                            if answer.lower() == 'y':
+                                indirect_matches += 1
+                    intels.append(float(direct_matches+indirect_matches)/len(y))
                 else:
                     print 'Key %s was not present' % s
                     intels.append(0.0)