Skip to content

Commit e8890d6

Browse files
committed
Corrected doctests
1 parent 1152edd commit e8890d6

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

machine_learning/word_frequency_functions.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ def term_frequency(term : str, document : str) -> int:
5353
>>> document = "To be, or not to be"
5454
>>> term_frequency("to", "To be, or not to be")
5555
2
56-
57-
>>> document = "Natural Language Processing is a subfield of \
58-
Artificial Intelligence concerned with interactions \
59-
between computers and human languages"
60-
>>> term = "NLP"
61-
0
6256
"""
6357
# strip all punctuation and newlines and replace it with ''
6458
document_without_punctuation = document.translate(
@@ -81,8 +75,8 @@ def document_frequency(term: str, corpus: str) -> int:
8175
searching for and the number of documents in the corpus
8276
@examples :
8377
>>> corpus = \
84-
"This is the first document in the corpus.\n
85-
ThIs is the second document in the corpus.\n
78+
"This is the first document in the corpus.\n \
79+
ThIs is the second document in the corpus.\n \
8680
THIS is the third document in the corpus."
8781
>>> term = "first"
8882
1
@@ -115,9 +109,9 @@ def inverse_document_frequency(df : int, N: int) -> float:
115109
@examples :
116110
>>> df = 1
117111
>>> N = 3
118-
log10(3/1) = .477
112+
.477
119113
>>> df = 3
120-
log10(3/3) = log10(1) = 0
114+
0
121115
>>> df = 0
122116
log10(3/0) -> throws ZeroDivisionError
123117
"""

0 commit comments

Comments
 (0)