Skip to content

Commit

Permalink
Beleza
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaloney111 committed Jun 11, 2024
1 parent 894ac22 commit ca08a18
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 51,017 deletions.
6 changes: 3 additions & 3 deletions api/DataProcesser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ def handle_classify(self, df, classifier):

def get_pipeline(self, model_name):
if model_name=="emotion_pipeline.pkl":
df = pd.read_csv('src/assets/tweet_emotions.csv')
df = pd.read_csv('assets/tweet_emotions.csv')
train_data, test_data, train_target, test_target = train_test_split(df['content'], df['sentiment'], test_size=0.2, shuffle=True)
elif model_name=="hate_speech.pkl":
df = pd.read_csv('src/assets/nb_hatespeech.csv', sep=';')
df = pd.read_csv('assets/nb_hatespeech.csv', sep=';')
train_data, test_data, train_target, test_target = train_test_split(df['comment'], df['isHate'], test_size=0.2, shuffle=True)
elif model_name=="text_classification_pipeline.pkl":
df = pd.read_csv('src/assets/nb_news.csv')
df = pd.read_csv('assets/nb_news.csv')
train_data, test_data, train_target, test_target = train_test_split(df['short_description'], df['category'], test_size=0.2, shuffle=True)
else:
with open(f'api/models/{model_name}', 'rb') as file:
Expand Down
6 changes: 3 additions & 3 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def upload_file():

@app.route('/get-classifiers', methods=["GET"])
def get_classifiers():
print(build_tree('..'))
print(build_tree('.'))
classifiers = get_available_classifiers()
return jsonify(build_tree('../..')) # should be classifiers but testing for now
return jsonify(classifiers)

def build_tree(directory, indent='', d=0):
"""
Recursively build directory tree structure as a string.
"""
if d == 3:
if d == 6:
return ''

tree = indent + os.path.basename(directory) + '/' + '\n'
Expand Down
4 changes: 2 additions & 2 deletions api/available_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ def get_available_classifiers():

# Verifica se o diretório 'models' existe
if not model_folder:
return []
return {}

# Obtém a lista de arquivos no diretório 'models'
model_files = os.listdir(model_folder)
classifiers = {}
classifiers = {0 : "emotion_pipeline.pkl", 1 : "hate_speech.pkl", 2 : "text_classification_pipeline.pkl"}

for file in model_files:
classifiers[len(classifiers)] = file
Expand Down
Loading

0 comments on commit ca08a18

Please sign in to comment.