def _normalizeparse(ctx): ''' Versa action function Utility to specify a list of relationships :param ctx: Versa context used in processing (e.g. includes the prototype link :return: Tuple of key/value tuples from the attributes; suitable for hashing ''' _text_in = text_in(ctx) if callable(text_in) else text_in return slugify(_text_in, False) if _text_in else ''
def _relator_property(ctx): ''' Versa action function Utility to specify a list of relationships :param ctx: Versa context used in processing (e.g. includes the prototype link) :return: List of relationships computed from the source text ''' _text_in = text_in(ctx) if callable(text_in) else text_in if not isinstance(_text_in, list): _text_in = [_text_in] #Take into account RDA-isms such as $iContainer of (expression) by stripping the parens https://foundry.zepheira.com/topics/380 return [((prefix or '') + amara3.iri.percent_encode(slugify(RDA_PARENS_PAT.sub('', ti), False))) if ti else '' for ti in _text_in]
def _relator_property(ctx): ''' Versa action function Utility to specify a list of relationships :param ctx: Versa context used in processing (e.g. includes the prototype link) :return: List of relationships computed from the source text ''' _text_in = text_in(ctx) if callable(text_in) else text_in _prefix = prefix or '' if not isinstance(_text_in, list): _text_in = [_text_in] #Take into account RDA-isms such as $iContainer of (expression) by stripping the parens https://foundry.zepheira.com/topics/380 properties = [ (_prefix + iri.percent_encode(slugify(RDA_PARENS_PAT.sub('', ti), False))) if ti else '' for ti in _text_in ] properties = [ prop if (allowed is None or prop in allowed) else default for prop in properties ] return properties