Rename: nlg → elp (Engram Language Protocol)

This commit is contained in:
Will Anderson
2026-05-02 22:15:25 -05:00
parent cbb27b8d87
commit 34725a3988
125 changed files with 129214 additions and 780 deletions
+47 -6
View File
@@ -1,9 +1,15 @@
// vocabulary.el - Vocabulary query interface with inline seed data.
//
// Represents lexical entries for English words with POS, morphological forms,
// semantic class, and synonyms. Inline data covers the vocabulary needed for
// grammar tests. The long-term backing store is the Neuron engram (queried at
// runtime), but inline data is used for bootstrapping.
// Represents lexical entries with POS, morphological forms, semantic class,
// synonyms, and a language code. Inline data covers English vocabulary needed
// for grammar tests. The long-term backing store is the Neuron Engram (queried
// at runtime via searchKnowledge(query="VOCAB: <word>", category="vocabulary")),
// but inline data is used for bootstrapping.
//
// Language codes follow ISO 639-1. The seed data below is English ("en").
// Vocabulary for other languages is loaded from the Engram at runtime; the
// engine functions `vocab_lookup` and `vocab_synonym` accept a lang_code
// parameter to filter results by language.
//
// POS values: "noun" | "verb" | "adjective" | "adverb" | "determiner" |
// "preposition" | "pronoun" | "conjunction" | "auxiliary"
@@ -245,9 +251,18 @@ fn get_vocab() -> [[String]] {
}
// Query functions
//
// All lookup functions accept an optional lang_code parameter. The inline seed
// data is English ("en"). When lang_code is "" the match is language-agnostic
// (useful when the caller has already filtered by language).
//
// The Engram path (not implemented inline) would be:
// searchKnowledge(query="VOCAB: " + word, category="vocabulary", lang=lang_code)
// Returns the entry whose word (index 0) matches, or an empty list if not found.
fn vocab_lookup(word: String) -> [String] {
// vocab_lookup(word, lang_code) -> [String]
// Returns the entry whose word (index 0) matches the query word for the given
// language. Pass lang_code="" to match any language.
fn vocab_lookup(word: String, lang_code: String) -> [String] {
let vocab: [[String]] = get_vocab()
let n: Int = native_list_len(vocab)
let i: Int = 0
@@ -255,6 +270,15 @@ fn vocab_lookup(word: String) -> [String] {
let entry: [String] = native_list_get(vocab, i)
let w: String = native_list_get(entry, 0)
if str_eq(w, word) {
// The inline seed data is English. If caller requests a specific
// language other than "en", we cannot satisfy it from inline data;
// return empty to signal "not found" (Engram lookup should follow).
if !str_eq(lang_code, "") {
if !str_eq(lang_code, "en") {
let empty: [String] = native_list_empty()
return empty
}
}
return entry
}
let i = i + 1
@@ -263,6 +287,23 @@ fn vocab_lookup(word: String) -> [String] {
return empty
}
// vocab_lookup_en(word) -> [String]
// Backward-compatible alias: look up an English word.
fn vocab_lookup_en(word: String) -> [String] {
return vocab_lookup(word, "en")
}
// vocab_synonym(word, register, lang_code) -> String
// Returns a register-appropriate synonym for a word in the given language.
// register: "formal" | "informal" | "neutral"
// Returns the original word if no synonym is found.
fn vocab_synonym(word: String, lang_register: String, lang_code: String) -> String {
// Inline data does not carry synonym information.
// The Engram backing store supplies synonyms via knowledge nodes.
// Return the word unchanged as a safe fallback.
return word
}
// Returns all entries whose pos (index 1) matches.
fn vocab_by_pos(pos: String) -> [[String]] {
let vocab: [[String]] = get_vocab()