def NAMES(*args, config, op=None): if type(args[0]) == list: initial_list = [resolve_value(arg, config=config) for arg in flatten(args)] else: initial_list = [args[0]] names = list([" ".join(filter(remove_empty, names)) for names in generate_names(initial_list)]) logger.debug("Generated list of names: {}".format(names)) new_op = ExtendedOp(op) new_op.case_sensitive_override = True return "any_of", names, new_op
def PLURALIZE(*args, config, op=None): """ For a noun or a list of nouns, it will match any singular or plural word Usage for a single word, e.g.: PLURALIZE("car") Usage for lists, e.g.: vehicles = {"car", "bicycle", "ship"} PLURALIZE(vehicles) Will work even for regex or if the lemmatizer of spaCy is making an error Has dependency to the Python inflect package https://pypi.org/project/inflect/ """ if type(args[0]) == list: initial_list = [ resolve_value(arg, config=config) for arg in flatten(args) ] else: initial_list = [args[0]] return "any_of", pluralizing(initial_list), op
def nested_parse(values, config: "SessionConfig", op: ExtendedOp) -> SpacyPattern: from rita.macros import resolve_value results = rules_to_patterns( "", [resolve_value(v, config=config) for v in values], config=config) return results["pattern"]
def nested_parse(values, config, op=None): from rita.macros import resolve_value results = rules_to_patterns( "", [resolve_value(v, config=config) for v in values], config=config) return results["pattern"]
def TAG(name, config, op=None): """ For generating POS/TAG patterns based on a Regex e.g. TAG("^NN|^JJ") for nouns or adjectives """ return "tag", resolve_value(name, config=config), op
def nested_parse(values, config, op=None): from rita.macros import resolve_value (_, patterns) = rules_to_patterns( "", [resolve_value(v, config=config) for v in values], config=config) return r"(?P<g{}>{})".format(config.new_nested_group_id(), "".join(patterns))
def nested_parse(values, config: "SessionConfig", op: ExtendedOp) -> str: from rita.macros import resolve_value (_, patterns) = rules_to_patterns("", [resolve_value(v, config=config) for v in values], config=config) return r"(?P<g{}>{})".format(config.new_nested_group_id(), "".join(patterns))
def FUZZY(name, config, op=None): initial = resolve_value(name, config=config) return ("fuzzy", list(premutations(initial.lower())), op)