Skip to content

tdfs4ds.agent.entity_word

tdfs4ds.agent.entity_word

The word "entity" as a business term (0.3.7.34, pure).

tdfs4ds says "entity" for the key a feature is computed for (CustomerID, AccountID). In some stores - banking is the usual one - "entity" is a business word: a legal entity of the group, often a column (LEGAL_ENTITY, ENTITY_ID). :func:entity_word_is_business says which meaning the store carries; :func:decide_entity_reading says what "entity X" in a question refers to when it does. No database access here: the caller reads the inputs once per turn.

_ENTITY_TERMS module-attribute

_ENTITY_TERMS = frozenset({'ENTITY', 'ENTITIES', 'LEGAL ENTITY', 'LEGAL ENTITIES', 'ENTITE', 'ENTITES', 'ENTITE JURIDIQUE', 'ENTITES JURIDIQUES'})

_PHRASE_RE module-attribute

_PHRASE_RE = re.compile('\\b(?:legal\\s+)?(?:entity|entities|entit[eé]s?)(?:\\s+juridiques?)?\\s+(?:(?:named|called|nomm[ée]e?s?)\\s+)?[\\"\'`]?([\\w][\\w.\\-]*)', re.IGNORECASE | re.UNICODE)

_FILLER module-attribute

_FILLER = frozenset({'for', 'of', 'the', 'is', 'are', 'and', 'or', 'in', 'on', 'with', 'has', 'have', 'key', 'keys', 'level', 'levels', 'a', 'an', 'to', 'by', 'that', 'which', 'what', 'as', 'at', 'from', 'do', 'does', 'did', 'list', 'available', 'exist', 'exists', 'existing', 'registered', 'defined', 'there', 'here', 'all', 'disponibles', 'existent', 'les', 'des', 'de', 'du', 'la', 'le', 'pour', 'est', 'sont', 'et', 'ou', 'dans', 'avec', 'cle', 'clef', 'cles', 'niveau', 'niveaux', 'un', 'une', 'qui', 'que', 'quoi', 'au', 'aux', 'sur', 'par', 'comme'})

_plain

_plain(text) -> str

_norm_term

_norm_term(term) -> str

_compact

_compact(text) -> str

_words

_words(name) -> List[str]

_key_parts

_key_parts(entity_keys: Iterable) -> set

glossary_defines_entity

glossary_defines_entity(glossary_entries) -> bool

True when the glossary defines ENTITY, LEGAL ENTITY, ENTITE or ENTITE JURIDIQUE (term or synonym).

business_entity_columns

business_entity_columns(column_names: Iterable, entity_keys: Iterable = ()) -> List[str]

The documented column / feature names carrying ENTITY (or ENTITE) that are not themselves a key of the store (the tdfs4ds concept), in first-seen order.

entity_word_is_business

entity_word_is_business(glossary_entries, column_names: Iterable, entity_keys: Iterable = ()) -> bool

True when "entity" is a business term in this store: the glossary defines it, or a documented column / feature name contains ENTITY without being the key of the store.

entity_phrase

entity_phrase(question: str) -> Optional[str]

X of "entity X" / "legal entity X" / "entité X" in question, or None (a filler word is no X).

decide_entity_reading

decide_entity_reading(question: str, entity_keys: Iterable, known_names: Iterable, columns: Iterable, value_found: Optional[Callable[[str, str], bool]] = None) -> Optional[Dict]

What "entity X" refers to when the word is a business term.

None when the question has no "entity X". Otherwise a dict with action: key (X names a key of the store: the tdfs4ds concept, unchanged), object (X is a feature or documented object), value (X is a value of column) or ask (still ambiguous: the agent asks).

clarification_text

clarification_text(value: str, columns: List[str], keys: List[str], fr: bool) -> str

The fixed question asked when "entity X" is ambiguous.

clarification_options

clarification_options(value: str, columns: List[str], keys: List[str], fr: bool) -> List[str]

legal_question

legal_question(value: str, columns: List[str], fr: bool) -> str

The fixed search question that shows where the value of a business entity is documented.

value_note

value_note(value: str, column: str, table: Optional[str], fr: bool) -> str

First line of the answer when X is a value of a business entity column (not a key).

not_a_key_text

not_a_key_text(value: str, keys: List[str], fr: bool) -> str

Answer when the reader chose the "feature key" reading but X is not a key of the store.