Ejemplo n.º 1
0
    def __init__(self, stdscr):
        profiles = Profiles()
        profile_data = ProfileData()
        stdscr.refresh()
        stdscr.clear()
        wordbook = WordBook()

        #iterate over every word in the dictionary forever until the user enters nothing
        for word in wordbook.generate_words(train=False):
            stdscr.addstr(0, 0, "%s" % (" " * 100))
            stdscr.addstr(0, 0, "-> %s " % (word))
            stdscr.refresh()
            start = time.time()
            count, user_word = self.read_char(stdscr)
            end = time.time()

            stdscr.addstr(
                3, 0,
                "Time taken: %i, times_corrected: %i" % (end - start, count))
            data_point = DataPoint(time=end - start,
                                   error_count=count,
                                   distance=Levenshtein.distance(
                                       word, user_word))
            break

        classifier = svm.SVC(gamma=1)
        (features, targets) = profiles.get_classifier_data()

        classifier.fit(features, targets)
        predicted = classifier.predict(
            [[data_point.time, data_point.error_count, data_point.distance]])
        print "\nYou're probably.. %s " % predicted[0]
Ejemplo n.º 2
0
 def __init__(self, stdscr):
     profiles = Profiles()
     profile_data = ProfileData()
     stdscr.refresh()
     stdscr.clear()
     wordbook = WordBook()
     
     #iterate over every word in the dictionary forever until the user enters nothing
     for word in wordbook.generate_words(train=False):
         stdscr.addstr(0,0, "%s" % (" " * 100))
         stdscr.addstr(0,0, "-> %s " % (word))
         stdscr.refresh()
         start = time.time()
         count, user_word = self.read_char(stdscr)
         end = time.time()
 
         stdscr.addstr(3, 0, "Time taken: %i, times_corrected: %i" % (end-start, count))
         data_point = DataPoint(time=end-start, error_count=count, distance=Levenshtein.distance(word, user_word))
         break
         
     classifier = svm.SVC(gamma=1)
     (features, targets) = profiles.get_classifier_data()
     
     classifier.fit(features, targets)
     predicted = classifier.predict([[data_point.time, data_point.error_count, data_point.distance]])
     print "\nYou're probably.. %s " % predicted[0]
     
         
Ejemplo n.º 3
0
    def __init__(self, stdscr):
        wordbook = WordBook()
        stdscr.addstr("What is your name?")
        profiles = Profiles()
        profile_data = ProfileData()
        stdscr.refresh()
        name = stdscr.getstr(1,0, 15)
        profile_data.set_name(name)
        profiles.append_profile(profile_data)
        stdscr.clear()
        
        #iterate over every word in the dictionary forever until the user enters nothing
        for word in wordbook.generate_words(train=True):
            stdscr.addstr(0,0, "%s" % (" " * 100))
            stdscr.addstr(0,0, "-> %s " % (word))
            stdscr.refresh()
            start = time.time()
            count, user_word = self.read_char(stdscr)
            end = time.time()
    
            stdscr.addstr(3, 0, "Time taken: %i, times_corrected: %i" % (end-start, count))
    
            if user_word == "":
                break

            #create a data point with the Levenshtein distance, 
            #count of errors user made while typing, and how long the process took 
            data_point = DataPoint(time=end-start, error_count=count, distance=Levenshtein.distance(word, user_word))
            profile_data.append_point(data_point)
        profiles.flush()
Ejemplo n.º 4
0
    def __init__(self, stdscr):
        wordbook = WordBook()
        stdscr.addstr("What is your name?")
        profiles = Profiles()
        profile_data = ProfileData()
        stdscr.refresh()
        name = stdscr.getstr(1, 0, 15)
        profile_data.set_name(name)
        profiles.append_profile(profile_data)
        stdscr.clear()

        #iterate over every word in the dictionary forever until the user enters nothing
        for word in wordbook.generate_words(train=True):
            stdscr.addstr(0, 0, "%s" % (" " * 100))
            stdscr.addstr(0, 0, "-> %s " % (word))
            stdscr.refresh()
            start = time.time()
            count, user_word = self.read_char(stdscr)
            end = time.time()

            stdscr.addstr(
                3, 0,
                "Time taken: %i, times_corrected: %i" % (end - start, count))

            if user_word == "":
                break

            #create a data point with the Levenshtein distance,
            #count of errors user made while typing, and how long the process took
            data_point = DataPoint(time=end - start,
                                   error_count=count,
                                   distance=Levenshtein.distance(
                                       word, user_word))
            profile_data.append_point(data_point)
        profiles.flush()