graphid.util.util_tags module¶
- graphid.util.util_tags.build_alias_map(regex_map, tag_vocab)[source]¶
Constructs explicit mapping. Order of items in regex map matters. Items at top are given preference.
- graphid.util.util_tags.alias_tags(tags_list, alias_map)[source]¶
update tags to new values
- Parameters:
tags_list (list)
alias_map (list) – list of 2-tuples with regex, value
- Returns:
updated tags
- Return type:
- graphid.util.util_tags.filterflags_general_tags(tags_list, has_any=None, has_all=None, has_none=None, min_num=None, max_num=None, any_startswith=None, any_endswith=None, in_any=None, any_match=None, none_match=None, logic='and', ignore_case=True)[source]¶
- Parameters:
tags_list (list)
has_any (None) – (default = None)
has_all (None) – (default = None)
min_num (None) – (default = None)
max_num (None) – (default = None)
Notes
in_any should probably be ni_any
- Example1:
>>> # ENABLE_DOCTEST >>> tags_list = [['v'], [], ['P'], ['P'], ['n', 'o'], [], ['n', 'N'], ['e', 'i', 'p', 'b', 'n'], ['n'], ['n'], ['N']] >>> has_all = 'n' >>> min_num = 1 >>> flags = filterflags_general_tags(tags_list, has_all=has_all, min_num=min_num) >>> result = list(ub.compress(tags_list, flags)) >>> print('result = %r' % (result,))
- Example2:
>>> tags_list = [['vn'], ['vn', 'no'], ['P'], ['P'], ['n', 'o'], [], ['n', 'N'], ['e', 'i', 'p', 'b', 'n'], ['n'], ['n', 'nP'], ['NP']] >>> kwargs = { >>> 'any_endswith': 'n', >>> 'any_match': None, >>> 'any_startswith': 'n', >>> 'has_all': None, >>> 'has_any': None, >>> 'has_none': None, >>> 'max_num': 3, >>> 'min_num': 1, >>> 'none_match': ['P'], >>> } >>> flags = filterflags_general_tags(tags_list, **kwargs) >>> filtered = list(ub.compress(tags_list, flags)) >>> result = ('result = %s' % (ub.urepr(filtered, nl=0),)) >>> print(result) result = [['vn', 'no'], ['n', 'o'], ['n', 'N'], ['n'], ['n', 'nP']]