-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blocker - stuck on batchSize implementation
- Loading branch information
Philippe Renzen
committed
Dec 11, 2023
1 parent
3c1a902
commit 3863f85
Showing
6 changed files
with
144 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { NamedNode } from "@rdfjs/types"; | ||
import sparqljs from 'sparqljs' | ||
import { type SelectQuery, type ConstructQuery } from 'sparqljs' | ||
const { Generator } = sparqljs | ||
|
||
/** | ||
* | ||
* @param query SPARQL construct/Select query template with $this | ||
* @param arrayOfNamedNodes an array of named nodes | ||
* @returns a batch SPARQL query | ||
*/ | ||
function getBatchSPARQLQueryString(query: SelectQuery | ConstructQuery, arrayOfNamedNodes: NamedNode[]): string { | ||
let batchQuery: string = '' | ||
for (let index = 0; index < arrayOfNamedNodes.length; index++) { | ||
const value = arrayOfNamedNodes[index].value; | ||
const generator = new Generator(); | ||
console.log(query.prefixes) | ||
if (index === 0){ | ||
batchQuery += generator.stringify(query).replaceAll( | ||
/[?$]\bthis\b/g, | ||
`<${value}>` | ||
); | ||
}else{ | ||
query.prefixes = {} // clearing prefixes | ||
console.log(query.prefixes) | ||
batchQuery += " UNION " + generator.stringify(query).replaceAll( | ||
/[?$]\bthis\b/g, | ||
`<${value}>` | ||
); | ||
} | ||
} | ||
|
||
return batchQuery | ||
} | ||
|
||
export default getBatchSPARQLQueryString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters