@@ -39,7 +39,7 @@ def test_call_method(self, tfidf_encoder):
39
39
isinstance (sublist , list ) for sublist in result
40
40
), "Each item in result should be a list"
41
41
42
- def test_call_method_no_docs (self , tfidf_encoder ):
42
+ def test_call_method_no_docs_tfidf (self , tfidf_encoder ):
43
43
with pytest .raises (ValueError ):
44
44
tfidf_encoder ([])
45
45
@@ -60,3 +60,26 @@ def test_call_method_no_word(self, tfidf_encoder):
60
60
def test_call_method_with_uninitialized_model (self , tfidf_encoder ):
61
61
with pytest .raises (ValueError ):
62
62
tfidf_encoder (["test" ])
63
+
64
+ def test_call_method_no_docs (self , tfidf_encoder ):
65
+ with pytest .raises (ValueError , match = "No documents to encode." ):
66
+ tfidf_encoder ([])
67
+
68
+ def test_compute_tf_no_word_index (self , tfidf_encoder ):
69
+ with pytest .raises (ValueError , match = "Word index is not initialized." ):
70
+ tfidf_encoder ._compute_tf (["some docs" ])
71
+
72
+ def test_compute_tf_with_word_in_word_index (self , tfidf_encoder ):
73
+ routes = [
74
+ Route (
75
+ name = "test_route" ,
76
+ utterances = ["some docs" , "and more docs" , "and even more docs" ],
77
+ )
78
+ ]
79
+ tfidf_encoder .fit (routes )
80
+ tf = tfidf_encoder ._compute_tf (["some docs" ])
81
+ assert tf .shape == (1 , len (tfidf_encoder .word_index ))
82
+
83
+ def test_compute_idf_no_word_index (self , tfidf_encoder ):
84
+ with pytest .raises (ValueError , match = "Word index is not initialized." ):
85
+ tfidf_encoder ._compute_idf (["some docs" ])
0 commit comments