SPARQL engine (ask.chaipat.cc)
Component
The SPARQL engine in src/kg.js stores the knowledge graph of ask.chaipat.cc and answers SPARQL SELECT queries over it, in plain JavaScript, inside the visitor's browser. Factual answers can be checked in the SPARQL tab, which shows the queries used with their rows and timings. Finding an entity or choosing its live site, about page or source code is a separate catalog operation, not a reason to invent a SPARQL answer.
What it supports
PREFIX,SELECTwithDISTINCTand*- triple patterns with
;,,anda OPTIONAL,UNIONand nested groupsFILTERwith comparisons,&&,||,!, and the functionsCONTAINS,LCASE,UCASE,STR,REGEX,STRSTARTS,STRENDS,BOUND,ISIRI,ISLITERAL,YEARandSUBSTRORDER BY(numbers compare as numbers; rows without the value go last),LIMIT,OFFSET
How it works
Terms are kept in one short text form (id:JAIST, "2024-07"), and three indexes (by subject, predicate and object) let each pattern start from its smallest candidate list. The graph is loaded together with its ontology: the reasoner adds the facts the ontology implies, and a query can be run on the stated facts alone, which is how the SPARQL tab tells how many rows came from reasoning. The Turtle parser reads the files.
src/resources.js is another pure consumer of this graph API. It gathers typed entities, their labels and aliases, descriptions and relationships into a catalog, and reads explicit live and repository properties for resource actions. Its local about addresses do not depend on whether a written wiki article exists. The graph remains the source of truth in both Node.js and the browser; the generated search catalog is only a snapshot, not a second database or a replacement query engine.
The shared answer composer in src/answer.js can cite graph facts it actually reads, such as a work's technologies, description or declared source files. Those graph citations are evidence for the single answer, not a list of every related entity or resource destination. A wiki passage or Wikipedia extract used instead carries its own source.
The knowledge-state manifest covers this engine, the parser and reasoner, the answer/resource modules, the ontology and graph inputs. Validation rejects changed code or schema without a rebuild and checks generated graph and search contents read-only. cj:implementationDigest records the bytes of a component's declared source files in the generated wiki graph. These are freshness checks, not a proof that SPARQL support or this explanation is correct; behavior changes still require review.
In the knowledge graph
SPARQL engine and the 3 things it is linked to. Open any dot for its page, or explore it in the full graph.
As data
Everything on this page is read from triples in the knowledge graph. These are the 10 it states about SPARQL engine, and 1 more its ontology implies; the console runs SPARQL over the whole graph, here in your browser.
@prefix id: <https://ask.chaipat.cc/id/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix cj: <https://ask.chaipat.cc/ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . id:SiteSPARQL a cj:Component ; rdfs:label "SPARQL engine (ask.chaipat.cc)" ; cj:shortLabel "SPARQL engine" ; cj:componentOf id:ThisSite ; cj:sourceFile "src/kg.js" ; cj:uses id:SPARQL , id:JavaScript ; cj:description "Runs SPARQL SELECT queries (with OPTIONAL, UNION, FILTER and ORDER BY) over the whole graph in the visitor's browser. The queries used for factual answers are shown in the SPARQL tab; entity resource selection reads the same graph separately." ; cj:article "https://ask.chaipat.cc/wiki/SiteSPARQL"^^xsd:anyURI ; cj:implementationDigest "sha256:aacf48bcf79942e98c61848e3d88979b9446e6b023a050854f57c032f5f67d64" .