Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AngelMoralesChazari/TautoTeacher-2.0/llms.txt

Use this file to discover all available pages before exploring further.

SemanticMapper (package tautoteacher2.nlp.semantica) is the final translation step of the NLP pipeline. It receives the List<TokenNatural> produced by NaturalLexer, iterates over an ordered catalogue of PatronSemanticoLgs patterns, and — for the first pattern whose token-type sequence exactly matches the list — constructs a LogicExpr IR node. The lexemas carried by the matched LITERAL tokens are canonicalized by BaseConocimiento before they become AtomExpr leaves, so the resulting IR always uses infinitive proposition labels regardless of how the original sentence was conjugated.

IR Expression Types

The IR nodes live in package tautoteacher2.logicscript.ir. Every node implements LogicExpr, which is the root interface walked by EmitidorFormula to render a Unicode formula string.
IR classArityFormula symbolDescription
AtomExpr0 (leaf)A propositional variable, optionally negated (¬)
NegExpr1 (unary)¬Logical negation of a sub-expression
AndExpr2 (binary)Conjunction
OrExpr2 (binary)Disjunction
ImpExpr2 (binary)Implication (antecedent → consequent)
EquivExpr2 (binary)Biconditional equivalence
AtomExpr carries two fields: the canonical label string (e.g., "llover") and a boolean negada flag set to true when the original literal was prefixed with "no ".

Built-in Patterns

The default pattern catalogue is defined in patronesPredeterminados(). Patterns are matched in the order listed; the first matching pattern wins.
Pattern nameToken sequenceIR outputNotes
SI_CONJ_Y_ENTONCESSI LIT Y LIT ENTONCES LITIMP_ANDAntecedent is conjunction of two literals
SI_ENTONCES_DISY_CONSSI LIT ENTONCES LIT O LITIMP_ORConsequent is disjunction
SI_ENTONCES_CONJ_CONSSI LIT ENTONCES LIT Y LITIMP_AND_CONSConsequent is conjunction
SI_DISY_O_ENTONCESSI LIT O LIT ENTONCES LITIMP_OR_ANTAntecedent is disjunction
SI_DISY_O_ELIPTICOSI LIT O LIT LITIMP_OR_ANTElided entonces, disjunctive antecedent
SIEMPRE_QUE_CONJ_Y_ELIPTICOSIEMPRE_QUE LIT Y LIT LITIMP_ANDElided entonces after siempre que
SIEMPRE_QUE_DISY_O_ELIPTICOSIEMPRE_QUE LIT O LIT LITIMP_OR_ANTElided entonces, disjunctive antecedent
CUANDO_CONJ_Y_ELIPTICOCUANDO LIT Y LIT LITIMP_ANDElided entonces after cuando
CUANDO_DISY_O_ELIPTICOCUANDO LIT O LIT LITIMP_OR_ANTElided entonces, disjunctive antecedent
SI_CONJ_Y_ELIPTICOSI LIT Y LIT LITIMP_ANDElided entonces, conjunctive antecedent
SI_ENTONCESSI LIT ENTONCES LITIMPStandard conditional
SI_ELIPTICOSI LIT LITIMPElliptical conditional, no entonces
CUANDO_ENTONCESCUANDO LIT ENTONCES LITIMPTemporal conditional with entonces
CUANDO_ELIPTICOCUANDO LIT LITIMPElliptical temporal conditional
SOLO_SILIT SOLO_SI LITIMPNecessary condition (P solo si QP → Q)
A_MENOS_QUELIT A_MENOS_QUE LITIMP_UNLESSException (P a menos que Q¬Q → P)
SIEMPRE_QUE_ENTONCESSIEMPRE_QUE LIT ENTONCES LITIMPSufficient condition with entonces
SIEMPRE_QUE_ELIPTICOSIEMPRE_QUE LIT LITIMPElliptical sufficient condition
CONSECUENTE_SI_ANTECEDENTELIT SI LITIMP (reversed)Consequent-first word order: Q si PP → Q
EN_CASO_DE_QUEEN_CASO_DE_QUE LIT LITIMPAlternative conditional phrasing
EQUIVALENCIALIT SI_Y_SOLO_SI LITEQUIVBiconditional
CONJUNCIONLIT Y LITANDSimple conjunction
DISYUNCIONLIT O LITORSimple disjunction
The IMP_UNLESS IR type does not create a plain ImpExpr(left, right); instead it wraps the right-hand atom in a NegExpr and reverses the operand order, producing ImpExpr(NegExpr(right), left) — i.e., (¬Q → P).

The mapearBloque Method

// tokens produced by NaturalLexer.tokenizar(...)
List<TokenNatural> tokens = lexer.tokenizar("si llueve entonces llevo paraguas");

List<String> pasosDeAnalisis = new ArrayList<>();

LogicExpr expr = semanticMapper.mapearBloque(
    "si llueve entonces llevo paraguas",   // original block text (used only for fallback)
    tokens,
    pasosDeAnalisis
);
// expr → ImpExpr(AtomExpr("llover"), AtomExpr("llevar paraguas"))
// pasosDeAnalisis → ["SemanticMapper: patrón SI_ENTONCES detectado."]
The pasosDeAnalisis list is a caller-supplied accumulator. After the call it contains one entry naming the matched pattern, or "SemanticMapper: fallback a átomo simple." when no pattern matched.

Negation Inside Literals

Before constructing an AtomExpr, SemanticMapper checks whether the literal lexema starts with "no ". If so, the no prefix is stripped and AtomExpr is created with negada = true. This means a literal like "no estudio" produces AtomExpr("estudiar", true), which EmitidorFormula renders as ¬estudiar.

Fallback Behavior

When no pattern in the catalogue matches the token list, SemanticMapper applies two sequential fallbacks:
  1. First-literal fallback — the lexema of the first LITERAL token found in the list is canonicalized and wrapped in an AtomExpr. pasosDeAnalisis records "SemanticMapper: fallback a átomo simple.".
  2. Full-text fallback — if there are no LITERAL tokens at all, the raw textoBloque string is used as the atom label. pasosDeAnalisis records "SemanticMapper: fallback por texto completo.".
Both fallbacks produce a valid (though structurally incomplete) LogicExpr so the pipeline never throws on unrecognized input.

Loading Patterns from core.lgs

SemanticMapper is constructed with a BaseConocimiento and an optional List<PatronSemanticoLgs> loaded from core.lgs by the pipeline bootstrap. If the list is null or empty — for example when core.lgs contains no pattern directives — the built-in defaults from patronesPredeterminados() are used instead. This means the system works out of the box without any configuration file.
Pattern matching is exact: the number of tokens and the type of every token in the list must match the pattern’s form specification precisely. A sentence that introduces a new connective phrase or a novel word order will not match any existing pattern and will fall back to atom mode. To support new sentence structures, add a pattern directive to core.lgs — no Java recompilation is needed once the PatronSemanticoLgs loading infrastructure is in place.

Build docs developers (and LLMs) love