src.dackar.RCA.ner.hybrid_ner.generators ======================================== .. py:module:: src.dackar.RCA.ner.hybrid_ner.generators .. autoapi-nested-parse:: Candidate generators produce CandidateSpan objects from a Document. Multiple generators are intended: gazetteer, regex/patterns, noun phrases, heuristics, etc. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/src/dackar/RCA/ner/hybrid_ner/generators/anchored_np_generator/index /autoapi/src/dackar/RCA/ner/hybrid_ner/generators/base/index /autoapi/src/dackar/RCA/ner/hybrid_ner/generators/candidate_utils/index /autoapi/src/dackar/RCA/ner/hybrid_ner/generators/description_embed_generator/index /autoapi/src/dackar/RCA/ner/hybrid_ner/generators/gazetteer_generator/index /autoapi/src/dackar/RCA/ner/hybrid_ner/generators/nounphrase_generator/index /autoapi/src/dackar/RCA/ner/hybrid_ner/generators/regex_generator/index Classes ------- .. autoapisummary:: src.dackar.RCA.ner.hybrid_ner.generators.CandidateGenerator src.dackar.RCA.ner.hybrid_ner.generators.RegexCandidateGenerator src.dackar.RCA.ner.hybrid_ner.generators.GazetteerGenerator src.dackar.RCA.ner.hybrid_ner.generators.GazetteerConfig src.dackar.RCA.ner.hybrid_ner.generators.NounPhraseGenerator Package Contents ---------------- .. py:class:: CandidateGenerator Bases: :py:obj:`abc.ABC` Interface for candidate generation. Candidate generation is the high-recall stage of Hybrid NER. Each generator proposes spans (with provenance and optional label hypotheses). .. py:method:: generate(doc) :abstractmethod: Return a list of CandidateSpan objects for the given document. .. py:class:: RegexCandidateGenerator(patterns) Bases: :py:obj:`src.dackar.RCA.ner.hybrid_ner.generators.base.CandidateGenerator` Simple candidate generator using regex patterns. Intended as a starter generator for v0.1 (before gazetteer + noun chunks are added). You can use this to propose common reliability phrases like: - "failed to start" - "trip occurred" - "corrosion-induced failure" Each regex can optionally attach an initial label hypothesis. .. py:attribute:: patterns .. py:method:: generate(doc) Return a list of CandidateSpan objects for the given document. .. py:class:: GazetteerGenerator(excel_path, sheet_names = None, config = None) Bases: :py:obj:`src.dackar.RCA.ner.hybrid_ner.generators.base.CandidateGenerator` Gazetteer-based candidate generator reading an Excel file of labeled term lists. Expected Excel convention: - Each sheet contains one or more columns of terms. - Column header should contain the label in square brackets, e.g.: "Degradation mechanisms [deg_mech]" If brackets are missing, the entire header is treated as the label. For each term: - exact_phrase mode: compiled, case-insensitive word-boundary regex - fuzzy_tokens mode: approximate phrase matching by token overlap Produces CandidateSpan with a LabelHypothesis(label=