Add JAKA knowledge and improve weather, news and song answers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 01:52:13 +09:00
co-authored by Claude Opus 5.5
parent 1e1862e120
commit 4fd9f3cbf4
9 changed files with 159 additions and 25 deletions
+6 -2
View File
@@ -15,6 +15,7 @@ missed (no song where one was asked); odd (no song, but the wrong kind of answer
import collections
import json
import pathlib
import re
import sys
import time
@@ -31,7 +32,9 @@ TITLES = [n for s in sing.songs().values() for n in (s["title"].lower(), s["titl
def sung(text, lang, before, whole=False):
song = sing.choose(text, lang, SANG_SONG if before == SANG else None, whole)
sang = re.match(r"ACTION: sing (\w+)", before[1]) if before else None # lumi.last_song: the song sung just before
song = sing.picked(text, before[1] if before else "") or \
sing.choose(text, lang, sang.group(1) if sang else None, whole) # as lumi.sing_now: after the list, its order
return "unknown" if song is None else "sing:" + song
@@ -69,9 +72,10 @@ def from_llm(raw, first, text, lang, before, marks):
def verdict(expect, got, before):
kind = got.split(":")[0]
sang = re.match(r"ACTION: sing (\w+)", before[1]) if before else None
for alt in expect.split(" | "):
if alt == got or alt == "sing" and kind == "sing" or \
alt == "sing_other" and kind == "sing" and got != "sing:" + SANG_SONG or \
alt == "sing_other" and kind == "sing" and got != "sing:" + (sang.group(1) if sang else SANG_SONG) or \
alt == "list" and got in ("list", "talk_titles") or \
alt == "unknown" and got in ("talk", "talk_titles") or \
alt in ("no", "stop") and got in ("talk", "talk_titles", "stop", "list"):
+2 -1
View File
@@ -8,7 +8,8 @@ NOW = ["And charging?", "charging?", "battery?", "Battery", "what's your battery
"배터리 몇 프로야?", "충전 중이야?", "배터리 얼마나 남았어?", "배터리 상태 어때?", "지금 충전하고 있어?", "배터리는?",
"배터리 충분해?", "충전 중이에요?", "그럼 충전은?", "충전은요?", "배터리 몇 퍼센트예요?"]
HOW_LONG = ["how long does charging take?", "How long does it take to charge?", "how long to recharge",
"what's the charging time", "충전 시간 얼마나 걸려?", "충전하는 데 얼마나 걸려요?", "충전 몇 시간 걸려?"]
"what's the charging time", "충전 시간 얼마나 걸려?", "충전하는 데 얼마나 걸려요?", "충전 몇 시간 걸려?",
"완충하는 데 얼마나 걸려?", "완충까지 몇 시간이에요?", "how long does a full charge take?", "완충 시간이 얼마예요?"]
OTHER = ["How long does your battery last?", "how long on a charge?", "How long does the battery last on a full charge?",
"what kind of battery do you have", "배터리 얼마나 가요?", "한 번 충전하면 몇 시간 가요?", "배터리 용량이 얼마야?",
"go charge", "충전하러 가", "How long until you need a charge?", "at what battery level do you go back to charge",
+5 -1
View File
@@ -113,7 +113,8 @@ fri = datetime.date(2026, 10, 23)
for q, days in {"오늘 날씨": [0], "and tomorrow?": [1], "모레는요?": [2], "내일모레": [2], "next Monday?": [3],
"다음 주 월요일 어때요?": [3], "this weekend": [1, 2], "이번 주말": [1, 2], "and Friday?": [0],
"next Friday": [7], "yesterday": [-1], "어제": [-1], "in 2 days": [2], "사흘 뒤": [3], "what about Busan?": None,
"the day after": [2]}.items():
"the day after": [2], "tomorrow는?": [1], "weekend는?": [1, 2], "다음 주말은?": [8, 9], "저녁에는?": [0],
"in the evening?": [0], "밤에는?": [0]}.items():
assert web.asked_day(q, [1], fri) == days, (q, web.asked_day(q, [1], fri))
week = "Weather in Seoul now: clear sky, 15 degrees.\n" + "\n".join(
f"{(fri + datetime.timedelta(days=i)).strftime('%A %d %B')}: rain." for i in range(7))
@@ -229,4 +230,7 @@ assert events[1][1] == "내일 비 와? (the weather)", events
web.search, events[:] = (lambda target: None), []
L.look_up("Who won?", "search", "winner")
assert [e[1] for e in events][1].startswith("Sorry, I'm not connected"), events
# the weather follow-up after a weather question: the day or the place moves
for q, place in {"이번 주말은 어때요?": "", "tomorrow는?": "", "부산은?": None, "and Tokyo tomorrow?": "Tokyo"}.items():
assert brain.weather_follow(q) == place, (q, brain.weather_follow(q))
print("web ok")