wefe
.Query¶
- class wefe.Query(target_sets: List[Any], attribute_sets: List[Any], target_sets_names: Optional[List[str]] = None, attribute_sets_names: Optional[List[str]] = None)[source]¶
A container for attribute and target word sets.
- __init__(target_sets: List[Any], attribute_sets: List[Any], target_sets_names: Optional[List[str]] = None, attribute_sets_names: Optional[List[str]] = None)[source]¶
Initializes the container. It could include a name for each word set.
- Parameters
- target_setsUnion[np.ndarray, list]
Array or list that contains the target word sets.
- attribute_setsUnion[np.ndarray, Iterable]
Array or list that contains the attribute word sets.
- target_sets_namesUnion[np.ndarray, Iterable], optional
Array or list that contains the word sets names, by default None
- attribute_sets_namesUnion[np.ndarray, Iterable], optional
Array or list that contains the attribute sets names, by default None
- 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'
- Attributes
- target_setslist
Array or list with the lists of target words.
- attribute_setslist
Array or list with the lists of target words.
- templatetuple
A tuple that contains the template: the cardinality of the target and attribute sets respectively.
- target_sets_nameslist
Array or list with the names of target sets.
- attribute_sets_nameslist
Array or list with the lists of target words.
- query_namestr
A string that contains the auto-generated name of the query.