https://github.com/solidlabresearch/hive-thought-rewriter
Rewriting different RSP-QL queries (thoughts) by combining or decomposing in a Hive.
https://github.com/solidlabresearch/hive-thought-rewriter
Last synced: 8 months ago
JSON representation
Rewriting different RSP-QL queries (thoughts) by combining or decomposing in a Hive.
- Host: GitHub
- URL: https://github.com/solidlabresearch/hive-thought-rewriter
- Owner: SolidLabResearch
- License: other
- Created: 2025-05-12T11:14:37.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-06-05T12:45:50.000Z (8 months ago)
- Last Synced: 2025-06-11T17:56:45.183Z (8 months ago)
- Language: TypeScript
- Size: 204 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Citation: CITATION.cff
Awesome Lists containing this project
README
# Hive Thought Rewriter
The library rewrites different RSP-QL queries to either combine or decompose.
## Usage
### Installation
```shell
npm install hive-thought-rewriter
```
## Rewriting Queries by Combining
Different queries in RSP-QL [[1](#footnotes-1)] query format can be specified and combined together to create a single RSP-QL query.
```ts
import {QueryCombiner} from "hive-thought-rewriter";
const combiner = new QueryCombiner();
combiner.addQuery(query1);
combiner.addQuery(query2);
const combined = combiner.combine();
/**
* This will return the RSPQL query and it's different components
* in a object with type Parsed Query
*
* To get the query in string format
*/
const combined_query_string = combiner.ParsedToString(combined);
```
## Rewriting Queries by Decomposing
This is currently not possible and is a work in progress.
## Rewriting the Queries by changing the Window Parameters
```ts
import {RewriteChunkQuery} from "hive-thought-rewriter";
// Define the new window parameters for the query i.e slide is 10 and width is 20
const chunkRewriter = new RewriteChunkQuery(10, 20);
const originalQuery = `PREFIX ex:
REGISTER RStream AS
SELECT (AVG(?age) AS ?averageAge)
FROM NAMED WINDOW ex:w ON STREAM ex:stream [RANGE 10 STEP 5]
WHERE {
WINDOW ex:w {
?person a ex:Employee.
?person ex:hasAge ?age.
}
}`;
const rewrittenQuery = chunkRewriter.rewrite(originalQuery);
/**
* This will return the RSPQL query with the new window parameters as a string
*/
```
## License
This code is copyrighted by [Ghent University - imec](https://www.ugent.be/ea/idlab/en) and released under the [MIT Licence](./LICENCE)
### Footnotes
[1]: RSP-QL Semantics: A Unifying Query Model to Explain Heterogeneity of RDF Stream Processing Systems