@@ -54,8 +54,8 @@ def term_frequency(term : str, document : str) -> int:
54
54
>>> term_frequency("to", "To be, or not to be")
55
55
2
56
56
57
- >>> document = "Natural Language Processing is a subfield of
58
- Artificial Intelligence concerned with interactions
57
+ >>> document = "Natural Language Processing is a subfield of \
58
+ Artificial Intelligence concerned with interactions \
59
59
between computers and human languages"
60
60
>>> term = "NLP"
61
61
0
@@ -80,7 +80,7 @@ def document_frequency(term: str, corpus: str) -> int:
80
80
@returns : the number of documents in the corpus that contain the term you are
81
81
searching for and the number of documents in the corpus
82
82
@examples :
83
- >>> corpus =
83
+ >>> corpus = \
84
84
"This is the first document in the corpus.\n
85
85
ThIs is the second document in the corpus.\n
86
86
THIS is the third document in the corpus."
@@ -102,7 +102,7 @@ def document_frequency(term: str, corpus: str) -> int:
102
102
return document_frequency , len (documents )
103
103
104
104
105
- def inverse_document_frequency (df : int , N : int ) -> int :
105
+ def inverse_document_frequency (df : int , N : int ) -> float :
106
106
"""
107
107
A function that returns an integer denoting the importance
108
108
of a word. This measure of importance is
@@ -128,7 +128,7 @@ def inverse_document_frequency(df : int, N: int) -> int:
128
128
print ("The term you searched for is not in the corpus." )
129
129
130
130
131
- def tf_idf (tf : int , idf : int ) -> int :
131
+ def tf_idf (tf : int , idf : int ) -> float :
132
132
"""
133
133
A function that combines the term frequency
134
134
and inverse document frequency functions to
0 commit comments