Constructor
new SPARQLService(options)
Creates a new SPARQLService
.Creates a new SPARQLService
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| options | Object | Configuration options Properties
 | 
Methods
(async) executeQuery(query) → {Promise.<Object>}
Execute a SPARQL query
.Execute a SPARQL query
Parameters:
| Name | Type | Description | 
|---|---|---|
| query | string | The SPARQL query to execute | 
Returns:
The query results
- Type
- Promise.<Object>
(async) executeUpdate(update) → {Promise.<Response>}
Execute a SPARQL update
.Execute a SPARQL update
Parameters:
| Name | Type | Description | 
|---|---|---|
| update | string | The SPARQL update to execute | 
Returns:
The response
- Type
- Promise.<Response>
(async) exploreGraphFromSubject(subjectUri, depth, limit, graphName) → {Promise.<Array>}
Get graph exploration data for a given subject URI
.Get graph exploration data for a given subject URI
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| subjectUri | string | The subject URI to explore | |
| depth | number | 2 | The depth of exploration (default: 2) | 
| limit | number | 100 | Maximum number of triples to return | 
| graphName | string | The graph name to query | 
Returns:
Array of triples for graph visualization
- Type
- Promise.<Array>
(async) exportForVisNetwork(subjectUri, depth, graphName) → {Promise.<Object>}
Export graph data as vis-network compatible format
.Export graph data as vis-network compatible format
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| subjectUri | string | Starting subject URI | |
| depth | number | 2 | Exploration depth | 
| graphName | string | The graph name to query | 
Returns:
Vis-network compatible data {nodes, edges}
- Type
- Promise.<Object>
(async) fetchResourcesWithEmbeddings(resourceClass, contentPredicate, embeddingPredicate, graphName) → {Promise.<Array>}
Fetch resources with embeddings from the SPARQL store
.Fetch resources with embeddings from the SPARQL store
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| resourceClass | string | null | The class of resources to fetch (optional) | 
| contentPredicate | string | http://schema.org/articleBody | The predicate for resource content | 
| embeddingPredicate | string | http://example.org/embedding/vector | The predicate for resource embeddings | 
| graphName | string | The graph name to query | 
Returns:
The resources with their embeddings
- Type
- Promise.<Array>
(async) getGraphClasses(graphName) → {Promise.<Array>}
Get all classes and their instance counts from the graph
.Get all classes and their instance counts from the graph
Parameters:
| Name | Type | Description | 
|---|---|---|
| graphName | string | The graph name to query | 
Returns:
Array of classes with counts
- Type
- Promise.<Array>
(async) getGraphPredicates(graphName) → {Promise.<Array>}
Get all predicates and their usage counts from the graph
.Get all predicates and their usage counts from the graph
Parameters:
| Name | Type | Description | 
|---|---|---|
| graphName | string | The graph name to query | 
Returns:
Array of predicates with counts
- Type
- Promise.<Array>
(async) getGraphStats(graphName) → {Promise.<Object>}
Get graph statistics
.Get graph statistics
Parameters:
| Name | Type | Description | 
|---|---|---|
| graphName | string | The graph name to query | 
Returns:
Graph statistics
- Type
- Promise.<Object>
getNodeGroup(type) → {string}
Determine node group/color based on RDF type
.Determine node group/color based on RDF type
Parameters:
| Name | Type | Description | 
|---|---|---|
| type | string | The RDF type URI | 
Returns:
Group identifier
- Type
- string
(async) getNodeNeighbors(nodeUri, graphName, limit) → {Promise.<Array>}
Get neighboring nodes for graph exploration
.Get neighboring nodes for graph exploration
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| nodeUri | string | The node URI to get neighbors for | |
| graphName | string | The graph name to query | |
| limit | number | 50 | Maximum number of neighbors | 
Returns:
Array of neighboring nodes
- Type
- Promise.<Array>
getShortLabel(uri) → {string}
Get a short label for display purposes
.Get a short label for display purposes
Parameters:
| Name | Type | Description | 
|---|---|---|
| uri | string | The URI or label | 
Returns:
Short label
- Type
- string
(async) graphExists(graphName) → {Promise.<boolean>}
Check if a graph exists
.Check if a graph exists
Parameters:
| Name | Type | Description | 
|---|---|---|
| graphName | string | The graph name to check | 
Returns:
True if the graph exists and contains data
- Type
- Promise.<boolean>
(async) searchResources(searchText, graphName, limit) → {Promise.<Array>}
Search for resources containing a text pattern
.Search for resources containing a text pattern
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| searchText | string | Text to search for | |
| graphName | string | The graph name to query | |
| limit | number | 20 | Maximum number of results | 
Returns:
Array of matching resources
- Type
- Promise.<Array>
(async) storeEmbedding(resourceUri, embedding, graphName, predicateUri) → {Promise.<boolean>}
Store an embedding for a resource in the SPARQL store
.Store an embedding for a resource in the SPARQL store
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| resourceUri | string | The URI of the resource | |
| embedding | Array.<number> | The embedding vector | |
| graphName | string | The graph name to store in | |
| predicateUri | string | http://example.org/embedding/vector | The predicate to use | 
Returns:
True if successful
- Type
- Promise.<boolean>