Update env.py
Browse files
env.py
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
|
|
|
|
|
| 1 |
class EmailEnv:
|
| 2 |
def __init__(self):
|
| 3 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def reset(self):
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
def step(self, action):
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
|
| 3 |
class EmailEnv:
|
| 4 |
def __init__(self):
|
| 5 |
+
self.emails = [
|
| 6 |
+
{
|
| 7 |
+
"text": "Meeting at 5 PM, please attend",
|
| 8 |
+
"label": "important",
|
| 9 |
+
"reply": "Sure, I will attend the meeting."
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"text": "Congratulations! You won a lottery",
|
| 13 |
+
"label": "spam",
|
| 14 |
+
"reply": "This looks like spam."
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"text": "Can you send the report by tonight?",
|
| 18 |
+
"label": "important",
|
| 19 |
+
"reply": "Sure, I will send the report tonight."
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"text": "Lunch tomorrow?",
|
| 23 |
+
"label": "normal",
|
| 24 |
+
"reply": "Sounds good!"
|
| 25 |
+
}
|
| 26 |
+
]
|
| 27 |
|
| 28 |
def reset(self):
|
| 29 |
+
self.current = random.choice(self.emails)
|
| 30 |
+
return {"text": self.current["text"]}
|
| 31 |
|
| 32 |
def step(self, action):
|
| 33 |
+
reward = 0.0
|
| 34 |
+
|
| 35 |
+
if action["label"] == self.current["label"]:
|
| 36 |
+
reward += 0.5
|
| 37 |
+
|
| 38 |
+
if action["reply"] == self.current["reply"]:
|
| 39 |
+
reward += 0.5
|
| 40 |
+
|
| 41 |
+
return reward
|