Autocomplete (indra_network_search.autocomplete.autocomplete)

An API wrapping SortedStringTrie from pytrie (see https://github.com/gsakkis/pytrie)

class indra_network_search.autocomplete.autocomplete.NodesTrie(*args, **kwargs)[source]

A Trie structure that has case insensitive search methods

case_items(prefix=None, top_n=100)[source]

Case insensitive wrapper around NodeTrie.items()

Parameters:

prefix (Optional[str]) – The prefix to search

Return type:

List[Tuple[str, str, str]]

Returns:

Return a list of (name, namespace, id) tuples

case_keys(prefix=None, top_n=100)[source]

Case insensitive wrapper around NodeTrie.keys()

Parameters:
  • prefix (Optional[str]) – The prefix to search

  • top_n (Optional[int]) – The top ranked entities (by node degree)

Return type:

List[str]

Returns:

Return a list of this trie’s keys

classmethod from_node_names(graph)[source]

Produce a NodesTrie instance from a graph with node names as keys

Parameters:

graph (Union[DiGraph, MultiDiGraph]) – Graph from which nodes should be searchable. It is assumed the nodes are all keyed by strings

Return type:

NodesTrie

Returns:

An instance of a NodesTrie containing the node names of the graph as keys and the corresponding (name, ns, id, node degree) tuple as values

classmethod from_node_ns_id(graph)[source]

Produce a NodesTrie instance from a graph using ns:id as key

Parameters:

graph (Union[DiGraph, MultiDiGraph]) – Graph from which nodes should be searchable. It is assumed the nodes have the attributes ‘ns’ and ‘id’ accessible via g.nodes[node][‘ns’] and g.nodes[node][‘id’]

Return type:

NodesTrie

Returns:

An instance of a NodesTrie containing ns:id of each node of the graph as keys and the corresponding (name, ns, id, node degree) tuple as values