-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (42 loc) · 1.3 KB
/
main.py
File metadata and controls
53 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from typing import List, Any
from modelwork import (
clean_html,
remove_spec_char,
simple_stemmer,
remove_stop_words,
load_model,
load_vectorizer,
predict,
)
from huggingface_hub import hf_hub_download
def run_preprocessing_pipeline(text: str, functions: List[Any]) -> str:
for function in functions:
text = function(text)
return text
def run_predict(text):
preprocessing_functions = [
clean_html,
remove_spec_char,
simple_stemmer,
remove_stop_words,
]
processed_text = run_preprocessing_pipeline(text, preprocessing_functions)
model = load_model(
hf_hub_download(
repo_id="dsdevnull/mn_bays_tfidf_sentiment_analysis",
local_dir="models",
filename="mn_bays_tfidf_sentiment_analysis.pkl",
)
)
vectorizer = load_vectorizer(
hf_hub_download(
repo_id="dsdevnull/mn_bays_tfidf_sentiment_analysis",
local_dir="models",
filename="tfidf_vectorizer.pickle",
)
)
result = predict(processed_text, model, vectorizer)
print(result)
if __name__ == "__main__":
input_text = "this show was garbage i am surprised it was approved. Next time the main character should do the right thing"
run_predict(input_text)