Model_C API

Package iabm_semantics

Reusable components for Model_C semantic mode interpretation.

class iabm_semantics.SemanticAssignment(sequence_states, components, operating_mode, working_mode, semantic_status, anomaly_score)[source]

Bases: object

Represent the semantic interpretation of one active sequence.

Parameters:
  • sequence_states (tuple[int, ...])

  • components (tuple[str, ...])

  • operating_mode (str)

  • working_mode (str)

  • semantic_status (str)

  • anomaly_score (float | None)

sequence_states

Original sequence word.

Type:

tuple[int, …]

components

Sorted tuple of unique components involved.

Type:

tuple[str, …]

operating_mode

High-level operating-mode label.

Type:

str

working_mode

More specific working-mode label.

Type:

str

semantic_status

Normal or anomalous semantic status.

Type:

str

anomaly_score

Optional anomaly score inherited from Model_B.

Type:

float | None

sequence_states: tuple[int, ...]
components: tuple[str, ...]
operating_mode: str
working_mode: str
semantic_status: str
anomaly_score: float | None
class iabm_semantics.SemanticModeInterpreter(component_map=None, rules=None)[source]

Bases: object

Interpret Model_B active sequences as operating and working modes.

The interpreter decodes state words into component activity, assigns semantic labels through a combination of explicit rules and heuristics, and can enrich the result with anomaly information generated by Model_B.

Parameters:
  • component_map (dict[int, str] | None)

  • rules (Iterable[SemanticRule] | None)

load_active_sequences(file_path)[source]

Load Model_B active sequences from Excel, CSV, or Parquet.

Parameters:

file_path (str | Path) – Path to the active-sequence report exported by Model_B.

Returns:

A DataFrame ready for semantic interpretation.

Return type:

DataFrame

load_comparison_report(file_path)[source]

Load a Model_B sequence-comparison report.

Parameters:

file_path (str | Path) – Path to the comparison report exported by Model_B.

Returns:

A DataFrame aligned with the active-sequence report.

Return type:

DataFrame

load_rules(file_path)[source]

Load semantic rules from a JSON file.

Parameters:

file_path (str | Path) – Path to a JSON file containing semantic-rule records.

Returns:

The parsed list of semantic rules stored in the interpreter.

Return type:

list[SemanticRule]

interpret_sequences(sequences, *, comparison=None)[source]

Assign semantic operating and working modes to sequence rows.

Parameters:
  • sequences (DataFrame) – Active sequence report produced by Model_B.

  • comparison (DataFrame | None) – Optional anomaly-comparison report produced by Model_B.

Returns:

A DataFrame containing semantic assignments for each sequence.

Return type:

DataFrame

summarize_modes(assignments)[source]

Summarize interpreted modes across all assignments.

Parameters:

assignments (DataFrame) – Per-sequence semantic assignments.

Returns:

An aggregated count table grouped by operating mode, working mode, and semantic status.

Return type:

DataFrame

class iabm_semantics.SemanticRule(required_components, operating_mode, working_mode)[source]

Bases: object

Define an explicit semantic label for a sequence of components.

Parameters:
  • required_components (tuple[str, ...])

  • operating_mode (str)

  • working_mode (str)

required_components

Components that must all be present.

Type:

tuple[str, …]

operating_mode

High-level operating-mode label.

Type:

str

working_mode

More specific working-mode label.

Type:

str

required_components: tuple[str, ...]
operating_mode: str
working_mode: str

Semantic Interpretation

Semantic interpretation utilities for Model_C.

class iabm_semantics.semantics.SemanticRule(required_components, operating_mode, working_mode)[source]

Bases: object

Define an explicit semantic label for a sequence of components.

Parameters:
  • required_components (tuple[str, ...])

  • operating_mode (str)

  • working_mode (str)

required_components

Components that must all be present.

Type:

tuple[str, …]

operating_mode

High-level operating-mode label.

Type:

str

working_mode

More specific working-mode label.

Type:

str

required_components: tuple[str, ...]
operating_mode: str
working_mode: str
class iabm_semantics.semantics.SemanticAssignment(sequence_states, components, operating_mode, working_mode, semantic_status, anomaly_score)[source]

Bases: object

Represent the semantic interpretation of one active sequence.

Parameters:
  • sequence_states (tuple[int, ...])

  • components (tuple[str, ...])

  • operating_mode (str)

  • working_mode (str)

  • semantic_status (str)

  • anomaly_score (float | None)

sequence_states

Original sequence word.

Type:

tuple[int, …]

components

Sorted tuple of unique components involved.

Type:

tuple[str, …]

operating_mode

High-level operating-mode label.

Type:

str

working_mode

More specific working-mode label.

Type:

str

semantic_status

Normal or anomalous semantic status.

Type:

str

anomaly_score

Optional anomaly score inherited from Model_B.

Type:

float | None

sequence_states: tuple[int, ...]
components: tuple[str, ...]
operating_mode: str
working_mode: str
semantic_status: str
anomaly_score: float | None
class iabm_semantics.semantics.SemanticModeInterpreter(component_map=None, rules=None)[source]

Bases: object

Interpret Model_B active sequences as operating and working modes.

The interpreter decodes state words into component activity, assigns semantic labels through a combination of explicit rules and heuristics, and can enrich the result with anomaly information generated by Model_B.

Parameters:
  • component_map (dict[int, str] | None)

  • rules (Iterable[SemanticRule] | None)

load_active_sequences(file_path)[source]

Load Model_B active sequences from Excel, CSV, or Parquet.

Parameters:

file_path (str | Path) – Path to the active-sequence report exported by Model_B.

Returns:

A DataFrame ready for semantic interpretation.

Return type:

DataFrame

load_comparison_report(file_path)[source]

Load a Model_B sequence-comparison report.

Parameters:

file_path (str | Path) – Path to the comparison report exported by Model_B.

Returns:

A DataFrame aligned with the active-sequence report.

Return type:

DataFrame

load_rules(file_path)[source]

Load semantic rules from a JSON file.

Parameters:

file_path (str | Path) – Path to a JSON file containing semantic-rule records.

Returns:

The parsed list of semantic rules stored in the interpreter.

Return type:

list[SemanticRule]

interpret_sequences(sequences, *, comparison=None)[source]

Assign semantic operating and working modes to sequence rows.

Parameters:
  • sequences (DataFrame) – Active sequence report produced by Model_B.

  • comparison (DataFrame | None) – Optional anomaly-comparison report produced by Model_B.

Returns:

A DataFrame containing semantic assignments for each sequence.

Return type:

DataFrame

summarize_modes(assignments)[source]

Summarize interpreted modes across all assignments.

Parameters:

assignments (DataFrame) – Per-sequence semantic assignments.

Returns:

An aggregated count table grouped by operating mode, working mode, and semantic status.

Return type:

DataFrame

Command-Line Interface

Command-line entry point for Model_C semantic interpretation.

iabm_semantics.main.parse_arguments(translator)[source]

Build the CLI parser with translated help messages.

Parameters:

translator (Callable[[str], str]) – Translation function returned by setup_i18n().

Returns:

Parsed command-line arguments for semantic interpretation.

Return type:

Namespace

iabm_semantics.main.main()[source]

Run the Model_C semantic interpretation workflow from the command line.

The workflow consumes sequence-level reports from Model_B, maps them to semantic operating and working modes, and optionally enriches the result with anomaly status coming from Model_B comparison outputs.

Return type:

None

Utilities

Internationalization helpers for the Model_C command-line interface.

iabm_semantics.utils.setup_i18n(lang='en')[source]

Return a translation function for the requested interface language.

Parameters:

lang (str) – ISO language code requested by the caller.

Returns:

A callable that translates user-facing CLI strings into the requested language, falling back to the original message when no translation exists.

Return type:

Callable[[str], str]