Create inference.py
Browse files- inference.py +22 -0
inference.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from env import EmailEnv
|
| 2 |
+
|
| 3 |
+
env = EmailEnv()
|
| 4 |
+
|
| 5 |
+
def predict():
|
| 6 |
+
email = env.reset()
|
| 7 |
+
text = email["text"]
|
| 8 |
+
|
| 9 |
+
if "meeting" in text.lower():
|
| 10 |
+
action = {"label": "important", "reply": "Sure, I will attend the meeting."}
|
| 11 |
+
elif "lottery" in text.lower():
|
| 12 |
+
action = {"label": "spam", "reply": "This looks like spam."}
|
| 13 |
+
else:
|
| 14 |
+
action = {"label": "normal", "reply": "Sounds good!"}
|
| 15 |
+
|
| 16 |
+
reward = env.step(action)
|
| 17 |
+
|
| 18 |
+
return {
|
| 19 |
+
"email": text,
|
| 20 |
+
"action": action,
|
| 21 |
+
"reward": reward
|
| 22 |
+
}
|