(edge, property2label,
                                    use_placeholder=False,
                                    mind_direction=True,
                                    include_modifiers=True,
                                    include_all_hop_labels=True
                                    )
return str_representation.strip()
Construct a string representation of a label using the property to label mapping.

    :param edge: edge to translate
    :param property2label: property id to label mapping
    :param use_placeholder: if an named entity should be included or just a placeholder, doesn't affect classes
    :param mind_direction: if the direction of the edge should be accounted for
    :return: a string representation of an edge
    >>> get_property_str_representation({'kbID': 'P17v','right': ['Iceland'],'rightkbID': 'Q189','type': 'direct'}, {'P17': "country"})
    'country Iceland'
    >>> get_property_str_representation({'kbID': 'P17v','right': ['Iceland'],'rightkbID': 'Q189','type': 'direct'}, {'P17': "country"}, use_placeholder=True)
    'country <e>'
    >>> get_property_str_representation({'kbID': 'P17v','right': ['Iceland'],'rightkbID': 'Q189','type': 'direct'}, {'P17': {"label":"country", "altlabel": ["land", "province"]}}, use_placeholder=True)
    'country <e>'
    >>> get_property_str_representation({'kbID': 'P17487v','right': ['Iceland'],'rightkbID': 'Q1859','type': 'direct'}, {'P17': "country"}, use_placeholder=True)
    '_UNKNOWN <e>'
    >>> get_property_str_representation({'argmax':'time','type': 'time'}, {'P17': "country"}, use_placeholder=True)
    '<a> _UNKNOWN'
    >>> get_property_str_representation({'type': 'time', 'kbID': 'P585v', 'argmax': 'time'}, {'P585': "point in time"}, use_placeholder=True)
    '<a> point in time'
    >>> get_property_str_representation({'type': 'time', 'kbID': 'P585v', 'right': ['2012']}, {'P585': "point in time"}, use_placeholder=True)
    'point in time <n>'
    >>> get_property_str_representation({'kbID': 'P31v',   'right': ['Australia'], \
   'rightkbID': 'Q408', 'type': 'reverse'}, {'P31': "instance of"}, use_placeholder=True)
    '<e> instance of'
    >>> get_property_str_representation({'kbID': 'P31v',   'right': ['Australia'], \
   'rightkbID': 'Q408', 'type': 'reverse'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    '<r> instance of <e>'
    >>> get_property_str_representation({'kbID': 'P31v',  'right': ['language'], \
   'rightkbID': 'Q408', 'type': 'class'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'language'
    >>> get_property_str_representation({'kbID': 'P31v',  'canonical_right': 'language communication method', \
   'rightkbID': 'Q408', 'type': 'iclass'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'language communication method'
    >>> get_property_str_representation({'type': 'iclass', 'kbID': 'P31v', 'canonical_right': 'currency'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'currency'
    >>> get_property_str_representation({'type': 'iclass', 'kbID': 'P31v', 'canonical_right': ['MTV Movie award', 'award', 'MTV annual movie award']}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'award'
    >>> get_property_str_representation({'argmin': 'time', 'kbID': 'P17s',  'right': ['IC'], \
    'rightkbID': 'Q189', 'canonical_right': 'Iceland', 'type': 'direct'}, {'P17': "country"}, use_placeholder=False)
    '<i> country Iceland'
    >>> get_property_str_representation({'hopUp': 'P131v', 'kbID': 'P69s',  'right': ['Missouri'], \
    'rightkbID': 'Q189', 'type': 'direct'}, {'P69': "educated at", 'P131': 'located in'}, use_placeholder=True)
    'educated at <x> located in <e>'
    >>> get_property_str_representation({'hopUp': 'P17v', 'kbID': 'P140v',  'right': ['Russia'], \
    'rightkbID': 'Q159', 'type': 'reverse'}, {'P17': "country", 'P140': 'religion'}, use_placeholder=True)
    '<x> country <e> religion'
    >>> get_property_str_representation({'hopUp': None, 'kbID': 'P140v',  'right': ['Russia'], \
    'rightkbID': 'Q159', 'type': 'reverse'}, {'P17': "country", 'P140': 'religion'}, use_placeholder=True)
    '<e> religion'
    >>> get_property_str_representation({'kbID': 'P453q', 'right': ['Natalie', 'Portman'], 'type': 'reverse', 'hopUp': 'P161v', 'rightkbID': 'Q37876', 'canonical_right': 'Natalie Portman'},  {'P453': "character role", "P161": "cast member" }, use_placeholder=True)
    '<x> cast member <e> character role'
    >>> get_property_str_representation({'kbID': 'P453q', 'right': ['Natalie', 'Portman'], 'type': 'reverse', 'hopUp': 'P161v', 'rightkbID': 'Q37876', 'canonical_right': 'Natalie Portman'},  {'P453': "character role", "P161": "cast member" }, use_placeholder=True, include_all_hop_labels=False)
    '<e> character role'
    >>> get_property_str_representation({'canonical_right': 'Indiana', 'hopUp': 'P1001v', 'kbID': 'P39v', 'type': 'direct'}, {'P39': 'position held', 'P1001':'applies to territorial jurisdiction'}, use_placeholder=True)
    'position held <x> applies to territorial jurisdiction <e>'
    >>> get_property_str_representation({'canonical_right': 'Facebook','hopDown': 'P17v','kbID': 'P150v','type': 'reverse'}, {'P17':'country', 'P150':'contains administrative territorial entity'}, use_placeholder=True)
    '<e> country <x> contains administrative territorial entity'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct'}, {'P361': 'part of'}, use_placeholder=True)
    'part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Meg Griffin', 'kbID': 'P161v', 'type': 'v-structure'}, {'P161': "cast member"}, use_placeholder=True)
    '<v> cast member <e>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'argmax':'time'}, {'P361': 'part of'}, use_placeholder=True)
    '<a> part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'argmax':'time'}, {'P361': 'part of'}, use_placeholder=True, include_modifiers=False)
    'part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'filter':'importance'}, {'P361': 'part of'}, use_placeholder=True)
    'part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'filter':'importance'}, {'P361': 'part of'}, use_placeholder=False)
    'part of Washington Redskins part of <x>'
    >>> get_property_str_representation({'kbID': 'P69s',  'right': ['Missouri'], \
    'rightkbID': 'Q189', 'type': 'direct', 'num': '2012'}, {'P69': "educated at", 'P131': 'located in'}, use_placeholder=True)
    'educated at <e> <n>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'reverse'}, {'P361': 'part of'}, use_placeholder=True, mind_direction=False, include_all_hop_labels=False)
    '<r> part of <e>'
    >>> get_property_str_representation({'label': 'netflix genres', 'type': 'direct'},{'P17': "country"}, use_placeholder=True)
    'netflix genres <e>'
Construct a string representation of a label using the property to label mapping.
Construct a string representation of a label using the property to label mapping .
def get_property_str_representation(edge, property2label,
                                    use_placeholder=False,
                                    mind_direction=True,
                                    include_modifiers=True,
                                    include_all_hop_labels=True
                                    ):
    """
    Construct a string representation of a label using the property to label mapping.

    :param edge: edge to translate
    :param property2label: property id to label mapping
    :param use_placeholder: if an named entity should be included or just a placeholder, doesn't affect classes
    :param mind_direction: if the direction of the edge should be accounted for
    :return: a string representation of an edge
    >>> get_property_str_representation({'kbID': 'P17v','right': ['Iceland'],'rightkbID': 'Q189','type': 'direct'}, {'P17': "country"})
    'country Iceland'
    >>> get_property_str_representation({'kbID': 'P17v','right': ['Iceland'],'rightkbID': 'Q189','type': 'direct'}, {'P17': "country"}, use_placeholder=True)
    'country <e>'
    >>> get_property_str_representation({'kbID': 'P17v','right': ['Iceland'],'rightkbID': 'Q189','type': 'direct'}, {'P17': {"label":"country", "altlabel": ["land", "province"]}}, use_placeholder=True)
    'country <e>'
    >>> get_property_str_representation({'kbID': 'P17487v','right': ['Iceland'],'rightkbID': 'Q1859','type': 'direct'}, {'P17': "country"}, use_placeholder=True)
    '_UNKNOWN <e>'
    >>> get_property_str_representation({'argmax':'time','type': 'time'}, {'P17': "country"}, use_placeholder=True)
    '<a> _UNKNOWN'
    >>> get_property_str_representation({'type': 'time', 'kbID': 'P585v', 'argmax': 'time'}, {'P585': "point in time"}, use_placeholder=True)
    '<a> point in time'
    >>> get_property_str_representation({'type': 'time', 'kbID': 'P585v', 'right': ['2012']}, {'P585': "point in time"}, use_placeholder=True)
    'point in time <n>'
    >>> get_property_str_representation({'kbID': 'P31v',   'right': ['Australia'], \
   'rightkbID': 'Q408', 'type': 'reverse'}, {'P31': "instance of"}, use_placeholder=True)
    '<e> instance of'
    >>> get_property_str_representation({'kbID': 'P31v',   'right': ['Australia'], \
   'rightkbID': 'Q408', 'type': 'reverse'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    '<r> instance of <e>'
    >>> get_property_str_representation({'kbID': 'P31v',  'right': ['language'], \
   'rightkbID': 'Q408', 'type': 'class'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'language'
    >>> get_property_str_representation({'kbID': 'P31v',  'canonical_right': 'language communication method', \
   'rightkbID': 'Q408', 'type': 'iclass'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'language communication method'
    >>> get_property_str_representation({'type': 'iclass', 'kbID': 'P31v', 'canonical_right': 'currency'}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'currency'
    >>> get_property_str_representation({'type': 'iclass', 'kbID': 'P31v', 'canonical_right': ['MTV Movie award', 'award', 'MTV annual movie award']}, {'P31': "instance of"}, use_placeholder=True, mind_direction=False)
    'award'
    >>> get_property_str_representation({'argmin': 'time', 'kbID': 'P17s',  'right': ['IC'], \
    'rightkbID': 'Q189', 'canonical_right': 'Iceland', 'type': 'direct'}, {'P17': "country"}, use_placeholder=False)
    '<i> country Iceland'
    >>> get_property_str_representation({'hopUp': 'P131v', 'kbID': 'P69s',  'right': ['Missouri'], \
    'rightkbID': 'Q189', 'type': 'direct'}, {'P69': "educated at", 'P131': 'located in'}, use_placeholder=True)
    'educated at <x> located in <e>'
    >>> get_property_str_representation({'hopUp': 'P17v', 'kbID': 'P140v',  'right': ['Russia'], \
    'rightkbID': 'Q159', 'type': 'reverse'}, {'P17': "country", 'P140': 'religion'}, use_placeholder=True)
    '<x> country <e> religion'
    >>> get_property_str_representation({'hopUp': None, 'kbID': 'P140v',  'right': ['Russia'], \
    'rightkbID': 'Q159', 'type': 'reverse'}, {'P17': "country", 'P140': 'religion'}, use_placeholder=True)
    '<e> religion'
    >>> get_property_str_representation({'kbID': 'P453q', 'right': ['Natalie', 'Portman'], 'type': 'reverse', 'hopUp': 'P161v', 'rightkbID': 'Q37876', 'canonical_right': 'Natalie Portman'},  {'P453': "character role", "P161": "cast member" }, use_placeholder=True)
    '<x> cast member <e> character role'
    >>> get_property_str_representation({'kbID': 'P453q', 'right': ['Natalie', 'Portman'], 'type': 'reverse', 'hopUp': 'P161v', 'rightkbID': 'Q37876', 'canonical_right': 'Natalie Portman'},  {'P453': "character role", "P161": "cast member" }, use_placeholder=True, include_all_hop_labels=False)
    '<e> character role'
    >>> get_property_str_representation({'canonical_right': 'Indiana', 'hopUp': 'P1001v', 'kbID': 'P39v', 'type': 'direct'}, {'P39': 'position held', 'P1001':'applies to territorial jurisdiction'}, use_placeholder=True)
    'position held <x> applies to territorial jurisdiction <e>'
    >>> get_property_str_representation({'canonical_right': 'Facebook','hopDown': 'P17v','kbID': 'P150v','type': 'reverse'}, {'P17':'country', 'P150':'contains administrative territorial entity'}, use_placeholder=True)
    '<e> country <x> contains administrative territorial entity'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct'}, {'P361': 'part of'}, use_placeholder=True)
    'part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Meg Griffin', 'kbID': 'P161v', 'type': 'v-structure'}, {'P161': "cast member"}, use_placeholder=True)
    '<v> cast member <e>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'argmax':'time'}, {'P361': 'part of'}, use_placeholder=True)
    '<a> part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'argmax':'time'}, {'P361': 'part of'}, use_placeholder=True, include_modifiers=False)
    'part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'filter':'importance'}, {'P361': 'part of'}, use_placeholder=True)
    'part of <e> part of <x>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'direct', 'filter':'importance'}, {'P361': 'part of'}, use_placeholder=False)
    'part of Washington Redskins part of <x>'
    >>> get_property_str_representation({'kbID': 'P69s',  'right': ['Missouri'], \
    'rightkbID': 'Q189', 'type': 'direct', 'num': '2012'}, {'P69': "educated at", 'P131': 'located in'}, use_placeholder=True)
    'educated at <e> <n>'
    >>> get_property_str_representation({'canonical_right': 'Washington Redskins', 'hopDown': 'P361v', 'kbID': 'P361v', 'type': 'reverse'}, {'P361': 'part of'}, use_placeholder=True, mind_direction=False, include_all_hop_labels=False)
    '<r> part of <e>'
    >>> get_property_str_representation({'label': 'netflix genres', 'type': 'direct'},{'P17': "country"}, use_placeholder=True)
    'netflix genres <e>'
    """
    e_type = edge.get('type', 'direct')
    if "label" in edge:
        property_label = edge["label"]
    else:
        p_meta = property2label.get(edge.get('kbID', " ")[:-1], {})
        property_label = base_objects.unknown_el
        if type(p_meta) == dict and len(p_meta) != 0:
            property_label = p_meta.get("label", "") # + " " + " ".join(p_meta.get("altlabel", "")[:5])
            property_label = property_label.strip()
        elif type(p_meta) == str:
            property_label = p_meta

    e_arg, num = "", ""
    if e_type == 'v-structure':
        property_label = "<v> " + property_label
    elif e_type == 'reverse' and not mind_direction:
        property_label = "<r> " + property_label
    if include_modifiers:
        e_arg = '<a> ' if 'argmax' in edge else '<i> ' if 'argmin' in edge else ""
        num = "<n>" if "num" in edge else ""
        # if 'filter' in edge and edge['filter'] == 'importance':
        #     e_arg += "<f> "
    hopUp_label, hopDown_label = '', ''
    if include_all_hop_labels and 'hopUp' in edge and edge['hopUp']:
        hopUp_label = "<x> {} ".format(property2label.get(edge['hopUp'][:-1],
                                                          base_objects.unknown_el))
    elif include_all_hop_labels and 'hopDown' in edge and edge['hopDown']:
        hopDown_label = " {} <x>".format(property2label.get(edge['hopDown'][:-1],
                                                            base_objects.unknown_el))
    if e_type.endswith("class"):
        property_label = ""
    if use_placeholder and not e_type.endswith("class"):
        if e_type == "time":
            entity_name = "<n>" if 'right' in edge else ""
        else:
            entity_name = "<e>"
    else:
        if "canonical_right" in edge:
            entity_name = " , ".join(sorted(edge["canonical_right"], key=len)[:1]) if type(edge["canonical_right"]) is list else edge["canonical_right"]
        else:
            entity_name = " ".join(edge.get('right', []))
    base_pattern = "{2}{3}{1}{4} {0} {5}" if mind_direction and e_type in {'reverse'} else "{2}{0} {3}{1}{4} {5}"
    str_representation = base_pattern.format(property_label, entity_name, e_arg, hopUp_label, hopDown_label, num)
    return str_representation.strip()
def get_property_str_representation ( edge , property2label , use_placeholder = False , mind_direction = True , include_modifiers = True , include_all_hop_labels = True ) : e_type = edge . get ( 'type' , 'direct' ) if "label" in edge : property_label = edge [ "label" ] else : p_meta = property2label . get ( edge . get ( 'kbID' , " " ) [ : - 1 ] , { } ) property_label = base_objects . unknown_el if type ( p_meta ) == dict and len ( p_meta ) != 0 : property_label = p_meta . get ( "label" , "" ) # + " " + " ".join(p_meta.get("altlabel", "")[:5]) property_label = property_label . strip ( ) elif type ( p_meta ) == str : property_label = p_meta e_arg , num = "" , "" if e_type == 'v-structure' : property_label = "<v> " + property_label elif e_type == 'reverse' and not mind_direction : property_label = "<r> " + property_label if include_modifiers : e_arg = '<a> ' if 'argmax' in edge else '<i> ' if 'argmin' in edge else "" num = "<n>" if "num" in edge else "" # if 'filter' in edge and edge['filter'] == 'importance': #     e_arg += "<f> " hopUp_label , hopDown_label = '' , '' if include_all_hop_labels and 'hopUp' in edge and edge [ 'hopUp' ] : hopUp_label = "<x> {} " . format ( property2label . get ( edge [ 'hopUp' ] [ : - 1 ] , base_objects . unknown_el ) ) elif include_all_hop_labels and 'hopDown' in edge and edge [ 'hopDown' ] : hopDown_label = " {} <x>" . format ( property2label . get ( edge [ 'hopDown' ] [ : - 1 ] , base_objects . unknown_el ) ) if e_type . endswith ( "class" ) : property_label = "" if use_placeholder and not e_type . endswith ( "class" ) : if e_type == "time" : entity_name = "<n>" if 'right' in edge else "" else : entity_name = "<e>" else : if "canonical_right" in edge : entity_name = " , " . join ( sorted ( edge [ "canonical_right" ] , key = len ) [ : 1 ] ) if type ( edge [ "canonical_right" ] ) is list else edge [ "canonical_right" ] else : entity_name = " " . join ( edge . get ( 'right' , [ ] ) ) base_pattern = "{2}{3}{1}{4} {0} {5}" if mind_direction and e_type in { 'reverse' } else "{2}{0} {3}{1}{4} {5}" str_representation = base_pattern . format ( property_label , entity_name , e_arg , hopUp_label , hopDown_label , num ) return str_representation . strip ( )