Skip to content

Commit 3a3f30c

Browse files
committed
Cleared All Dependencies
1 parent e0f24f2 commit 3a3f30c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

machine_learning/cosine_similarity.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Computations.
2222
"""
2323

24+
nlp = spacy.load('en_core_web_md')
2425

2526
class CosineSimilarity:
2627
def __init__(self) -> None:
@@ -32,8 +33,7 @@ def __init__(self) -> None:
3233
>>> isinstance(cs.nlp, spacy.lang.en.English)
3334
True
3435
"""
35-
spacy.cli.download("en_core_web_md")
36-
self.nlp = spacy.load("en_core_web_md")
36+
self.nlp = nlp
3737

3838
def tokenize(self, text: str) -> list:
3939
"""
@@ -234,11 +234,5 @@ def cosine_similarity_percentage(self, text1: str, text2: str) -> float:
234234
"""
235235
Main function to Test the Cosine Similarity between two Texts.
236236
"""
237-
text1 = "The biggest Infrastructure in the World is Burj Khalifa"
238-
text2 = "The name of the tallest Tower in the world is Burj Khalifa"
239-
240-
spacy.cli.download("en_core_web_md") # Comment if Installed
241-
similarity_percentage = CosineSimilarity().cosine_similarity_percentage(
242-
text1, text2
243-
)
244-
print(f"Cosine Similarity: {similarity_percentage:.2f}%")
237+
import doctest
238+
doctest.testmod() # Run the Doctests

0 commit comments

Comments
 (0)