diff --git a/src/Backend/ml_approach/classify.py b/src/Backend/ml_approach/classify.py index a8644bae..e8a48d82 100644 --- a/src/Backend/ml_approach/classify.py +++ b/src/Backend/ml_approach/classify.py @@ -78,8 +78,6 @@ def evaluate(sentences, prepared_sentences, classification_results, obj_a, obj_b if len(sentences) > 0: max_sentscore = max(sentence.score for sentence in sentences) - print(max_sentscore) - counts = count_confindences( prepared_sentences, classification_results, aspects) threshold_sentences = find_threshold(counts, 5) @@ -98,7 +96,8 @@ def evaluate(sentences, prepared_sentences, classification_results, obj_a, obj_b sentence = s break sentences.remove(sentence) - + sentence.set_confidence(classification_confidence.item()) + contained_aspects = find_aspects(sentence.text, aspects) if (label == 'BETTER' and row['object_a'] == obj_a.name) or (label == 'WORSE' and row['object_b'] == obj_a.name): add_points(contained_aspects, obj_a, sentence, diff --git a/src/Backend/utils/answer_preparation.py b/src/Backend/utils/answer_preparation.py index 56e95b82..3bfa6d15 100644 --- a/src/Backend/utils/answer_preparation.py +++ b/src/Backend/utils/answer_preparation.py @@ -72,7 +72,9 @@ def add_points(contained_aspects, winner, sentence, max_score, classification_sc aspect = contained_aspects[0] points = score_function( sentence.score, max_score, aspect.weight, classification_score, threshold_sentences) - if classification_score > threshold_score: + if classification_score < threshold_score: + winner.add_points(aspect.name, (points/10) * document_occurences) + else: winner.add_points(aspect.name, points * document_occurences) winner.add_sentence([points, sentence]) else: diff --git a/src/Backend/utils/objects.py b/src/Backend/utils/objects.py index 475792fd..5cabc62d 100644 --- a/src/Backend/utils/objects.py +++ b/src/Backend/utils/objects.py @@ -7,10 +7,14 @@ def __init__(self, text, score, document_id, sentence_id): self.text = text self.score = score self.id_pair = {document_id: sentence_id} + self.confidence = 0 def add_id_pair(self, document_id, sentence_id): self.id_pair[document_id] = sentence_id + def set_confidence(self, confidence): + self.confidence = confidence + class Argument: '''