from typing import Literal Priority = Literal["low", "normal", "high", "urgent"] URGENT_WORDS = ["ngay lập tức", "ngay bây giờ", "lập tức", "khẩn cấp"] HIGH_WORDS = ["càng sớm càng tốt", "sớm nhất", "ưu tiên", "rất quan trọng"] LOW_WORDS = ["khi rảnh", "lúc rảnh", "khi nào tiện", "không gấp"] def estimate_priority(command: str) -> Priority: """Estimate the priority of a Vietnamese task/command.""" t = command.lower() for w in URGENT_WORDS: if w in t: return "urgent" for w in HIGH_WORDS: if w in t: return "high" for w in LOW_WORDS: if w in t: return "low" # heuristic: if has words like 'ngay', 'bây giờ' if "ngay" in t or "bây giờ" in t: return "high" return "normal" if __name__ == "__main__": tests = [ "Hút bụi phòng khách khi rảnh", "Nhắc tôi thanh toán tiền điện càng sớm càng tốt", "Dọn nhà bếp ngay lập tức", "Kiểm tra cửa sổ tối nay", ] for t in tests: print(t, "->", estimate_priority(t))