gensim logo

gensim
gensim tagline

Get Expert Help

• machine learning, NLP, data mining

• custom SW design, development, optimizations

• corporate trainings & IT consulting

summarization.graph – TextRank graph

summarization.graph – TextRank graph

class gensim.summarization.graph.Graph

Bases: gensim.summarization.graph.IGraph

Implementation of an undirected graph, based on Pygraph

DEFAULT_LABEL = ''
DEFAULT_WEIGHT = 0
LABEL_ATTRIBUTE_NAME = 'label'
WEIGHT_ATTRIBUTE_NAME = 'weight'
add_edge(edge, wt=1, label='', attrs=None)
add_edge_attribute(edge, attr)
add_edge_attributes(edge, attrs)
add_node(node, attrs=None)
del_edge(edge)
del_edge_labeling(edge)
del_node(node)
edge_attributes(edge)
edge_weight(edge)
edges()
get_edge_properties(edge)
has_edge(edge)
has_node(node)
neighbors(node)
nodes()
set_edge_properties(edge, **properties)
class gensim.summarization.graph.IGraph

Bases: object

Represents the interface or contract that the graph for TextRank should implement.

add_edge(edge, wt=1, label='', attrs=None)

Add an edge to the graph connecting two nodes.

An edge, here, is a pair of nodes like C{(n, m)}.

@type edge: tuple @param edge: Edge.

@type wt: number @param wt: Edge weight.

@type label: string @param label: Edge label.

@type attrs: list @param attrs: List of node attributes specified as (attribute, value) tuples.

add_node(node, attrs=None)

Add given node to the graph.

@attention: While nodes can be of any type, it’s strongly recommended to use only numbers and single-line strings as node identifiers if you intend to use write().

@type node: node @param node: Node identifier.

@type attrs: list @param attrs: List of node attributes specified as (attribute, value) tuples.

del_node(node)

Remove a node from the graph.

@type node: node @param node: Node identifier.

edge_weight(edge)

Get the weight of an edge.

@type edge: edge @param edge: One edge.

@rtype: number @return: Edge weight.

edges()

Return all edges in the graph.

@rtype: list @return: List of all edges in the graph.

has_edge(edge)

Return whether an edge exists.

@type edge: tuple @param edge: Edge.

@rtype: boolean @return: Truth-value for edge existence.

has_node(node)

Return whether the requested node exists.

@type node: node @param node: Node identifier

@rtype: boolean @return: Truth-value for node existence.

neighbors(node)

Return all nodes that are directly accessible from given node.

@type node: node @param node: Node identifier

@rtype: list @return: List of nodes directly accessible from given node.

nodes()

Return node list.

@rtype: list @return: Node list.