Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created November 23, 2021 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruJu/499a35b3d37d439547fbb468c58ed129 to your computer and use it in GitHub Desktop.
Save BruJu/499a35b3d37d439547fbb468c58ed129 to your computer and use it in GitHub Desktop.
findAllOccurrencesOfTerms
/**
* Return all occurences of the given terms in a DStar Dataset
* @see https://github.com/BruJu/PREC
*/
function findAllOccurrencesOfTerms(graph: DStar, terms: RDF.Term[]): RDF.Quad[] {
return terms.flatMap(term => [
...graph.getQuads(term, null, null, $defaultGraph),
...graph.getQuads(null, term, null, $defaultGraph),
...graph.getQuads(null, null, term, $defaultGraph),
...graph.getRDFStarQuads().filter(q => QuadStar.containsTerm(q, term))
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment