Feature metadata
Shared metadata used by the docs feature catalogue and
melody_features.get_feature_metadata().
Shared metadata for melodic features: name, source, type, family, description.
This module is the single source of truth for feature metadata used both by
the Quarto documentation table (docs/quarto_table_build.py) and by the
package-level get_feature_metadata() API, which lets users join
per-feature metadata (source, family, domain, type, description) onto a long
format feature table by feature_name.
Collects labelled feature callables from melody_features.features, extracts metadata such as pre-existing implementations, references, descriptions, notes, and categories.
- class FeatureRow(python_name, name, source_url, implementations, references, description, type_label, notes, category, domain, sort_name, feature_types=(), has_corpus_stats_param=False)[source]
Bases:
objectOne row of metadata for a single atomic feature (function or descriptor).
- Parameters:
- normalize_feature_text(text)[source]
Normalize acronyms and tokens in free text. - IOI -> IOI - df -> DF (word-boundary) - tfdf -> TFDF (word-boundary) - npvi -> NPVI (word-boundary)
- fix_possessive_feature_names(text)[source]
Fix known feature name possessives that are lost by title-casing. E.g., ‘Honores H’ -> “Honore’s H”, ‘Sichels S’ -> “Sichel’s S”, etc.
- extract_sections_from_docstring(doc)[source]
Parse simple NumPy-style sections (Parameters, Returns, Notes, Citation, etc.).
- collect_feature_rows(objs)[source]
Collect metadata rows for a set of (name, callable/property) pairs.
- to_dataframe(rows)[source]
- Parameters:
rows (list[FeatureRow])
- Return type:
DataFrame
- build_table()[source]
Build the exported feature table from atomic feature callables only.
Convention: helper/aggregator wrappers (for example get_*) are intentionally excluded so the table contains only user-facing scalar/sequence feature atoms.
- Return type:
DataFrame
- get_feature_metadata()[source]
Return a metadata table for every feature produced by get_all_features.
One row per feature family.feature_name combination (matching the dotted column names in the wide-format DataFrame returned by
melody_features.get_all_features()), with columns describing the feature’s source, family/category, domain, return type, and description. This table can be joined onto a long-format feature table by feature_name (seemelody_features.to_long_format()).to_long_format falls back to inferring family/source from the column prefix for any wide-format column (e.g. dynamic IDyOM columns) that doesn’t have an exact match here.
- Returns:
Columns: feature_name, family, source, domain, type, description, notes, references.
- Return type:
pd.DataFrame