langtest.transform.utils.RepresentationOperation#
- class RepresentationOperation#
Bases:
object
This class provides operations for analyzing and evaluating different representations in data.
- - add_custom_representation(data, name, append, check)
Adds custom representation to the given data.
- - get_label_representation_dict(data)
Retrieves the label representation information from the data.
- - get_country_economic_representation_dict(data)
Retrieves the country economic representation information from the data.
- - get_religion_name_representation_dict(data)
Retrieves the religion representation information from the data.
- - get_ethnicity_representation_dict(data)
Retrieves the ethnicity representation information from the data.
- - get_entity_representation_proportions(entity_representation)
Calculates the proportions of each entity in the representation.
- - entity_types
A list of default entity types.
- __init__()#
Methods
__init__
()add_custom_representation
(data, name, ...)Add custom representation to the given data.
Retrieves the country economic representation information from the data.
Calculates the proportions of each entity in the representation.
Retrieves the ethnicity representation information from the data.
Retrieves the label representation information from the data.
Retrieves the religion representation information from the data.
Attributes
entity_types
- static add_custom_representation(data: list | dict, name: str, append: bool, check: str) None #
Add custom representation to the given data.
- Parameters:
data (Union[list, dict]) – The data to which the custom representation will be added.
name (str) – The name of the custom representation.
append (bool) – Indicates whether to append the custom representation or replace the existing representation.
check (str) – The check parameter is used for ‘Label-Representation’ because it is only supported for NER.
- Returns:
None
- static get_country_economic_representation_dict(data: List[Sample]) Dict[str, int] #
Retrieves the country economic representation information from the data.
- Parameters:
data (List[Sample]) – The input data to be evaluated for representation test.
- Returns:
a dictionary containing country economic representation information.
- Return type:
Dict[str, int]
- static get_entity_representation_proportions(entity_representation: Dict[str, int]) Dict[str, float] #
Calculates the proportions of each entity in the representation.
- Parameters:
entity_representation (dict) – a dictionary containing representation information.
- Returns:
a dictionary with proportions of each entity.
- Return type:
Dict[str, float]
- static get_ethnicity_representation_dict(data: List[Sample]) Dict[str, int] #
Retrieves the ethnicity representation information from the data.
- Parameters:
data (List[Sample]) – The input data to be evaluated for representation test.
- Returns:
a dictionary containing ethnicity representation information.
- Return type:
Dict[str, int]
- static get_label_representation_dict(data: List[Sample]) Dict[str, int] #
Retrieves the label representation information from the data.
- Parameters:
data (List[Sample]) – The input data to be evaluated for representation test.
- Returns:
a dictionary containing label representation information.
- Return type:
dict
- static get_religion_name_representation_dict(data: List[Sample]) Dict[str, int] #
Retrieves the religion representation information from the data.
- Parameters:
data (List[Sample]) – The input data to be evaluated for representation test.
- Returns:
a dictionary containing religion representation information.
- Return type:
Dict[str, int]