Wiki › Component

Turtle parser (ask.chaipat.cc)

Component

The Turtle parser in src/turtle.js reads the knowledge graph of ask.chaipat.cc from RDF Turtle files. It is small, has no dependencies and is strict, and it is plain JavaScript that runs both in the visitor's browser and in the build scripts, so the page, the prerendered wiki and the CV all read the graph the same way.

It supports @prefix and PREFIX, @base and relative IRIs, prefixed names, a, literals in all four quote styles with escapes, language tags and datatypes, numbers and booleans, predicate and object lists, and blank nodes. RDF collections become rdf:first / rdf:rest chains ending in rdf:nil; the ontology uses them for property-chain reasoning.

Before every deploy the same files are also checked with N3.js, an independent parser, so a file that only this parser accepts would be caught.

Parsing records the graph's meaning; it does not decide what a URL is for. The ontology distinguishes cj:liveUrl (an explicit live product destination), cj:repository (source code) and cj:url (a general related link, which can be a publication or store listing). src/resources.js turns those facts into resource actions and supplies every typed entity except the profile with a local wiki about address. The validator checks external URL safety and at most one live destination and repository per entity. No live resource is inferred merely because a general URL was parsed.

Ontology version 1.14 adds cj:implementationDigest, a string-valued component property generated from declared local source files. It is byte provenance, not a statement that code and prose have the same meaning. data/knowledge-state.json separately hashes the parser, shared answer/resource modules, ontology, graph and wiki sources; validation recomputes those hashes and expected generated artifacts without writing. Parser or ontology edits require rebuilding knowledge and reviewing affected descriptions.

The parser itself does not choose citations. The shared answer composer attaches only the graph, focused wiki passage or Wikipedia extract it actually used to one answer. Related entities are not automatically evidence, live/source actions remain separate, and an answer's sources are only what was actually read.

In the knowledge graph

Turtle parser 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 Turtle parser, and 2 more its ontology implies; the console runs SPARQL over the whole graph, here in your browser.

Download
@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:SiteTurtle
    a cj:Component ;
    rdfs:label "Turtle parser (ask.chaipat.cc)" ;
    cj:shortLabel "Turtle parser" ;
    cj:componentOf id:ThisSite ;
    cj:sourceFile "src/turtle.js" ;
    cj:handles id:TurtleFormat ;
    cj:uses id:JavaScript ;
    cj:description "Parses the graph's Turtle files into triples, in the browser and in the build scripts alike." ;
    cj:article "https://ask.chaipat.cc/wiki/SiteTurtle"^^xsd:anyURI ;
    cj:implementationDigest "sha256:6405f1975a45e36256483f927034aed5a37f7f3caa2d721328676f0b01901578" .