sdutta28 commited on
Commit
e788caa
1 Parent(s): fb2e1cb
Files changed (5) hide show
  1. app.py +0 -5
  2. get_predictions.py +0 -4
  3. requirements.txt +10 -52
  4. requirements.txt.bk +53 -0
  5. utils.py +13 -2
app.py CHANGED
@@ -2,11 +2,6 @@
2
  from get_predictions import get_predictions
3
  import gradio
4
 
5
- """
6
- @todo refactor code + fix nltk download
7
- @body change file directory,
8
- """
9
-
10
 
11
  if __name__ == "__main__":
12
  interface = gradio.Interface(
 
2
  from get_predictions import get_predictions
3
  import gradio
4
 
 
 
 
 
 
5
 
6
  if __name__ == "__main__":
7
  interface = gradio.Interface(
get_predictions.py CHANGED
@@ -18,7 +18,3 @@ def get_predictions(text: str) -> tuple:
18
  pred_2 = model_2.predict(cleaned_data)[0]
19
 
20
  return (utils.TASK_1_MAP[pred_1], utils.TASK_2_MAP[pred_2])
21
-
22
-
23
- if __name__ == "__main__":
24
- print(get_predictions("Hello"))
 
18
  pred_2 = model_2.predict(cleaned_data)[0]
19
 
20
  return (utils.TASK_1_MAP[pred_1], utils.TASK_2_MAP[pred_2])
 
 
 
 
requirements.txt CHANGED
@@ -1,53 +1,11 @@
1
- #
2
- # These requirements were autogenerated by pipenv
3
- # To regenerate from the project's Pipfile, run:
4
- #
5
- # pipenv lock --requirements
6
- #
7
-
8
- -i https://pypi.org/simple
9
- analytics-python==1.4.0
10
- backoff==1.10.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
11
- bcrypt==3.2.0; python_version >= '3.6'
12
- certifi==2021.10.8
13
- cffi==1.15.0
14
- charset-normalizer==2.0.10; python_version >= '3'
15
- click==8.0.3; python_version >= '3.6'
16
- cryptography==36.0.1; python_version >= '3.6'
17
- cycler==0.11.0; python_version >= '3.6'
18
- ffmpy==0.3.0
19
- flask-cachebuster==1.0.0
20
- flask-cors==3.0.10
21
- flask-login==0.5.0
22
- flask==2.0.2; python_version >= '3.6'
23
- fonttools==4.28.5; python_version >= '3.7'
24
  gradio==2.7.0
25
- idna==3.3; python_version >= '3'
26
- itsdangerous==2.0.1; python_version >= '3.6'
27
- jinja2==3.0.3; python_version >= '3.6'
28
- joblib==1.0.1
29
- kiwisolver==1.3.2; python_version >= '3.7'
30
- markdown2==2.4.2; python_version >= '3.5' and python_version < '4'
31
- markupsafe==2.0.1; python_version >= '3.6'
32
- matplotlib==3.5.1; python_version >= '3.7'
33
- monotonic==1.6
34
- nltk==3.2.5
35
- numpy==1.19.5
36
- packaging==21.3; python_version >= '3.6'
37
- pandas==1.4.0rc0; python_version >= '3.8'
38
- paramiko==2.9.2
39
- pillow==9.0.0; python_version >= '3.7'
40
- pycparser==2.21
41
- pycryptodome==3.12.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
42
- pydub==0.25.1
43
- pynacl==1.5.0; python_version >= '3.6'
44
- pyparsing==3.0.6; python_version >= '3.6'
45
- python-dateutil==2.8.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
46
- pytz==2021.3
47
- requests==2.27.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
48
- scikit-learn==0.22.2.post1
49
- scipy==1.8.0rc2; python_version < '3.11' and python_version >= '3.8'
50
- six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
51
- urllib3==1.26.8; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
52
- werkzeug==2.0.2; python_version >= '3.6'
53
- xgboost==0.90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  gradio==2.7.0
2
+ xgboost==0.90
3
+ numpy
4
+ pandas
5
+ matplotlib
6
+ flask
7
+ jinja2
8
+ pillow
9
+ nltk
10
+ joblib
11
+ sklearn
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt.bk ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # These requirements were autogenerated by pipenv
3
+ # To regenerate from the project's Pipfile, run:
4
+ #
5
+ # pipenv lock --requirements
6
+ #
7
+
8
+ -i https://pypi.org/simple
9
+ analytics-python==1.4.0
10
+ backoff==1.10.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
11
+ bcrypt==3.2.0; python_version >= '3.6'
12
+ certifi==2021.10.8
13
+ cffi==1.15.0
14
+ charset-normalizer==2.0.10; python_version >= '3'
15
+ click==8.0.3; python_version >= '3.6'
16
+ cryptography==36.0.1; python_version >= '3.6'
17
+ cycler==0.11.0; python_version >= '3.6'
18
+ ffmpy==0.3.0
19
+ flask-cachebuster==1.0.0
20
+ flask-cors==3.0.10
21
+ flask-login==0.5.0
22
+ flask==2.0.2; python_version >= '3.6'
23
+ fonttools==4.28.5; python_version >= '3.7'
24
+ gradio==2.7.0
25
+ idna==3.3; python_version >= '3'
26
+ itsdangerous==2.0.1; python_version >= '3.6'
27
+ jinja2==3.0.3; python_version >= '3.6'
28
+ joblib==1.0.1
29
+ kiwisolver==1.3.2; python_version >= '3.7'
30
+ markdown2==2.4.2; python_version >= '3.5' and python_version < '4'
31
+ markupsafe==2.0.1; python_version >= '3.6'
32
+ matplotlib==3.5.1; python_version >= '3.7'
33
+ monotonic==1.6
34
+ nltk==3.2.5
35
+ numpy==1.19.5
36
+ packaging==21.3; python_version >= '3.6'
37
+ pandas==1.4.0rc0; python_version >= '3.8'
38
+ paramiko==2.9.2
39
+ pillow==9.0.0; python_version >= '3.7'
40
+ pycparser==2.21
41
+ pycryptodome==3.12.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
42
+ pydub==0.25.1
43
+ pynacl==1.5.0; python_version >= '3.6'
44
+ pyparsing==3.0.6; python_version >= '3.6'
45
+ python-dateutil==2.8.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
46
+ pytz==2021.3
47
+ requests==2.27.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
48
+ scikit-learn==0.22.2.post1
49
+ scipy==1.8.0rc2; python_version < '3.11' and python_version >= '3.8'
50
+ six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
51
+ urllib3==1.26.8; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
52
+ werkzeug==2.0.2; python_version >= '3.6'
53
+ xgboost==0.90
utils.py CHANGED
@@ -3,7 +3,8 @@ import string
3
  import nltk
4
  import re
5
 
6
- nltk.download("stopwords")
 
7
  # Constants
8
  TASK_1_MODEL = " models/TASK_A_model_final.pkl"
9
  TASK_2_MODEL = " models/TASK_B_model_final.pkl"
@@ -17,9 +18,19 @@ TASK_2_MAP = {
17
  1: "GEN - Misogynistic Content",
18
  }
19
 
 
20
  # Cleans one text
21
  def clean_one_text(text: str) -> str:
22
- # Cleans one text and returns it
 
 
 
 
 
 
 
 
 
23
 
24
  # remove punctuation
25
  filter_str = string.punctuation.replace("'", "")
 
3
  import nltk
4
  import re
5
 
6
+ nltk.download("stopwords", download_dir="./nltk")
7
+
8
  # Constants
9
  TASK_1_MODEL = " models/TASK_A_model_final.pkl"
10
  TASK_2_MODEL = " models/TASK_B_model_final.pkl"
 
18
  1: "GEN - Misogynistic Content",
19
  }
20
 
21
+
22
  # Cleans one text
23
  def clean_one_text(text: str) -> str:
24
+ """
25
+ Cleans one text by removing punctuation, stopwords, and applying stemming.
26
+
27
+ Args:
28
+ text (str): The text to be cleaned.
29
+
30
+ Returns:
31
+ str: The cleaned text.
32
+
33
+ """
34
 
35
  # remove punctuation
36
  filter_str = string.punctuation.replace("'", "")