File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change
1
+ import sys
1
2
from textblob import TextBlob
2
3
import nltk
3
4
from nltk .sentiment .vader import SentimentIntensityAnalyzer
10
11
ssl ._create_default_https_context = _ctx
11
12
12
13
13
- nltk .download ("vader_lexicon" )
14
- nltk .download ("punkt" )
14
+ def setup ():
15
+ file_path = sys .argv [1 ] if len (sys .argv ) > 1 else setup_utils .get_default_config_file_path ()
16
+ config = setup_utils .get_config (file_path )
17
+ download_dir = None
18
+ if "nltk" in config :
19
+ nltk_config = config ["nltk" ]
20
+ download_dir = nltk_config .get ("NLTK_DOWNLOAD_PATH" )
21
+ if "NLTK_PROXY" in nltk_config :
22
+ nltk .set_proxy (nltk_config ["NLTK_PROXY" ])
23
+
24
+ nltk .download ("vader_lexicon" , download_dir = download_dir )
25
+ nltk .download ("punkt" , download_dir = download_dir )
15
26
16
27
17
28
def SentimentAnalysis (_arg1 , library = "nltk" ):
@@ -45,6 +56,7 @@ def SentimentAnalysis(_arg1, library="nltk"):
45
56
46
57
47
58
if __name__ == "__main__" :
59
+ setup ()
48
60
setup_utils .deploy_model (
49
61
"Sentiment Analysis" ,
50
62
SentimentAnalysis ,
You can’t perform that action at this time.
0 commit comments