def graph_properties(graph, distance=2, heuristic=None):
    """ Returns a list of important nodes that are property-of other nodes.
    By default, dislikes is-opposite-of paths.
    A "sun" node might have these direct properties: red, hot, bright, round.
    The algorithm will also find: slow, healthy, dangerous, blue, mysterious, 
    white, exotic, organic, passionate, chaotic, intense, fast, dry.
    """
    if not heuristic:
        heuristic = cost({"is-opposite-of": 10})
    return graph.enumerate_rules("is-property-of", distance, heuristic)
Beispiel #2
0
def graph_properties(graph, distance=2, heuristic=None):
    """ Returns a list of important nodes that are property-of other nodes.
    By default, dislikes is-opposite-of paths.
    A "sun" node might have these direct properties: red, hot, bright, round.
    The algorithm will also find: slow, healthy, dangerous, blue, mysterious, 
    white, exotic, organic, passionate, chaotic, intense, fast, dry.
    """
    if not heuristic:
        heuristic=cost({"is-opposite-of": 10})
    return graph.enumerate_rules("is-property-of", distance, heuristic)
Beispiel #3
0
def graph_objects(graph, distance=2, heuristic=None):
    """ Returns a list of tangible concepts.
    When the root is an object, returns a list of hyponym leaves. 
    For example, for a "tree" cluster: beech, birch, crapabble, dogwood, linden, ...
    When the root is a property, returns a list of objects.
    For example, for a "wild" cluster: landscape, forest, anger, sea, rodeo, ...
    """
    if not heuristic:
        heuristic=cost({"is-opposite-of": 10})
    if graph.root.is_property:
        nodes = graph.enumerate_rules("is-property-of", distance, heuristic, reversed=True)
        nodes = filter(lambda n: not n.is_property, nodes)
    else:
        nodes = graph.specific(proper=False)
    return nodes
def graph_objects(graph, distance=2, heuristic=None):
    """ Returns a list of tangible concepts.
    When the root is an object, returns a list of hyponym leaves. 
    For example, for a "tree" cluster: beech, birch, crapabble, dogwood, linden, ...
    When the root is a property, returns a list of objects.
    For example, for a "wild" cluster: landscape, forest, anger, sea, rodeo, ...
    """
    if not heuristic:
        heuristic = cost({"is-opposite-of": 10})
    if graph.root.is_property:
        nodes = graph.enumerate_rules("is-property-of",
                                      distance,
                                      heuristic,
                                      reversed=True)
        nodes = filter(lambda n: not n.is_property, nodes)
    else:
        nodes = graph.specific(proper=False)
    return nodes