wefe.query.Query
- class wefe.query.Query(target_sets: list[Any], attribute_sets: list[Any], target_sets_names: list[str] | None = None, attribute_sets_names: list[str] | None = None)[source]
Bases:
objectA container for attribute and target word sets.
- __init__(target_sets: list[Any], attribute_sets: list[Any], target_sets_names: list[str] | None = None, attribute_sets_names: list[str] | None = None) None[source]
Initializes the container. It could include a name for each word set.
- Parameters:
target_sets (Union[np.ndarray, list]) – Array or list that contains the target word sets.
attribute_sets (Union[np.ndarray, Iterable]) – Array or list that contains the attribute word sets.
target_sets_names (Union[np.ndarray, Iterable], optional) – Array or list that contains the word sets names, by default None
attribute_sets_names (Union[np.ndarray, Iterable], optional) – Array or list that contains the attribute sets names, by default None
- template
A tuple that contains the template: the cardinality of the target and attribute sets respectively.
- Type:
- Raises:
TypeError – if target_sets are not an iterable or np.ndarray instance.
TypeError – if attribute_sets are not an iterable or np.ndarray instance.
Exception – if the length of target_sets is 0.
TypeError – if some element of target_sets is not an array or list.
TypeError – if some element of some target set is not an string.
TypeError – if some element of attribute_sets is not an array or list.
TypeError – if some element of some attribute set is not an string.
Examples
Construct a Query with 2 sets of target words and one set of attribute words.
>>> male_terms = ['male', 'man', 'boy'] >>> female_terms = ['female', 'woman', 'girl'] >>> science_terms = ['science','technology','physics'] >>> query = Query([male_terms, female_terms], [science_terms], ... ['Male terms', 'Female terms'], ['Science terms']) >>> query.target_sets [['male', 'man', 'boy'], ['female', 'woman', 'girl']] >>> query.attribute_sets [['science', 'technology', 'physics']] >>> query.query_name 'Male terms and Female terms wrt Science terms'