VectorSelection
#
Bases: object
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 distance of 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
list
|
List of the edge ids or edges to add. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
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 distance of 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
list
|
List of the node ids or nodes to add. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
append(selection)
#
Add all the documents in a specified selection to the current selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selection
|
VectorSelection
|
Selection to be added. |
required |
Returns:
| Type | Description |
|---|---|
VectorSelection
|
The combined selection. |
edges()
#
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:
| Name | Type | Description | Default |
|---|---|---|---|
hops
|
int
|
The number of hops to carry out the expansion. |
required |
window
|
Tuple[int | str, int | str]
|
The window that documents need to belong to in order to be considered. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
expand_edges_by_similarity(query, limit, window=None)
#
Add to the selection the limit adjacent edges closest to query
This function has the same behaviour as expand_entities_by_similarity but it only considers edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | list
|
The text or the embedding to calculate the distance from. |
required |
limit
|
int
|
The maximum number of new edges to add. |
required |
window
|
Tuple[int | str, int | str]
|
The window that documents need to belong to in order to be considered. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
expand_entities_by_similarity(query, limit, window=None)
#
Add to the selection the limit adjacent entities closest to query
The expansion algorithm is a loop with two steps on each iteration:
- All the entities 1 hop away of some of the entities included on the selection (and not already selected) are marked as candidates.
- Those candidates are added to the selection in ascending distance from
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:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | list
|
The text or the embedding to calculate the distance from. |
required |
limit
|
int
|
The number of documents to add. |
required |
window
|
Tuple[int | str, int | str]
|
The window that documents need to belong to in order to be considered. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
expand_nodes_by_similarity(query, limit, window=None)
#
Add to the selection the limit adjacent nodes closest to query
This function has the same behaviour as expand_entities_by_similarity but it only considers nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | list
|
The text or the embedding to calculate the distance from. |
required |
limit
|
int
|
The maximum number of new nodes to add. |
required |
window
|
Tuple[int | str, int | str]
|
The window that documents need to belong to in order to be considered. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|