foley.index.taxonomy.model#

Data structures for the UCS/AudioSet taxonomy resolver (stdlib-only).

These are plain, immutable-ish records — the resolver logic lives in ucs, audioset, and resolver. Nothing here imports numpy/torch; the whole taxonomy layer is a pure lookup over dicts (report 04 §5.3 — “taxonomies do faceting and browse”, the CLAP vector does the heavy retrieval).

Module Attributes

GENERIC_SUBCATEGORIES

Subcategories that name no particular sound (RAIN/GENERAL, AIR/MISC).

NON_SOUND_CATEGORIES

Categories whose rows are production bookkeeping (TMARK, WIP, SCNE), not kinds of sound: a filename may name them, a tagger or keyword match never does.

Classes

AudioSetUcsMap([by_name, by_mid])

AudioSet-label -> UCS-CatID overlap map (report 04 §5.3).

CatIdResolution([catid, category, ...])

The result of resolving free tags/caption/labels to a UCS CatID.

UcsName(catid, category, subcategory[, ...])

Every field of a UCS filename (foley.index.taxonomy.ucs.parse_ucs_name).

UcsRow(catid, category, subcategory[, ...])

One Universal Category System entry.

UcsTable([by_catid, order, _ci_index, legacy])

A loaded UCS lookup by CatID: exact, case-insensitive, or a legacy CatID.

class foley.index.taxonomy.model.AudioSetUcsMap(by_name=dict(), by_mid=dict())[source]#

Bases: object

AudioSet-label -> UCS-CatID overlap map (report 04 §5.3).

Keyed primarily by lowercased label name (robust); by_mid carries the best-effort /m/... machine ids as a secondary key. Every target CatID is validated against the UCS table at load time (fail-fast on a broken map).

resolve(label)[source]#

Map one AudioSet label (a MID or a name) to a UCS CatID (or None).

Return type:

Optional[str]

class foley.index.taxonomy.model.CatIdResolution(catid=None, category=None, subcategory=None, source=None, confidence=0.0, matched_terms=list())[source]#

Bases: object

The result of resolving free tags/caption/labels to a UCS CatID.

catid feeds ucs_category and subcategory feeds ucs_subcategory on ingest, and ucs_catid on the query side.

foley.index.taxonomy.model.GENERIC_SUBCATEGORIES: frozenset = frozenset({'general', 'misc'})#

Subcategories that name no particular sound (RAIN/GENERAL, AIR/MISC).

foley.index.taxonomy.model.NON_SOUND_CATEGORIES: frozenset = frozenset({'ARCHIVED'})#

Categories whose rows are production bookkeeping (TMARK, WIP, SCNE), not kinds of sound: a filename may name them, a tagger or keyword match never does.

class foley.index.taxonomy.model.UcsName(catid, category, subcategory, fx_name=None, creator_id=None, source_id=None, user_category=None, vendor_category=None, user_data=None)[source]#

Bases: object

Every field of a UCS filename (foley.index.taxonomy.ucs.parse_ucs_name).

CatID[-UserCategory]_[VendorCategory-]FXName_CreatorID_SourceID[_UserData].ext: underscores separate the blocks; a hyphen attaches the optional UserCategory to the CatID and the optional VendorCategory to the FXName. category and subcategory come from the table row of catid; a block the name does not have is None.

class foley.index.taxonomy.model.UcsRow(catid, category, subcategory, synonyms=(), confident=False, explanation='')[source]#

Bases: object

One Universal Category System entry.

A catid (e.g. 'DOORWood') is an OPAQUE key — the category prefix is variable-length and not reliably splittable — so catid -> (category, subcategory) is always a table lookup, never a string split (report 04 §5.2). confident=False marks an unverified row (a house drop’s); the keyword resolver bands its matches one notch lower.

property is_generic: bool#

Whether the subcategory names no particular sound (GENERAL, MISC).

class foley.index.taxonomy.model.UcsTable(by_catid=dict(), order=list(), _ci_index=dict(), legacy=dict())[source]#

Bases: object

A loaded UCS lookup by CatID: exact, case-insensitive, or a legacy CatID.

Plain data, compared by identity (a matcher caches its index per table).

by_catid#

CatID -> UcsRow (case-sensitive primary key).

Type:

dict[str, UcsRow]

order#

The CatIDs in stable insertion order (deterministic tie-breaking).

Type:

list[str]

legacy#

lower(old CatID) -> CatID for CatIDs foley once stamped that are not UCS (weathrain -> RAIN), so a stored record still finds its row.

Type:

dict[str, str]

get(catid)[source]#

Look up a row by CatID: exact, then case-insensitive, then a legacy CatID.

Return type:

Optional[UcsRow]