VectorSelection

Methods

MethodDescription
add_edgesAdd all the documents associated with the specified edges to the current selection.
add_nodesAdd all the documents associated with the specified nodes to the current selection.
appendAdd all the documents in a specified selection to the current selection.
edgesReturns the edges present in the current selection.
expandAdd all the documents a specified number of hops away from the selection.
expand_edges_by_similarityAdd the top limit adjacent edges with higher score for query to the selection
expand_entities_by_similarityAdd the top limit adjacent entities with higher score for query to the selection
expand_nodes_by_similarityAdd the top limit adjacent nodes with higher score for query to the selection
get_documentsReturns the documents present in the current selection.
get_documents_with_scoresReturns the documents present in the current selection alongside their scores.
nodesReturns the nodes present in the current selection.

Method Details

add_edges

Signature: add_edges(edges)

Add all the documents associated with the specified edges to the current selection.

Documents added by this call are assumed to have a score of 0.

Parameters

NameTypeDefaultDescription
edgeslist-List of the edge ids or edges to add.

Returns

TypeDescription
None

add_nodes

Signature: add_nodes(nodes)

Add all the documents associated with the specified nodes to the current selection.

Documents added by this call are assumed to have a score of 0.

Parameters

NameTypeDefaultDescription
nodeslist-List of the node ids or nodes to add.

Returns

TypeDescription
None

append

Signature: append(selection)

Add all the documents in a specified selection to the current selection.

Parameters

NameTypeDefaultDescription
selectionVectorSelection-Selection to be added.

Returns

TypeDescription
VectorSelectionThe combined selection.

edges

Returns the edges present in the current selection.

Returns

TypeDescription
list[Edge]List of edges in the current selection.

expand

Signature: expand(hops, window=None)

Add all the documents a specified number of hops away from the selection.

Two documents A and B are considered to be 1 hop away from each other if they are on the same entity or if they are on the same node/edge pair. Provided that two nodes A and C are n hops away of each other if there is a document B such that A is n - 1 hops away of B and B is 1 hop away of C.

Parameters

NameTypeDefaultDescription
hopsint-The number of hops to carry out the expansion.
windowTuple | str, int | str], optionalNoneThe window that documents need to belong to in order to be considered.

Returns

TypeDescription
None

expand_edges_by_similarity

Signature: expand_edges_by_similarity(query, limit, window=None)

Add the top limit adjacent edges with higher score for query to the selection

This function has the same behaviour as expand_entities_by_similarity but it only considers edges.

Parameters

NameTypeDefaultDescription
querystr | list-The text or the embedding to score against.
limitint-The maximum number of new edges to add.
windowTuple | str, int | str], optionalNoneThe window that documents need to belong to in order to be considered.

Returns

TypeDescription
None

expand_entities_by_similarity

Signature: expand_entities_by_similarity(query, limit, window=None)

Add the top limit adjacent entities with higher score for query to the selection

The expansion algorithm is a loop with two steps on each iteration:

  1. All the entities 1 hop away of some of the entities included on the selection (and not already selected) are marked as candidates.
  2. Those candidates are added to the selection in descending order according to the similarity score obtained against the query.

This loops goes on until the number of new entities reaches a total of limit entities or until no more documents are available

Parameters

NameTypeDefaultDescription
querystr | list-The text or the embedding to score against.
limitint-The number of documents to add.
windowTuple | str, int | str], optionalNoneThe window that documents need to belong to in order to be considered.

Returns

TypeDescription
None

expand_nodes_by_similarity

Signature: expand_nodes_by_similarity(query, limit, window=None)

Add the top limit adjacent nodes with higher score for query to the selection

This function has the same behaviour as expand_entities_by_similarity but it only considers nodes.

Parameters

NameTypeDefaultDescription
querystr | list-The text or the embedding to score against.
limitint-The maximum number of new nodes to add.
windowTuple | str, int | str], optionalNoneThe window that documents need to belong to in order to be considered.

Returns

TypeDescription
None

get_documents

Returns the documents present in the current selection.

Returns

TypeDescription
list[Document]List of documents in the current selection.

get_documents_with_scores

Returns the documents present in the current selection alongside their scores.

nodes

Returns the nodes present in the current selection.

Returns

TypeDescription
list[Node]List of nodes in the current selection.