예제 #1
0
    def test_emptyStrings(self):
        """
        Test emtpy strings using default values
        :return:
        """

        ed = DistanceCalculator()
        self.assertEqual(ed.distance('', ''), 0)
        self.assertEqual(ed.distance('a', ''), 1)
        self.assertEqual(ed.distance('', 'a'), 1)
예제 #2
0
class CalcDistance:
    print('Lets calculate the edit distance between two strings.')
    str1 = input('Input first string: ')
    str2 = input('Input second string: ')

    DC = DistanceCalculator()

    print('Edit distance between ', str1, ' and ', str2, ': ',
          DC.distance(str1, str2))
예제 #3
0
    def test_nonStandardDistances(self):
        ed = DistanceCalculator(2, 2, 4)

        self.assertEqual(ed.distance('book', 'books'), 2)
        self.assertEqual(ed.distance('book', 'back'), 4)
        self.assertEqual(ed.distance('books', 'book'), 2)
예제 #4
0
    def test_levensteinDistance(self):

        ed = DistanceCalculator()
        self.assertEqual(ed.distance('book', 'books'), 1)
        self.assertEqual(ed.distance('book', 'back'), 2)
        self.assertEqual(ed.distance('books', 'book'), 1)
예제 #5
0
    def test_sameStrings(self):
        ed = DistanceCalculator()

        self.assertEqual(ed.distance('abc', 'abc'), 0)
예제 #6
0
import tkinter as tk
from util import DistanceCalculator
from tkinter.messagebox import *

ed = DistanceCalculator()


def Show_results():
    sResult = (ed.distance(e1.get(), e2.get()))
    tk.messagebox.showinfo(title="Your Edit distance", message=sResult)


myForm = tk.Tk()
tk.Label(myForm, text="Enter 1st word").grid(row=0)
tk.Label(myForm, text="Enter 2nd word").grid(row=2)

e1 = tk.Entry(myForm)
e2 = tk.Entry(myForm)
e1.grid(row=0, column=1)
e2.grid(row=2, column=1)

tk.Button(myForm, text='Calculate', command=Show_results).grid(row=4,
                                                               column=0,
                                                               sticky=tk.W,
                                                               pady=4)
tk.Button(myForm, text='Exit', command=myForm.quit).grid(row=4,
                                                         column=1,
                                                         sticky=tk.W,
                                                         pady=4)
tk.mainloop()