Example #1
0
def fill_ve(line, datatype: str, VERTEXS, EDGES):
    line = re.split(':|,|->', line.strip(',; \t'))
    line = list(map(lambda i: i.strip(' ()"'), line))
    value = ttypes.Value()
    assert datatype != 'none'
    if datatype == 'player':
        vertex = create_vertex_player(line)
        key = utf8s(vertex.vid)
        if key in VERTEXS:
            temp = VERTEXS[key].get_vVal()
            temp.tags.append(vertex.tags[0])
            temp.tags.sort(key=lambda x: x.name)
            value.set_vVal(temp)
            VERTEXS[key] = value
        else:
            value.set_vVal(vertex)
            VERTEXS[key] = value
    elif datatype == 'team':
        vertex = create_vertex_team(line)
        value.set_vVal(vertex)
        key = utf8s(vertex.vid)
        VERTEXS[key] = value
    elif datatype == 'bachelor':
        vertex = create_vertex_bachelor(line)
        key = utf8s(vertex.vid)
        if key in VERTEXS:
            temp = VERTEXS[key].get_vVal()
            temp.tags.append(vertex.tags[0])
            temp.tags.sort(key=lambda x: x.name)
            value.set_vVal(temp)
            VERTEXS[key] = value
        else:
            value.set_vVal(vertex)
            VERTEXS[key] = value
    elif datatype == 'serve':
        edge = create_edge_serve(line)
        value.set_eVal(edge)
        key = edgekey(edge)
        EDGES[key] = value
    elif datatype == 'like':
        edge = create_edge_like(line)
        value.set_eVal(edge)
        key = edgekey(edge)
        EDGES[key] = value
    elif datatype == 'teammate':
        edge = create_edge_teammate(line)
        value.set_eVal(edge)
        key = edgekey(edge)
        EDGES[key] = value
    else:
        raise ValueError('datatype is {}'.format(datatype))
Example #2
0
def edgekey(edge):
    return utf8s(edge.src) + utf8s(edge.dst) + utf8s(edge.name) \
        + str(edge.ranking)
Example #3
0
def edgekey(edge):
    return utf8s(edge.src.get_sVal()) + utf8s(edge.dst.get_sVal()) + utf8s(edge.name) \
        + str(edge.ranking)