Skip to content

Commit 3cfd680

Browse files
Deprecated UrbanDictionary due to profane results
1 parent 5ad6dde commit 3cfd680

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/MAGIST/NLP/WordScraper.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
from ..Utils.LogMaster.log_init import MainLogger
44

55

6+
class ClassDeprecated(Exception):
7+
pass
8+
9+
610
class UrbanDictionary():
711
def __init__(self, config):
812
"""Initialize the Urban Dictionary API.
913
:param config: The config file(config.json).
1014
"""
1115

16+
raise ClassDeprecated("This class is deprecated")
17+
1218
root_log = MainLogger(config)
1319
self.log = root_log.StandardLogger("UrbanDictionary")
1420

@@ -23,7 +29,7 @@ def define(self, word):
2329
querystring = {"term": word}
2430

2531
headers = {
26-
"X-RapidAPI-Key": "ccb24b8108msh0b3a5c1ef1265b7p197610jsna515c20cf465",
32+
"X-RapidAPI-Key": "xxx",
2733
"X-RapidAPI-Host": "mashape-community-urban-dictionary.p.rapidapi.com"
2834
}
2935

@@ -89,14 +95,13 @@ def __init__(self, config):
8995
root_log = MainLogger(config)
9096
self.log = root_log.StandardLogger("FullDictionarySearch")
9197

92-
self.urban = UrbanDictionary(config)
9398
self.dictdev = DicitonaryAPIDev(config)
9499

95100
def define(self, word):
96101
definition = self.dictdev.define(word)
97102

98103
if definition == "No definition found":
99-
self.log.info("No definition found in DictionaryAPI.dev. Trying UrbanDictionary...")
100-
definition = self.urban.define(word)
104+
self.log.info("No definition found in DictionaryAPI.dev.")
105+
definition = None
101106

102107
return definition

0 commit comments

Comments
 (0)