forked from yashspr/sentiment_analysis_ml_part
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
26 lines (20 loc) · 756 Bytes
/
main.py
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
import spacy
from spacy.pipeline import Sentencizer
import pandas as pd
from preprocess import preprocess, construct_spacy_obj
import ft
import train
from feature_extraction import feature_extraction
from classifiation import classify
nlp = spacy.load('en_core_web_sm')
sentencizer = Sentencizer(punct_chars=[".", "!", "?", "\n", "\r", ";"])
nlp.add_pipe(sentencizer)
ft_model = ft.get_model()
model = train.get_model(nlp, ft_model)
def get_features_and_classification(filename):
df = pd.read_csv("csv_files/" + filename, header=None, names=['reviewText', 'rating'])
df = preprocess(df, nlp)
df = construct_spacy_obj(df, nlp)
features = feature_extraction(df, ft_model, nlp)
result, _, __ = classify(df, features, model)
return features, result