Spaces:
Running
Running
Ask Andy: a typed fall gets 911 first, then the phone search
Browse files- index.html +5 -1
- scenes/turned.json +0 -0
index.html
CHANGED
|
@@ -834,6 +834,8 @@
|
|
| 834 |
// A health question typed, which matched no scene: what Andy says to it on the robot, its own words, never a model's
|
| 835 |
// (companion/safety.py HEALTH_REPLY; on the robot the rule is wider, and tested)
|
| 836 |
const HEALTH_TYPED = /\b(?:hurts?|aches?|aching|pain|sore|swollen|dizzy|fever|cough|rash|headaches?|migraines?|nause\w*|pills?|tablets?|medicines?|medications?|meds|doses?|tylenol|ibuprofen|aspirin|advil|statins?|insulin|antibiotics?|melatonin|vitamins?|blood (?:pressure|sugar)|cholesterol|diabet\w*|dementia|symptoms?|diagnos\w*|side effects?|depress\w*|anxious|anxiety)\b/i;
|
|
|
|
|
|
|
| 837 |
const HEALTH_SAID = "I'm a robot, so I can't give health advice: your doctor or pharmacist can. I can remind you to call them. If it's an emergency, please call 911.";
|
| 838 |
let asked = null, asking = 0;
|
| 839 |
// Typed in another of Andy's fifteen languages: that language's scene, as Andy notices the language it's called in
|
|
@@ -871,6 +873,7 @@
|
|
| 871 |
function route(text) {
|
| 872 |
const t = text.replace(/^\W*(?:hey |oye )?andy\W*/i, ""), lang = typedIn(text);
|
| 873 |
if (lang && lang !== "en") return lang === "zh" ? "mandarin" : lang === "es" ? "spanish" : "in-" + lang;
|
|
|
|
| 874 |
const hit = (ASK.find(([, rx]) => rx.test(t)) || ["help"])[0];
|
| 875 |
return (hit === "answer" || hit === "help") && HEALTH_TYPED.test(t) ? "help" : hit; // never an answer, on the robot either
|
| 876 |
}
|
|
@@ -882,10 +885,11 @@
|
|
| 882 |
if (route(text) === "hood") { location.href = hoodUrl(); return; } // its own page, as from the gear
|
| 883 |
const scene = route(text), run = ++asking;
|
| 884 |
const thing = (text.match(/\b(?:my|the|our)\s+([a-z][a-z ]{1,24}?)(?=\s*(?:[?.!,]|$|\bplease\b|\bis\b|\bare\b|\bgo\b))/i) || [])[1] || "";
|
| 885 |
-
const other = thing && !/\b(?:mug|cup)s?\b/i.test(thing) && ["find", "guide", "turned"].includes(scene);
|
| 886 |
asked = { text, scene: scene === "find" ? "found" : scene,
|
| 887 |
note: /^in-|^mandarin$|^spanish$/.test(scene) ? "On the robot, Andy notices the language it's asked in and answers in it. This scene was recorded finding a mug."
|
| 888 |
: other ? `This scene was recorded finding a mug; on the robot, Andy looks for your ${thing.toLowerCase()} the same way.`
|
|
|
|
| 889 |
: scene === "help" && HEALTH_TYPED.test(text) ? `On the robot, Andy says: "${HEALTH_SAID}" Its own words, written in code in each of its fifteen languages: a health question never reaches a model.`
|
| 890 |
: scene === "help" ? "Nothing matched that, so here's what Andy can do. On the robot, Andy also just talks." : "" };
|
| 891 |
chosen = scene === "find" ? "finding" : asked.scene; pictureKey = ""; demoBar();
|
|
|
|
| 834 |
// A health question typed, which matched no scene: what Andy says to it on the robot, its own words, never a model's
|
| 835 |
// (companion/safety.py HEALTH_REPLY; on the robot the rule is wider, and tested)
|
| 836 |
const HEALTH_TYPED = /\b(?:hurts?|aches?|aching|pain|sore|swollen|dizzy|fever|cough|rash|headaches?|migraines?|nause\w*|pills?|tablets?|medicines?|medications?|meds|doses?|tylenol|ibuprofen|aspirin|advil|statins?|insulin|antibiotics?|melatonin|vitamins?|blood (?:pressure|sugar)|cholesterol|diabet\w*|dementia|symptoms?|diagnos\w*|side effects?|depress\w*|anxious|anxiety)\b/i;
|
| 837 |
+
const EMERGENCY_TYPED = /\bi(?:'ve| have| just)?\s*(?:just\s+)?(?:fell|fallen|had a fall)\b(?!\s+(?:asleep|for|in love|behind|apart))|\b(?:can'?t|cannot) (?:get up|breathe)\b(?!\s+(?:early|tomorrow|in the morning))|\bchest (?:pains?|hurts)\b|\bcollapsed\b|\bcall 911\b/i;
|
| 838 |
+
const EMERGENCY_SAID = "If you need help, please call 911 right away. I'll find your phone.";
|
| 839 |
const HEALTH_SAID = "I'm a robot, so I can't give health advice: your doctor or pharmacist can. I can remind you to call them. If it's an emergency, please call 911.";
|
| 840 |
let asked = null, asking = 0;
|
| 841 |
// Typed in another of Andy's fifteen languages: that language's scene, as Andy notices the language it's called in
|
|
|
|
| 873 |
function route(text) {
|
| 874 |
const t = text.replace(/^\W*(?:hey |oye )?andy\W*/i, ""), lang = typedIn(text);
|
| 875 |
if (lang && lang !== "en") return lang === "zh" ? "mandarin" : lang === "es" ? "spanish" : "in-" + lang;
|
| 876 |
+
if (EMERGENCY_TYPED.test(t)) return "find"; // 911 first, then the phone found: the search scene
|
| 877 |
const hit = (ASK.find(([, rx]) => rx.test(t)) || ["help"])[0];
|
| 878 |
return (hit === "answer" || hit === "help") && HEALTH_TYPED.test(t) ? "help" : hit; // never an answer, on the robot either
|
| 879 |
}
|
|
|
|
| 885 |
if (route(text) === "hood") { location.href = hoodUrl(); return; } // its own page, as from the gear
|
| 886 |
const scene = route(text), run = ++asking;
|
| 887 |
const thing = (text.match(/\b(?:my|the|our)\s+([a-z][a-z ]{1,24}?)(?=\s*(?:[?.!,]|$|\bplease\b|\bis\b|\bare\b|\bgo\b))/i) || [])[1] || "";
|
| 888 |
+
const other = thing && !/\b(?:mug|cup)s?\b/i.test(thing) && ["find", "guide", "turned"].includes(scene) && !EMERGENCY_TYPED.test(text);
|
| 889 |
asked = { text, scene: scene === "find" ? "found" : scene,
|
| 890 |
note: /^in-|^mandarin$|^spanish$/.test(scene) ? "On the robot, Andy notices the language it's asked in and answers in it. This scene was recorded finding a mug."
|
| 891 |
: other ? `This scene was recorded finding a mug; on the robot, Andy looks for your ${thing.toLowerCase()} the same way.`
|
| 892 |
+
: EMERGENCY_TYPED.test(text) ? `On the robot, Andy says first: "${EMERGENCY_SAID}" Then it finds your phone and points at it (16.5 s on the robot). This scene was recorded finding a mug.`
|
| 893 |
: scene === "help" && HEALTH_TYPED.test(text) ? `On the robot, Andy says: "${HEALTH_SAID}" Its own words, written in code in each of its fifteen languages: a health question never reaches a model.`
|
| 894 |
: scene === "help" ? "Nothing matched that, so here's what Andy can do. On the robot, Andy also just talks." : "" };
|
| 895 |
chosen = scene === "find" ? "finding" : asked.scene; pictureKey = ""; demoBar();
|
scenes/turned.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|