コード例 #1
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_find_from_file_returns_tuple_of_matching_words(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="organization", file_name="../sample/organizations.list")
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		result1 = lookupTable.find_from_file(feature="organization", file_name="../sample/sample2.txt")
		result2 = lookupTable.find_from_file(feature="name", file_name="../sample/sample2.txt")
		self.assertTrue(result1==("facebook",) and result2==("Jithin", "aneesh",))
コード例 #2
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_find_returns_tuple_of_matching_words(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="organization", file_name="../sample/organizations.list")
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		result1 = lookupTable.find(feature="organization", text="Hello Jithin, where is aneesh?. Is facebook down?")
		result2 = lookupTable.find(feature="name", text="Hello Jithin/aneesh?. Is facebook down?")
		self.assertTrue(result1==("facebook",) and result2==("Jithin", "aneesh",))
コード例 #3
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_find_all_returns_list_of_tuples_maping_word_with_feature(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="organization", file_name="../sample/organizations.list")
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		result = lookupTable.find_all(text="Hello Jithin, where is aneesh?. Is facebook down?")
		self.assertEqual(result, [("facebook", "organization"), ("Jithin", "name"), ("aneesh", "name"), ])
コード例 #4
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_matching_tokens_returns_list_of_tokens_matching_specified_lookup(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		tokens = ["Hello", "Jithin", "where", "is", "aneesh", "Is", "facebook", "down"]
		result = lookupTable._matching_tokens(feature="name", tokens=tokens)
		self.assertEqual(result, ("Jithin", "aneesh",))
コード例 #5
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_find_from_file_raises_value_error_if_file_given_is_invalid(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		self.assertRaises(IOError, lookupTable.find_from_file, feature="name", file_name="../sample/unavailable.txt")
コード例 #6
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_find_raises_value_error_if_feature_not_exists(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		self.assertRaises(KeyError, lookupTable.find, feature="fruit", text="Hello Jithin, where is aneesh?")
コード例 #7
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_find_returns_list_of_tuples(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		result = lookupTable.find(feature="name", text="Hello Jithin, where is aneesh?")
		self.assertEqual(result, ("Jithin", "aneesh"))
コード例 #8
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test__load_lookup_returns_true_if_loading_lookup_from_file_success(self):
		lookupTable = LookUpTable()
		result = lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		self.assertTrue(result)
コード例 #9
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test__load_lookup_raises_value_error_if_feature_already_exists(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		self.assertRaises(KeyError, lookupTable._load_lookup, "name", "../sample/names.list")
コード例 #10
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_available_features_returns_list_of_features_added(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="organization", file_name="../sample/organizations.list")
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		result = lookupTable.available_features()
		self.assertEqual(result, ["organization", "name"])
コード例 #11
0
ファイル: test_lookup_table.py プロジェクト: jithinoc/parrot
	def test_match_returns_true_if_word_is_a_feature(self):
		lookupTable = LookUpTable()
		lookupTable._load_lookup(feature="organization", file_name="../sample/organizations.list")
		lookupTable._load_lookup(feature="name", file_name="../sample/names.list")
		self.assertTrue(lookupTable._match(feature="name", word="Akhil"))