Add semantics layer bridging intent frames to grammar realization

Introduces semantics.el with SemFrame (sem_frame/sem_frame_simple/sem_frame_obj
constructors), sem_to_spec to convert intent frames into realizer slot maps,
and sem_realize/sem_realize_full as end-to-end frame→text entry points.
Supports intents: assert, query, describe, greet.

Wires generate_frame() into nlg.el and adds 4 new passing tests
(sem-assert, sem-query, sem-describe, sem-greet). All 10 tests pass.
This commit is contained in:
Will Anderson
2026-05-02 14:45:54 -05:00
parent 2a6d70b959
commit 4945e8e8c5
7 changed files with 362 additions and 12 deletions
+10
View File
@@ -0,0 +1,10 @@
// sem-assert.el - Realize "She sleeps." via the semantics layer.
//
// SemFrame: intent="assert", subject="she", object="sleep" (verb), modifiers=""
fn run_test() -> String {
let frame: [String] = sem_frame("assert", "she", "sleep", "")
return sem_realize(frame)
}
println(run_test())
+10
View File
@@ -0,0 +1,10 @@
// sem-describe.el - Realize "The cat is big." via the semantics layer.
//
// SemFrame: intent="describe", subject="the cat", object="big", modifiers=""
fn run_test() -> String {
let frame: [String] = sem_frame("describe", "the cat", "big", "")
return sem_realize(frame)
}
println(run_test())
+10
View File
@@ -0,0 +1,10 @@
// sem-greet.el - Realize "Hello, Alice." via the semantics layer.
//
// SemFrame: intent="greet", subject="Alice", object="", modifiers=""
fn run_test() -> String {
let frame: [String] = sem_frame("greet", "Alice", "", "")
return sem_realize(frame)
}
println(run_test())
+10
View File
@@ -0,0 +1,10 @@
// sem-query.el - Realize "Do you see?" via the semantics layer.
//
// SemFrame: intent="query", subject="you", object="see" (verb), modifiers=""
fn run_test() -> String {
let frame: [String] = sem_frame("query", "you", "see", "")
return sem_realize(frame)
}
println(run_test())
+5
View File
@@ -33,6 +33,7 @@ NLG_MODULES=(
"${SRC_DIR}/vocabulary.el"
"${SRC_DIR}/grammar.el"
"${SRC_DIR}/realizer.el"
"${SRC_DIR}/semantics.el"
"${SRC_DIR}/nlg.el"
)
@@ -102,6 +103,10 @@ run_nlg_case "question" examples/question.el "Do you see the d
run_nlg_case "command" examples/command.el "Go home."
run_nlg_case "plural-noun" examples/plural-noun.el "cats|children|boxes|cities|fish|leaves"
run_nlg_case "verb-conjugation" examples/verb-conjugation.el "ran|walked|is|am|sleeping"
run_nlg_case "sem-assert" examples/sem-assert.el "She sleeps."
run_nlg_case "sem-query" examples/sem-query.el "Do you see?"
run_nlg_case "sem-describe" examples/sem-describe.el "The cat is big."
run_nlg_case "sem-greet" examples/sem-greet.el "Hello, Alice."
echo
echo "${PASS} passed, ${FAIL} failed"