Skip to content

tdfs4ds.agent.attributes_skill

tdfs4ds.agent.attributes_skill

Attributes of features in the consumer agent (0.3.7.22).

A dataset whose entity is FEATURE_NAME gives each feature attributes (an exclusion flag and its reason, an owner...); see :mod:tdfs4ds.feature_attrs. Two uses, both written by code (no LLM):

  • a DEFINITION of a feature carries one fixed line with its attributes;
  • "which features are excluded and why" / "quelles features sont exclues" is answered from the attribute frame: the flag-like column the question names (or a column holding a value the question names), the matching features, and the reason columns when the question asks why.

Nothing here runs unless the store has an attribute dataset: the frame comes from the turn snapshot (no extra read to find out) and every entry point returns None / "" without one, so the routing, the prompts and the answers of any other store are unchanged.

FLAG_POSITIVE module-attribute

FLAG_POSITIVE = {'Y', 'YES', '1', 'TRUE', 'T', 'OUI', 'X'}

FLAG_NEGATIVE module-attribute

FLAG_NEGATIVE = {'N', 'NO', '0', 'FALSE', 'F', 'NON'}

_GENERIC_COLUMN_WORDS module-attribute

_GENERIC_COLUMN_WORDS = {'flag', 'is', 'has', 'id', 'name', 'code', 'value', 'type', 'the', 'of', 'by', 'ind', 'indicator'}

_TEXT_COLUMN_RE module-attribute

_TEXT_COLUMN_RE = compile('REASON|COMMENT|JUSTIF|NOTE|RATIONALE|EXPLAN|MOTIF|RAISON|CAUSE|DESC', I)

_FEATURE_WORD_RE module-attribute

_FEATURE_WORD_RE = compile('\\b(features?|variables?|caract[eé]ristiques?|indicateurs?)\\b', I)

_WHY_RE module-attribute

_WHY_RE = compile('\\b(why|reasons?|because|pourquoi|raisons?|justif\\w*|motifs?|cause\\w*)\\b', I)

_NEGATION_RE module-attribute

_NEGATION_RE = compile("\\b(not|non|pas|sans|without|aren't|isn't)\\b", I)

_ca

_ca()

_fr

_fr(question: str) -> bool

_plain

_plain(text: str) -> str

_words

_words(text: str) -> list

_stem_match

_stem_match(a: str, b: str) -> bool

Same word, or the same first five letters ("excluded" / "exclusion" / "exclues").

attribute_frame

attribute_frame(ca=None) -> Optional[pd.DataFrame]

The feature-attribute frame of the turn, or None when the store has no attribute dataset.

Detected from the turn snapshot's dataset catalog and entity frames (no extra read); read once per turn through _turn_cached. Never raises.

_is_text_column

_is_text_column(name: str) -> bool

_flag_like

_flag_like(values) -> bool

attribute_request

attribute_request(question: str, frame: Optional[DataFrame]) -> Optional[dict]

The attribute request a question makes, or None. Pure.

{"filters": [{"column", "kind": "flag"|"value", "negative", "value"}], "text_columns": [...], "why": bool, "features": [names the question names]}. A question counts only when it speaks of features (or names one) AND names an attribute column (a flag-like one) or a value of a column.

select_features

select_features(frame: DataFrame, req: dict) -> pd.DataFrame

The rows of the attribute frame the request selects. Pure.

_filter_text

_filter_text(f: dict, fr: bool) -> str

render_attribute_answer

render_attribute_answer(frame: DataFrame, req: dict, fr: bool) -> str

The answer, written by code (EN / FR).

skill_attributes

skill_attributes(question: str, frame: Optional[DataFrame] = None) -> Optional[dict]

The answer to an attribute question as a skill result, or None when the question is not one (or the store has no attribute dataset). Never raises.

attribute_line

attribute_line(feature_name: str, entity_name: str = '', data_domain: str = '', fr: bool = False, frame: Optional[DataFrame] = None) -> str

One fixed line with a feature's attributes ("Attributes (from DS_RULES): EXCLUDED = Y, ..."), "" when the store has no attribute dataset or the feature has no attribute row. Never raises.