VarunRavichander commited on
Commit
44bf8a4
·
verified ·
1 Parent(s): 76d6cc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -3,19 +3,21 @@ from enhanced_text_humanizer import EnhancedTextHumanizer
3
  import time
4
  import nltk
5
  import os
 
 
6
 
7
- # Create nltk_data directory in the project
8
- if not os.path.exists('nltk_data'):
9
- os.makedirs('nltk_data')
10
 
11
- # Set NLTK data path to the project directory
12
- nltk.data.path.append(os.path.join(os.getcwd(), 'nltk_data'))
 
 
13
 
14
- # Download required NLTK data
15
- try:
16
- nltk.data.find('tokenizers/punkt')
17
- except LookupError:
18
- nltk.download('punkt')
19
 
20
 
21
  def initialize_humanizer():
 
3
  import time
4
  import nltk
5
  import os
6
+ import nltk
7
+ import os
8
 
9
+ import nltk
10
+ import os
 
11
 
12
+ # Set up NLTK data path
13
+ NLTK_DATA_PATH = os.path.join(os.getcwd(), 'nltk_data')
14
+ os.makedirs(NLTK_DATA_PATH, exist_ok=True)
15
+ nltk.data.path.append(NLTK_DATA_PATH)
16
 
17
+ # Download all required NLTK resources
18
+ resources = ['punkt', 'averaged_perceptron_tagger', 'wordnet', 'omw-1.4']
19
+ for resource in resources:
20
+ nltk.download(resource, quiet=True, download_dir=NLTK_DATA_PATH)
 
21
 
22
 
23
  def initialize_humanizer():