-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed docker image and perfect file
- Loading branch information
1 parent
0edf0e0
commit 52ae784
Showing
7 changed files
with
74 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,53 @@ | ||
import pickle | ||
from flask import request | ||
from nltk.corpus import stopwords | ||
import re | ||
from nltk.stem.snowball import SnowballStemmer | ||
|
||
def load_models(model_name): | ||
path = '/home/yesimtrinity/technical_test_laura/app/static/models/' + model_name | ||
path = 'static/models/' + model_name | ||
return pickle.load(open(path,'rb')) | ||
|
||
def get_arguments(arg): | ||
return request.args.get(arg, None) | ||
return request.args.get(arg, None) | ||
|
||
def remove_links(text): | ||
return " ".join([' ' if ('http') in word else word for word in text.split()]) | ||
|
||
def remove_stopwords(text): | ||
stop = stopwords.words('spanish') | ||
return ' '.join([word for word in text.split() if word not in (stop)]) | ||
|
||
def remove_mentions(text): | ||
return re.sub(r"\@\w+[,]|\@\w+|[,]\@\w+", " ", text) | ||
|
||
def signs_tweets(text): | ||
signs = re.compile("(\.)|(\;)|(\:)|(\!)|(\?)|(\¿)|(\@)|(\,)|(\")|(\()|(\))|(\[)|(\])|(\d+)|(\¡)") | ||
return signs.sub(' ', text.lower()) | ||
|
||
def remove_hash(text): | ||
return re.sub(r"\#\w+[,]|\#\w+|[,]\#\w+", "", text) | ||
|
||
def spanish_stemmer(x): | ||
stemmer = SnowballStemmer('spanish') | ||
return " ".join([stemmer.stem(word) for word in x.split()]) | ||
|
||
def clean_emoji(x): | ||
emoji_text = re.compile("[" | ||
u"\U0001F600-\U0001F64F" # emoticons | ||
u"\U0001F300-\U0001F5FF" # symbols & pictographs | ||
u"\U0001F680-\U0001F6FF" # transport & map symbols | ||
u"\U0001F1E0-\U0001F1FF" # flags (iOS) | ||
u"\U00002702-\U000027B0" | ||
u"\U000024C2-\U0001F251" | ||
"]+", flags=re.UNICODE) | ||
return emoji_text.sub(r'', x) | ||
|
||
def clean_text(x): | ||
text = remove_links(x) | ||
text = remove_stopwords(x) | ||
text = remove_mentions(x) | ||
text = signs_tweets(x) | ||
text = remove_hash(x) | ||
text = spanish_stemmer(x) | ||
return clean_emoji(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Flask | ||
pandas | ||
sklearn | ||
sklearn | ||
nltk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters