Skip to content
Snippets Groups Projects
Commit f1a0b830 authored by Hsien-Chin Lin's avatar Hsien-Chin Lin
Browse files

wip

parent 4f29a554
Branches
No related tags found
No related merge requests found
...@@ -65,6 +65,13 @@ class Evaluator: ...@@ -65,6 +65,13 @@ class Evaluator:
self.r["golden_sentiment"] = [] self.r["golden_sentiment"] = []
self.r["gen_sentiment"] = [] self.r["gen_sentiment"] = []
sent2emo = json.load(
open("convlab/policy/emoTUS/sent2emo.json"))
self.emo2sent = {}
for sent, emotions in sent2emo.items():
for emo in emotions:
self.emo2sent[emo] = sent
def _append_result(self, temp): def _append_result(self, temp):
for x in self.r: for x in self.r:
self.r[x].append(temp[x]) self.r[x].append(temp[x])
...@@ -241,6 +248,15 @@ class Evaluator: ...@@ -241,6 +248,15 @@ class Evaluator:
self.r["gen_sentiment"], self.r["gen_sentiment"],
self.model_checkpoint, self.model_checkpoint,
time=self.time) time=self.time)
else:
# transfer emotions to sentiment if the model do not generate sentiment
golden_sentiment = [self.emo2sent[emo] for emo in golden_emotions]
gen_sentiment = [self.emo2sent[emo] for emo in gen_emotions]
sent_score = sentiment_score(
golden_sentiment,
gen_sentiment,
self.model_checkpoint,
time=self.time)
# for metric in emo_score: # for metric in emo_score:
# result[metric] = emo_score[metric] # result[metric] = emo_score[metric]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment