TwKit
正在载入
TwKit

A reusable check for AI-extracted tasks: require the task, owner and due date,… · @chu_zheng74230 · TwKit

@chu_zheng74230

A reusable check for AI-extracted tasks: require the task, owner and due date, while allowing null when the source leaves the last two unknown. With jsonschema installed, run this Python on a saved JSON result: import json from jsonschema import Draft202012Validator, FormatChecker schema = { "type": "object", "properties": { "task": {"type": "string", "minLength": 1}, "owner": {"type": ["string", "null"]}, "due": {"type": ["string", "null"], "format": "date"} }, "required": ["task", "owner", "due"], "additionalProperties": False } with open(input("JSON file: "), encoding="utf-8") as f: data = json.load(f) validator = Draft202012Validator(schema, format_checker=FormatChecker()) validator.validate(data) print("Shape and date check passed") Valid example: {"task":"Print the handouts","owner":null,"due":null} The exact script accepted that example and a dated task. It rejected a missing owner field, a numeric owner, an extra priority field, an empty task and 2026-02-30. Give AI the same field rules before extraction. This validates the output’s shape and date syntax; compare names and commitments with the original source separately.

曝光 16 · 评论 1 · 点赞 0 · 书签 0

查看原帖