Skip to content

Commit

Permalink
adjustments to functions to make them accessible to AI classifier code
Browse files Browse the repository at this point in the history
  • Loading branch information
gicraveiro committed Feb 8, 2022
1 parent d9e6552 commit bb7c7ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 2 additions & 8 deletions partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@
import matplotlib.pyplot as plt
import numpy
import spacy
from utils import clean_corpus, reconstruct_hyphenated_words
from utils import clean_corpus, reconstruct_hyphenated_words, create_sent_label_dict

# Functions

# Creates dictionary of a set, associating sentence with label
def create_sent_label_dict(sents, labels):
sents_dict = []
for row_id,row in enumerate(sents):
row = re.sub("\n", " ", row)
sents_dict.append({"text":row.strip(), "label":labels[row_id]})
return sents_dict


# Writes json of partition set, each entry is the sentence associated with its labels
def write_partition_file(partition_dict, name):
Expand Down
6 changes: 3 additions & 3 deletions simpleclassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def simple_classifier(sents_ref_json):
test_pred_dict = simple_classifier(test_sents_ref_json)

# Output predictions in separate files
write_predictions_file("Train", train_pred_dict)
write_predictions_file("Dev", dev_pred_dict)
write_predictions_file("Test", test_pred_dict)
write_predictions_file(train_pred_dict, 'output/Simple Classifier/multilabelPredictions_Train.json')
write_predictions_file(dev_pred_dict,'output/Simple Classifier/multilabelPredictions_Dev.json')
write_predictions_file(test_pred_dict, 'output/Simple Classifier/multilabelPredictions_Test.json')

# Formatting predictions to calculate results
train_pred_array = [sent['label'] for sent in train_pred_dict]
Expand Down

0 comments on commit bb7c7ba

Please sign in to comment.