nekomata / regex-math /intent-parse.lisp
SNAPKITTYWEST's picture
push from SNAPKITTYWEST/nekomata
3b70664 verified
Raw History Blame Contribute Delete
1.27 kB
(in-package #:nekod.regex)
;; Parse natural language intent into symbolic constraints
;; "make it fast" -> regex over performance metrics -> routing decision
(defvar *intent-patterns*
'(("fast\\|performance\\|speed\\|latency" . :performance)
("reliable\\|stable\\|uptime\\|resilient" . :reliability)
("scale\\|traffic\\|load\\|capacity" . :scaling)
("secure\\|safe\\|isolat" . :security)
("cheap\\|cost\\|efficient\\|resource" . :efficiency)
("stor\\|data\\|persist\\|volume" . :storage)))
(defun parse-intent (natural-language-string)
"Parse NL intent to symbolic constraint keyword."
(let ((lower (string-downcase natural-language-string)))
(loop for (pattern . intent) in *intent-patterns*
when (cl-ppcre:scan pattern lower)
return intent
finally (return :unknown))))
(defun intent->expert (intent)
"Map intent keyword to MoE expert name."
(case intent
(:performance :scheduling)
(:reliability :recovery)
(:scaling :scaling)
(:security :security)
(:efficiency :scheduling)
(:storage :storage)
(t :scheduling)))
(defun parse-intent->expert (nl-string)
"One-shot: NL string -> expert keyword."
(intent->expert (parse-intent nl-string)))