def test_calcualte_various_combintations_for_correctly_spelt_words(self):
		metric_result = calculate("ban", "ban")
		self.assertEqual(metric_result, 0)
		metric_result = calculate("ban", "bane")
		self.assertEqual(metric_result, 0.3333333333333333)
		metric_result = calculate("ban", "band")
		self.assertEqual(metric_result, 0.3333333333333333)
		metric_result = calculate("ban", "bat")
		self.assertEqual(metric_result, 0.75)
		metric_result = calculate("ban", "bands")
		self.assertEqual(metric_result, 1.3333333333333335)
		metric_result = calculate("ban", "banana")
		self.assertEqual(metric_result, 2.0)
		metric_result = calculate("ban", "bandana")
		self.assertEqual(metric_result, 2.3333333333333335)
		metric_result = calculate("ban", "bandit")
		self.assertEqual(metric_result, 3.0)
		metric_result = calculate("ban", "bandage")
		self.assertEqual(metric_result, 4.666666666666667)
Пример #2
0
 def test_calcualte_various_combintations_for_correctly_spelt_words(self):
     metric_result = calculate("ban", "ban")
     self.assertEqual(metric_result, 0)
     metric_result = calculate("ban", "bane")
     self.assertEqual(metric_result, 0.3333333333333333)
     metric_result = calculate("ban", "band")
     self.assertEqual(metric_result, 0.3333333333333333)
     metric_result = calculate("ban", "bat")
     self.assertEqual(metric_result, 0.75)
     metric_result = calculate("ban", "bands")
     self.assertEqual(metric_result, 1.3333333333333335)
     metric_result = calculate("ban", "banana")
     self.assertEqual(metric_result, 2.0)
     metric_result = calculate("ban", "bandana")
     self.assertEqual(metric_result, 2.3333333333333335)
     metric_result = calculate("ban", "bandit")
     self.assertEqual(metric_result, 3.0)
     metric_result = calculate("ban", "bandage")
     self.assertEqual(metric_result, 4.666666666666667)
	def test_calcualte_various_combintations_for_incorrectly_spelt_words(self):
		metric_result = calculate("piccadilly", "piccadilly")
		self.assertEqual(metric_result, 0)
		metric_result = calculate("piccadilyl", "piccadilly")
		self.assertEqual(metric_result, 0.25)
		metric_result = calculate("piccadlily", "piccadilly")
		self.assertEqual(metric_result, 0.33333333333333337)
		metric_result = calculate("picacdilly", "piccadilly")
		self.assertEqual(metric_result, 0.4)
		metric_result = calculate("picadily", "piccadilly")
		self.assertEqual(metric_result, 0.5)
		metric_result = calculate("picacdlily", "piccadilly")
		self.assertEqual(metric_result, 1.3333333333333335)
		metric_result = calculate("ipcacdily", "piccadilly")
		self.assertEqual(metric_result, 1.4814814814814814)
		metric_result = calculate("pcicadlyil", "piccadilly")
		self.assertEqual(metric_result, 2.0)
Пример #4
0
 def test_calcualte_various_combintations_for_incorrectly_spelt_words(self):
     metric_result = calculate("piccadilly", "piccadilly")
     self.assertEqual(metric_result, 0)
     metric_result = calculate("piccadilyl", "piccadilly")
     self.assertEqual(metric_result, 0.25)
     metric_result = calculate("piccadlily", "piccadilly")
     self.assertEqual(metric_result, 0.33333333333333337)
     metric_result = calculate("picacdilly", "piccadilly")
     self.assertEqual(metric_result, 0.4)
     metric_result = calculate("picadily", "piccadilly")
     self.assertEqual(metric_result, 0.5)
     metric_result = calculate("picacdlily", "piccadilly")
     self.assertEqual(metric_result, 1.3333333333333335)
     metric_result = calculate("ipcacdily", "piccadilly")
     self.assertEqual(metric_result, 1.4814814814814814)
     metric_result = calculate("pcicadlyil", "piccadilly")
     self.assertEqual(metric_result, 2.0)
Пример #5
0
def perform_metric_calculation():

    parser = argparse.ArgumentParser(
        description='Calculate the similarity of 2 words using the Ozbay metric'
    )
    parser.add_argument("base",
                        type=str,
                        help="The first word to be compared with")
    parser.add_argument("term",
                        type=str,
                        help="The second word to be compared with")

    args = parser.parse_args()

    result = calculate(args.base, args.term)

    print("The result of comparing %s with %s is: %s" %
          (args.base, args.term, result))
	def test_calculate_match_ignore_case_sensitivity(self):
		metric_result = calculate("SERVICE", "service")
		self.assertEqual(metric_result, 0)
		metric_result = calculate("service", "SERVICE")
		self.assertEqual(metric_result, 0)
	def test_calculate_exact_match(self):
		metric_result = calculate("ban", "ban")
		self.assertEqual(metric_result, 0)
Пример #8
0
 def test_calculate_match_ignore_case_sensitivity(self):
     metric_result = calculate("SERVICE", "service")
     self.assertEqual(metric_result, 0)
     metric_result = calculate("service", "SERVICE")
     self.assertEqual(metric_result, 0)
Пример #9
0
 def test_calculate_exact_match(self):
     metric_result = calculate("ban", "ban")
     self.assertEqual(metric_result, 0)