Skip to content

4 1 lexicon api and generated tables

TransCompilator edited this page Nov 26, 2026 · 1 revision

4.1 Lexicon API and Generated Tables

Source: https://deepwiki.com/PonvasanthPon/TransCompilator/4-1-lexicon-api-and-generated-tables

Lexicon API and Generated Tables

Relevant source files

The following files were used as context for generating this wiki page:

Purpose and Scope

The tc-lexicon crate (crates/tc-lexicon/src/lib.rs:1-5) provides a deterministic, zero-ML lexical evidence layer for TransCompilator (tc_r1). It supplies compiled-in static tables derived from Open English WordNet 2025 and CU Boulder VerbNet 3.4, an auditable closed-class function word table, and a deterministic lemmatization engine. This page documents the lexical data structures, generated tables, classification APIs, and morphological resolution routines.

Sources: crates/tc-lexicon/src/lib.rs:1-5()


Core Lexical Enums and Data Structures

The lexicon defines strongly-typed enums and structs to represent parts of speech, computational concepts, verb predicates, thematic roles, and source-provenance entries.

+-----------------------------------------------------------------+
|                      Natural Language Input                      |
|                  ("add", "subtract", "into", etc.)              |
+-----------------------------------------------------------------+
                                 |
                                 v
+-----------------------------------------------------------------+
|                        tc-lexicon Types                         |
|  - Pos (crates/tc-lexicon/src/lib.rs:18-29)                     |
|  - SemanticConcept (crates/tc-lexicon/src/lib.rs:32-96)         |
|  - VerbPredicate (crates/tc-lexicon/src/lib.rs:99-121)          |
|  - PrepRole (crates/tc-lexicon/src/lib.rs:124-140)              |
|  - ClosedClass (crates/tc-lexicon/src/lib.rs:143-161)           |
+-----------------------------------------------------------------+
                                 |
                                 v
+-----------------------------------------------------------------+
|                       Generated Table Rows                      |
|  - WordNetEntry (crates/tc-lexicon/src/lib.rs:164-196)          |
|  - VerbNetFrame (crates/tc-lexicon/src/lib.rs:198-231)          |
+-----------------------------------------------------------------+

Sources: crates/tc-lexicon/src/lib.rs:18-231()

Parts of Speech and Concepts

  • Pos: Represents WordNet parts of speech (Verb, Noun, Adj, Adv) defined at [crates/tc-lexicon/src/lib.rs:18-29].
  • SemanticConcept: Distills WordNet hypernym paths into finite computational operations (Add, Sub, Mul, Div, Mod, Negate, Assign, Transfer, Swap, CompareGt, Create, Destroy, Output, Input, Loop, Branch, Return, etc.) defined at [crates/tc-lexicon/src/lib.rs:32-96].

Sources: crates/tc-lexicon/src/lib.rs:18-96()

Predicates and Thematic Roles

  • VerbPredicate: Represents closed semantic predicates extracted from VerbNet class semantics (TransferAdd, TransferSub, TransferMove, Assign, Create, Destroy, Emit, Receive, Combine, Transform) defined at [crates/tc-lexicon/src/lib.rs:99-121].
  • PrepRole: Maps prepositions to thematic roles (Source, Destination, Theme, Recipient, Extent, Instrument, Location) defined at [crates/tc-lexicon/src/lib.rs:124-140].
  • ClosedClass: Classifies English function words into categories (Preposition, Conjunction, Determiner, Auxiliary, Pronoun, Negation, DiscourseFiller, ControlAnchor) defined at [crates/tc-lexicon/src/lib.rs:143-161].

Sources: crates/tc-lexicon/src/lib.rs:99-161()

Provenance Structures

  • WordNetEntry: Associates a canonical lemma with a Pos, SemanticConcept, an exact Open English WordNet synset ID (synset_id), and hypernym distance (depth) [crates/tc-lexicon/src/lib.rs:164-196].
  • VerbNetFrame: Associates a verb lemma, preposition (prep), PrepRole, VerbPredicate, and an exact VerbNet class ID (class_id) [crates/tc-lexicon/src/lib.rs:198-231].

Sources: crates/tc-lexicon/src/lib.rs:164-231()


Generated Tables and Provenance

All open-class lexical tables are generated deterministically by offline harvesters (goldmines/tools/harvest_wordnet_r1.py) and committed as static Rust arrays. No runtime network access or machine learning models are used.

+-----------------------------------+     +-----------------------------------+
|  Open English WordNet 2025 XML    |     |    CU Boulder VerbNet 3.4 XMLs    |
+-----------------------------------+     +-----------------------------------+
                  |                                         |
                  v                                         v
+-----------------------------------+     +-----------------------------------+
| goldmines/tools/harvest_wordnet_r1.py|   | goldmines/tools/harvest_verbnet_r1.py|
+-----------------------------------+     +-----------------------------------+
                  |                                         |
                  v                                         v
+-----------------------------------+     +-----------------------------------+
| crates/tc-lexicon/src/generated/  |     | crates/tc-lexicon/src/generated/  |
| wordnet_concepts.rs               |     | verbnet_frames.rs                 |
| (WORDNET_ENTRIES)                 |     | (VERBNET_FRAMES)                  |
+-----------------------------------+     +-----------------------------------+

Sources: goldmines/PROVENANCE.md:1-123(), goldmines/tools/harvest_wordnet_r1.py:1-153()

Table Summary

  • WordNet Entries (WORDNET_ENTRIES): Emits 777 provenance-carrying rows derived from 43 concept anchor synsets with hypernym distance $\le 3$ [goldmines/PROVENANCE.md:18-19]. Defined in [crates/tc-lexicon/src/generated/wordnet_concepts.rs:1-15]().
  • VerbNet Frames (VERBNET_FRAMES): Emits 10,845 deduplicated semantic predicate frames sorted by (verb, prep, predicate, class_id) [goldmines/PROVENANCE.md:88-95]. Defined in [crates/tc-lexicon/src/generated/verbnet_frames.rs:1-10]().
  • Irregular Morphology (IRREGULAR_LEMMAS): Emits 103 standard irregular form-to-lemma mapping rows [goldmines/PROVENANCE.md:21]. Defined in [crates/tc-lexicon/src/generated/morphology.rs:1-114]().
  • Verb Lemmas (VERB_LEMMAS): Emits 8,871 single-word verb lemmas for validation [goldmines/PROVENANCE.md:21, crates/tc-lexicon/src/generated/morphology.rs:116-8871]().
  • Closed-Class Words (CLOSED_CLASS): Hand-audited table of 279 English function words [goldmines/PROVENANCE.md:105-106, crates/tc-lexicon/src/closed_class.rs:1-7].

Sources: goldmines/PROVENANCE.md:1-123(), crates/tc-lexicon/src/generated/wordnet_concepts.rs:1-15(), crates/tc-lexicon/src/generated/verbnet_frames.rs:1-10(), crates/tc-lexicon/src/generated/morphology.rs:1-114(), crates/tc-lexicon/src/closed_class.rs:1-7()


Verb Classification and Resolution API

The lexicon exposes lookup functions to resolve natural language verbs and prepositions into semantic concepts and VerbNet frames.

+-----------------------------------------------------------------+
|                   classify_verb(word, prep)                     |
|                 (crates/tc-lexicon/src/lib.rs)                  |
+-----------------------------------------------------------------+
          |                                             |
          v                                             v
+-------------------------------+             +-------------------------------+
|       lookup_wordnet()        |             |       lookup_verbnet()        |
|  - Returns SemanticConcept    |             |  - Returns VerbPredicate      |
|  - Returns synset_id          |             |  - Returns PrepRole, class_id |
+-------------------------------+             +-------------------------------+
          |                                             |
          +----------------------+----------------------+
                                 |
                                 v
+-----------------------------------------------------------------+
|                       VerbResolution Struct                     |
|  - lemma: String                                                |
|  - predicate: Option<VerbPredicate>                             |
|  - role: Option<PrepRole>                                       |
|  - concept: Option<SemanticConcept>                             |
|  - class_id: Option<&'static str>                               |
|  - synset_id: Option<&'static str>                              |
+-----------------------------------------------------------------+

Sources: crates/tc-lexicon/src/lib.rs:233-248()

  • classify_verb: Takes a verb word and an optional preposition, lemmatizes the word, and queries both WordNet entries and VerbNet frames to construct a VerbResolution object [crates/tc-lexicon/src/lib.rs:233-248]().
  • lookup_wordnet: Searches WORDNET_ENTRIES for matching lemma entries.
  • lookup_verbnet: Searches VERBNET_FRAMES matching the verb and preposition constraints.
  • lookup_closed_class: Queries CLOSED_CLASS for function words.

Sources: crates/tc-lexicon/src/lib.rs:12-16()


Lemmatization and Morphology Engine

The lemmatization engine (crates/tc-lexicon/src/lemmatize.rs:106-121) reduces inflected English word forms to their canonical base form using a deterministic precedence order:

  1. Irregular Lookup: Checks IRREGULAR_LEMMAS via binary search [crates/tc-lexicon/src/lemmatize.rs:111-113].
  2. Protection Filter: Checks the PROTECTED list (always, bus, class, equals, exists, gas, less, means, minus, news, physics, plus, series, species, times, towards, unless) to prevent suffix mangling of ambiguous measure or noun words [crates/tc-lexicon/src/lemmatize.rs:9-12, 114-116].
  3. Regular Suffix Rules: Strips inflectional suffixes (ies, ied, ing, ed, es, s) and validates candidate stems against VERB_LEMMAS [crates/tc-lexicon/src/lemmatize.rs:42-87, 117-119].
  4. Fallback: Returns the lowercased word unmodified if no lexicon entry matches [crates/tc-lexicon/src/lemmatize.rs:120].

Sources: crates/tc-lexicon/src/lemmatize.rs:1-137()


Clone this wiki locally