தேதிகள் Jev 1.13 jaggedness-இன் textbook case:
model "August 14"-ஐ text-ஆக வாசிக்கிறது, ordered quantity-ஆக அல்ல; எனவே எந்த date முதலில், இரண்டு
தேதிகளுக்கு இடையே எவ்வளவு இடைவெளி என்பது தவறாகும் – mixed formats, "next Thursday", quarters
போன்ற domain எல்லைகளில் மேலும் மோசம். TypeSafe-இன்
date-extraction cookbook
நிலைக்கும் தீர்வைக் காட்டுகிறது: ஏழு Choice கேள்விகள் ஒரே call-இல் தேதியின்
shape + பகுதிகளை text-லிருந்து படிக்கும்; சாதாரண code பதில்களை உண்மையான
date-ஆக மாற்றும், relative தேதிகளுக்கு இன்றிலிருந்து எண்ணி, பலவீன வாசிப்புகளை
மனிதரிடம் அனுப்பும் confidence gate-உடன். இந்த guide recipe-யின் சுருக்கம், key code shape-உடன்.
இறுதியில் ஒரு function கிடைக்கும், extract_date(document, role): document + "the deadline
to return the form" போன்ற phrase கொடுங்கள், date + confidence பெறுங்கள் – அல்லது அப்படி ஒரு date
இல்லை என்ற flag, அல்லது ஒருவர் பார்க்க வேண்டும் என்ற flag.
Pattern: பகுதிகளுக்கு Choices, calendar-க்கு code
தேதியின் ஒவ்வொரு பகுதியும் சிறு closed set – பன்னிரண்டு மாதங்கள், முப்பத்தொரு நாட்கள், bounded
ஆண்டுகள் – எனவே extraction free-form parsing-க்குப் பதில் enumerated options மீதான
Choice ஆகிறது, explicit "not stated" escape-உடன்; காணாமல் போன பகுதி guess
செய்யப்படாமல் report செய்யப்படும். ஏழு கேள்விகள்:
mode– date எப்படி எழுதப்பட்டுள்ளது:absolute(மாதப் பெயர்),relative(today, tomorrow, day after, named weekday), அல்லதுnone(document-இல் இந்த date இல்லை).month,day,year– absolute பகுதிகள். Year list 1900–2050, இரண்டு escapes-உடன்:none(code ஆண்டை ஊகிக்கும்),out_of_range(flag, guess இல்லை).day_anchor– today / tomorrow / day_after / weekday.weekday+week_offset– எந்த weekday, எந்த வாரம்:current("this Thursday"),next("next Thursday"), அல்லது bare ("Thursday" = இன்றிலிருந்து அடுத்த occurrence).
Code mode கேட்கும் pieces-ஐ மட்டும் படித்து, date-ஐ assemble செய்து,
பயன்படுத்திய பகுதிகளில் குறைந்த confidence-ஐ report செய்யும் – ஒரு பலவீனப் பகுதி
முழு date-ஐயும் review-க்கு அனுப்பும். 0.60-க்குக் கீழ் எதுவும், code assemble செய்ய முடியாத எதுவும்
மனிதரிடம் செல்லும்; மற்றவை நேராக through.
Code-இல் கேள்விகள்
def date_questions(role: str) -> dict[str, Choice]:
"""Seven typed choices that read a date's shape and parts off the text -- no math."""
absent = "The document does not state this, or it is not this kind of date."
return {
"mode": Choice(
instructions=(
f"How is {role} written? 'absolute' = a calendar date naming a month; "
"'relative' = relative to today; 'none' = the document does not state it."
),
criteria={"absolute": None, "relative": None, "none": None},
),
"month": Choice(
instructions=f"If {role} is an absolute calendar date, which month is it in?",
criteria={m: None for m in MONTHS} | {"none": absent},
),
"day": Choice(
instructions=f"If {role} is an absolute calendar date, which day (1-31)?",
criteria={str(d): None for d in range(1, 32)} | {"none": absent},
),
"year": Choice(
instructions=(
f"If {role} is an absolute calendar date, which year? 'none' if unstated "
"(code infers it), 'out_of_range' if stated but off the list."
),
criteria={str(y): None for y in YEAR_WINDOW}
| {"out_of_range": "Stated but outside the listed range.",
"none": "No year is stated."},
),
"day_anchor": Choice(
instructions=f"If {role} is relative to today, which day is it?",
criteria={"today": None, "tomorrow": None, "day_after": None,
"weekday": None, "none": absent},
),
"weekday": Choice(
instructions=f"If {role} names a day of the week, which one?",
criteria={w: None for w in WEEKDAYS} | {"none": absent},
),
"week_offset": Choice(
instructions=f"If {role} names a weekday, which week?",
criteria={"current": None, "next": None, "none": absent},
),
}
Code-இல் resolve செய்க
Assemble step வேண்டுமென்றே boring calendar math: காணாமல் போன ஆண்டை நிரப்புக (current year, date
ஒரு மாதத்துக்கும் பழையதாக இருந்தால் மட்டும் next), stated convention-ஆல் named weekday-ஐ date-ஆக
மாற்றுக, February 30 போன்ற impossible தேதிகளை inconsistent reads-ஆக reject செய்க. Year inference-ம்
weekday resolution-ம் pinned TODAY-லிருந்து எண்ணும், relative தேதிகள் ஒவ்வொரு run-லும்
reproduce ஆக:
def extract_date(document: str, role: str) -> dict:
return assemble(read_parts(document, role)) # one TypeSafe call, then pure code
Demo set முடிவுகள்
நான்கு சிறு documents மீது ஆறு கேள்விகள் (contract, form, survey, review notice), fixed Thursday அடிப்படையில் resolve. ஆறும் சரி:
| கேள்வி | Expected | Got | Conf | Flags |
|---|---|---|---|---|
| Agreement effective தேதி | 2025-01-01 | 2025-01-01 | 0.97 | – |
| Agreement expiry தேதி | 2027-12-31 | 2027-12-31 | 0.91 | – |
| Form return deadline | 2026-08-14 | 2026-08-14 | 0.95 | – |
| Kickoff call தேதி | none | none | 0.46 | review |
| Survey close ("today") | 2026-07-30 | 2026-07-30 | 0.94 | – |
| Design review ("next Thursday") | 2026-08-06 | 2026-08-06 | 0.92 | – |
சுவாரஸ்ய வரி kickoff call – form-இல் குறிப்பிடப்படாத date. Model absolute shape-ஐ
month இல்லாமல் தருகிறது, date காலியாக 0.46 confidence-உடன் வருகிறது, hallucinate செய்யாமல்
மனிதருக்கு flagged. ஐந்து auto-accept, ஒரு human review: இதுதான் முழு operating point.
இறுதி முடிவு
Jev-இடம் calendar math கேட்க வேண்டாம் – text எந்த boxes-ஐ tick செய்கிறது எனக் கேட்டு, math-ஐ நீங்களே செய்யுங்கள். Closed sets மீது Choices + explicit "not stated" options + weakest-link confidence – தேதிகளுக்கு அப்பால் reusable shape. Full source: TypeSafe date-extraction cookbook; தேதிகள் ஏன் jagged என்ற background Jev 1.13 jaggedness guide-இல்.