jaifar530 commited on
Commit
fa5527f
·
unverified ·
1 Parent(s): 6995f13
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -20,6 +20,7 @@ import numpy as np
20
  from nltk.stem import WordNetLemmatizer
21
  from nltk import ne_chunk, pos_tag, word_tokenize
22
  from nltk.tree import Tree
 
23
  nltk.download('wordnet')
24
  nltk.download('maxent_ne_chunker')
25
  nltk.download('words')
@@ -30,22 +31,26 @@ nltk.download('stopwords')
30
  nltk.download('averaged_perceptron_tagger')
31
 
32
  # Check if the file exists
33
- if not os.path.isfile('RandomForestClassifier.pkl'):
34
- # Download the zip file if it doesn't exist
35
- url = 'https://jaifar.net/RandomForestClassifier.pkl'
36
  headers = {
37
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
38
  }
39
 
40
  response = requests.get(url, headers=headers)
41
 
42
- # Save the file
43
- with open('RandomForestClassifier.pkl', 'wb') as file:
44
  file.write(response.content)
45
 
46
- # At this point, the pickle file should exist, either it was already there, or it has been downloaded and extracted.
47
- with open('RandomForestClassifier.pkl', 'rb') as file:
48
- clf_loaded = pickle.load(file)
 
 
 
 
49
 
50
  input_paragraph = st.text_area("Input your text here")
51
  words_counts = word_tokenize(input_paragraph)
 
20
  from nltk.stem import WordNetLemmatizer
21
  from nltk import ne_chunk, pos_tag, word_tokenize
22
  from nltk.tree import Tree
23
+ from joblib import dump, load
24
  nltk.download('wordnet')
25
  nltk.download('maxent_ne_chunker')
26
  nltk.download('words')
 
31
  nltk.download('averaged_perceptron_tagger')
32
 
33
  # Check if the file exists
34
+ if not os.path.isfile('RandomForestClassifier.joblib'):
35
+
36
+ url = 'https://jaifar.net/RandomForestClassifier.joblib'
37
  headers = {
38
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
39
  }
40
 
41
  response = requests.get(url, headers=headers)
42
 
43
+
44
+ with open('RandomForestClassifier.joblib', 'wb') as file:
45
  file.write(response.content)
46
 
47
+
48
+ # Load the model from the file
49
+ clf_loaded = load('RandomForestClassifier.joblib')
50
+
51
+ # # At this point, the pickle file should exist, either it was already there, or it has been downloaded and extracted.
52
+ # with open('RandomForestClassifier.pkl', 'rb') as file:
53
+ # clf_loaded = pickle.load(file)
54
 
55
  input_paragraph = st.text_area("Input your text here")
56
  words_counts = word_tokenize(input_paragraph)