LP mining extensions (lp2graph.mining)¶
The lp2graph.mining subpackage implements the modules the LP Mining with
LP2Graph method needs on top of the deterministic core library. Each module
maps to a tracked issue (M1–M6). Everything is deterministic: every frozen
resource is versioned in lp2graph.mining.versions and the version strings are
stamped into the records the pipeline emits, so two runs over the same inputs
produce byte-identical artifacts and any resource change is a readable diff.
The optional heavy dependencies (networkx, pyomo, nltk/WordNet,
hdbscan) are all imported lazily; the package imports and the core paths run
on the standard install.
M1 — Heterogeneous ingestion front-end (mining.ingest)¶
Turns idiosyncratic source artifacts into validated Formulations, never
silently dropping a failure.
- Solver-code importers.
from_pyomo(model)builds a canonicalFormulationfrom a PyomoConcreteModel/AbstractModel(structural, best-effort)..gms/.mod/.jlroute through a registry that returns honest, structured failures rather than swallowing the input. - Non-canonical LaTeX normalizer.
normalize_latexapplies a versioned rewrite-rule table (unicode/ascii operators → canonical macros,*→\cdot, set wrappers, …), logging every rewrite with aSourceSpaninto the original text, theningest_latexparses the canonical result via the codec and runs the two-phase validator. ingest(path_or_text, fmt=...)dispatches by extension and always returns anIngestionResultwhosefailuresare reported, never raised away.
M2 — Lexical homologizer & concept vectorizer (mining.homologize)¶
Reduces names and descriptions to comparable concepts and emits frozen TF-IDF concept vectors.
tokenize/lemmatizewith a versioned stop-list;concept_bagmaps tokens to concepts through a frozen domain thesaurus (greedy multi-word match) with an optional WordNet backend.ConceptVectorizerover a sorted, diffableVocabularyproduces L2-normalized TF-IDF vectors that are stable across runs.TypeSignatureexposes the structural signatureτ(s)(domain/role/kind/ shape/quantifier structure) read straight from the canonical model, andEntity/corpus_entitiesgive the levels V/C/M their mineable units.
M3 — Cluster-and-name operator + taxonomy (mining.cluster)¶
CN(entities, vectors, vocab, config)clusters in cosine-distance space (deterministic average-linkage default;fixed_kwith silhouette selection; optional HDBSCAN) and names each part by aggregated TF-IDF weight. Every entity lands in exactly one part, including an explicitunassigned.induce(formulations)runs the bottom-up passes — Level V (variables/params) → Level C (constraints/objective, conditioned on Level-V membership) → Level M (family/type histograms + flags + bucketed structural metrics) — plus the text-onlydomainandsolution_approachclusterings.stability_reportemits silhouette, bootstrap ARI, and sensitivity to the algorithm and|C|.
M4 — Labeling service with closed-loop store (mining.label)¶
Two-stage labeling with a versioned, self-growing store.
- Controlled vocabularies per
(level, dimension)seeded from M3. - Stage 1
RuleLayerover flags / type-signatures / seed lexicon (label or abstain); Stage 2 calibrated one-vs-restLinearSVM. - The closed
LabelingServiceloop gates ontheta_low/theta_high+ rule-consistency into auto-accept / human-adjudicate / defer, writes back to a versionedLabelStore, promotes confirmedconcept → labelrules, and retrains. Guardrails re-score a held-out gold set each loop, track drift and Cohen's κ, and raise a rollback flag if precision drops. The loop is replayable from the decision log.
M5 — Corpus & provenance manager (mining.corpusmgr)¶
ProvenanceRecordper formulation (source, venue + quality tier, year, citation count @ freeze date, domain shell, activity, priority cell P1–P5).CorpusManifest(frozen search date + query strings) makes a corpus regenerable.deduplicategroups by canonical schema-graph hash or bibliographic key (transitive);select_representativespicks the highest-citation member per cluster with documented fallbacks.
M6 — Intra-cluster schema-graph isomorphism (mining.isomorphism)¶
isomorphism_report(clusters) computes, per cluster, the schema-graph
isomorphism rate (pairwise and whole-cluster), via the existing NetworkX export,
so a reader can judge how representative a validated anchor is.