SLLlmLoader.sleela
lib/large-language-models/SLLlmLoader.sleela · 125 line(s) · sleela
<< lib/large-language-models/SLLlmLoader.sleela
SLeeLa Standard Library Definition.
Definition: SLeeLa mirror of the loader/handler idiom (sllme_ in
loader/example_loader.h). A user implements an encode() handler that turns
their own class (words, maths, objects) into a fixed-width feature/target
pair; the framework owns bounded buffers, deterministic ordering, and
fail-closed validation. It is careful by construction: a non-encodable item is
SKIPped (counted) or ERRORs the load -- it never fabricates data. >>
#sleela 3.0
material;
class SLLlmLoader {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 8211;
String metaAuthor = "Max Rupplin";
String metaDate = "2026-11-06";
String metaCopyright = "MEARVK LLC";
String metaTrademark = "none";
String metaCorporation = "MEARVK LLC";
String metaOrigin = "International";
String metaBirthDate = "2026-11-06";
int metaScienceRating = 6;
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
< sllme_status mirror. >
static final int STATUS_OK = 0;
static final int STATUS_INVALID_ARGUMENT = 1;
static final int STATUS_WIDTH_MISMATCH = 2;
static final int STATUS_HANDLER_ERROR = 3;
static final int STATUS_EMPTY = 4;
< sllme_item_result mirror. >
static final int ITEM_OK = 0;
static final int ITEM_SKIP = 1;
static final int ITEM_ERROR = 2;
< Handler shape: fixed feature/target widths. >
int featureWidth;
int targetWidth;
< Report counters (sllme_report). >
int seen;
int loaded;
int skipped;
void configure(int fWidth, int tWidth) {
featureWidth = fWidth;
targetWidth = tWidth;
resetReport();
}
void resetReport() {
seen = 0;
loaded = 0;
skipped = 0;
}
< sllme_validate: fail closed on non-positive widths. >
int validate() {
if (featureWidth <= 0 || targetWidth <= 0) { return STATUS_INVALID_ARGUMENT; }
return STATUS_OK;
}
<< Account for one encoded item by its handler result. Returns the load status:
ITEM_ERROR stops the load (STATUS_HANDLER_ERROR); ITEM_SKIP is counted and
honestly omitted; ITEM_OK is loaded. >>
int accountFor(int itemResult) {
seen = seen + 1;
if (itemResult == ITEM_ERROR) { return STATUS_HANDLER_ERROR; }
if (itemResult == ITEM_SKIP) {
skipped = skipped + 1;
return STATUS_OK;
}
loaded = loaded + 1;
return STATUS_OK;
}
< sllme_load_array summary: STATUS_EMPTY if nothing was loaded at all. >
int finishReport() {
if (loaded == 0) { return STATUS_EMPTY; }
return STATUS_OK;
}
int getSeen() { return seen; }
int getLoaded() { return loaded; }
int getSkipped() { return skipped; }
String statusString(int status) {
if (status == STATUS_OK) { return "ok"; }
if (status == STATUS_INVALID_ARGUMENT) { return "invalid argument"; }
if (status == STATUS_WIDTH_MISMATCH) { return "width mismatch"; }
if (status == STATUS_HANDLER_ERROR) { return "handler error"; }
if (status == STATUS_EMPTY) { return "empty"; }
return "unknown";
}
boolean available() { return featureWidth > 0 && targetWidth > 0; }
}