-
Notifications
You must be signed in to change notification settings - Fork 0
/
cot_state.py
32 lines (28 loc) · 1.64 KB
/
cot_state.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class ChainOfThoughtState:
""" We consider {context} with the {target} as utterance
that experience emotion. This chain of thought help
with reasoning on the potential sources (texts spans, i.e. utterances) of the
emotion that causes and results in state of the {target}.
"""
@staticmethod
def prompt_for_span_inferring(context, target):
new_context = f'Given the conversation "{context}", '
prompt = new_context + f'which text spans are possibly causes emotion on {target} ?'
return new_context, prompt
@staticmethod
def prompt_for_opinion_inferring(context, target, aspect_expr):
new_context = context + ' The mentioned text spans are about ' + aspect_expr + '.'
prompt = new_context + f' Based on the common sense, ' \
f'what is the implicit opinion towards the mentioned text spans that causes emotion on {target}, and why?'
return new_context, prompt
@staticmethod
def prompt_for_emotion_inferring(context, target, opinion_expr):
new_context = context + f' The opinion towards the text spans that causes emotion on {target} is ' + opinion_expr + '.'
prompt = new_context + f' Based on such opinion, what is the emotion state of {target}?'
return new_context, prompt
@staticmethod
def prompt_for_emotion_label(context, polarity_expr, label_list):
prompt = context + f' The emotion state is {polarity_expr}.' + \
" Based on these contexts, summarize and return the emotion cause only." + \
" Choose from: {}.".format(", ".join(label_list))
return prompt