TTY OV  1
A cross platform python terminal
Loading...
Searching...
No Matches
polyguard.src.normalise.Normalise Class Reference
Collaboration diagram for polyguard.src.normalise.Normalise:
Collaboration graph

Public Member Functions

"Normalise" __new__ (cls)
 

Static Public Member Functions

Set[str] normalize (Iterable[str] words)
 
Set[str] load_from_file (str filepath, str encoding="utf-8")
 
Dict[object, Set[str]] load_mapping ("dict" mapping)
 

Static Public Attributes

Disp disp = initialise_logger(__qualname__, False)
 

Static Protected Attributes

Lock _instance_lock = Lock()
 
Optional _instance = None
 

Detailed Description

Normalization utilities for word-list processing.

Provides singleton static methods for cleaning and normalizing word lists.
Methods are intentionally simple and easy to test. They do not mutate
external state, and all operations are thread-safe with explicit locking
for logging consistency.

Definition at line 40 of file normalise.py.

Member Function Documentation

◆ __new__()

"Normalise" polyguard.src.normalise.Normalise.__new__ ( cls)

Definition at line 52 of file normalise.py.

◆ load_from_file()

Set[str] polyguard.src.normalise.Normalise.load_from_file ( str filepath,
str encoding = "utf-8" )
static
Load and normalize words from a newline-delimited text file.

Reads the file line-by-line and passes each line to normalize().
Missing or unreadable files return an empty set without raising.

Args:
    filepath: Path to text file containing newline-delimited words.
    encoding: Character encoding for file read. Defaults to utf-8.

Returns:
    Set[str]: Normalized set of words from the file, or empty set if file not found.

Definition at line 90 of file normalise.py.

◆ load_mapping()

Dict[object, Set[str]] polyguard.src.normalise.Normalise.load_mapping ( "dict" mapping)
static
Normalize a mapping of keys to word iterables into key to word sets.

Transforms each value in the mapping through normalize(). The function
does not assume any particular key type; callers should validate keys
where necessary. None values are transformed to empty sets.

Args:
    mapping: Dictionary with arbitrary keys and word iterables as values.

Returns:
    Dict[object, Set[str]]: Mapping with same keys but normalized word sets as values.

Definition at line 115 of file normalise.py.

◆ normalize()

Set[str] polyguard.src.normalise.Normalise.normalize ( Iterable[str] words)
static
Clean and normalize an iterable of words to a lowercase set.

Filters out None values, empty strings, and whitespace-only entries.
All output words are converted to lowercase and stripped of whitespace.
Uses class-level logging lock to ensure interleaved output consistency.

Args:
    words: Iterable of string words to normalize.

Returns:
    Set[str]: Set of normalized (lowercase, stripped) words.

Definition at line 59 of file normalise.py.

Field Documentation

◆ _instance

Optional polyguard.src.normalise.Normalise._instance = None
staticprotected

Definition at line 49 of file normalise.py.

◆ _instance_lock

Lock polyguard.src.normalise.Normalise._instance_lock = Lock()
staticprotected

Definition at line 48 of file normalise.py.

◆ disp

Disp polyguard.src.normalise.Normalise.disp = initialise_logger(__qualname__, False)
static

Definition at line 50 of file normalise.py.


The documentation for this class was generated from the following file: