Skip to content

Commit 1152edd

Browse files
committed
Add line escapes and change int to float
1 parent 9ef8e62 commit 1152edd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

machine_learning/word_frequency_functions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def term_frequency(term : str, document : str) -> int:
5454
>>> term_frequency("to", "To be, or not to be")
5555
2
5656
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 \
5959
between computers and human languages"
6060
>>> term = "NLP"
6161
0
@@ -80,7 +80,7 @@ def document_frequency(term: str, corpus: str) -> int:
8080
@returns : the number of documents in the corpus that contain the term you are
8181
searching for and the number of documents in the corpus
8282
@examples :
83-
>>> corpus =
83+
>>> corpus = \
8484
"This is the first document in the corpus.\n
8585
ThIs is the second document in the corpus.\n
8686
THIS is the third document in the corpus."
@@ -102,7 +102,7 @@ def document_frequency(term: str, corpus: str) -> int:
102102
return document_frequency, len(documents)
103103

104104

105-
def inverse_document_frequency(df : int, N: int) -> int:
105+
def inverse_document_frequency(df : int, N: int) -> float:
106106
"""
107107
A function that returns an integer denoting the importance
108108
of a word. This measure of importance is
@@ -128,7 +128,7 @@ def inverse_document_frequency(df : int, N: int) -> int:
128128
print("The term you searched for is not in the corpus.")
129129

130130

131-
def tf_idf(tf : int, idf: int) -> int:
131+
def tf_idf(tf : int, idf: int) -> float:
132132
"""
133133
A function that combines the term frequency
134134
and inverse document frequency functions to

0 commit comments

Comments
 (0)