Exemplo n.º 1
0
def entity_tags(entity, authz=None, edge_types=registry.pivots):
    """Do a search on tags of an entity."""
    proxy = model.get_proxy(entity)
    edge_types = registry.get_types(edge_types)
    edge_types = [t for t in edge_types if t != registry.entity]
    graph = Graph(edge_types=edge_types)
    query = graph.query(authz=authz)
    nodes = set()
    for prop, value in proxy.itervalues():
        if prop.type not in graph.edge_types:
            continue
        if prop.specificity(value) < 0.1:
            continue
        nodes.add(Node(prop.type, value))
    for node in nodes:
        query.node(node, count=True)
    for res in query.execute():
        field = res.node.type.group
        if res.count is not None and res.count > 1:
            yield (field, res.node.value, res.count)
Exemplo n.º 2
0
 def __init__(self,
              edge_types: Iterable[PropertyType] = registry.pivots) -> None:
     types = registry.get_types(edge_types)
     self.edge_types = [t for t in types if t.matchable]
     self.flush()
Exemplo n.º 3
0
 def __init__(self, edge_types=registry.pivots):
     edge_types = registry.get_types(edge_types)
     self.edge_types = [t for t in edge_types if t.matchable]
     self.flush()
Exemplo n.º 4
0
 def __init__(self, edge_types: Iterable[str] = DEFAULT_EDGE_TYPES) -> None:
     super(GraphExporter, self).__init__()
     types = registry.get_types(edge_types)
     self.graph = Graph(edge_types=types)