跪拜 Guibai
← All articles
Data Visualization

Modeling a Classical Chinese Novel as a Knowledge Graph: Data, Ontology, and One 4.4 MB HTML

By wangweilong334 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Domain knowledge graphs rarely have to model fictional timelines and debated geography; this project shows a workable approach by flagging 42 of 71 dates as estimated, marking disputed map points as dashed lines, and packing the entire dataset into a single offline-capable HTML file.

Summary

The project, built by a developer who goes by wangweilong334, takes the Jiaxu edition with Zhiyanzhai commentary as its base text and extracts 623,645 characters of body text plus 5,634 commentary entries across 80 chapters. All structured data lives in a JSON file with 115 people, 54 places, 51 events, 163 relations, and 71 day records. The ontology layer follows classic TBox/ABox design: 7 top-level classes and 22 subclasses, with 21 object properties linking people, events, and places. Parsing the accompanying Turtle file yields 3,428 RDF triples.

Time is handled by anchoring to a fictional 'Red Chamber Year 1' and mapping lunar dates and two-hour watch markers to numeric values; 42 of the 71 day records carry an 'estimated' flag. Geography uses modern provincial boundaries as a base, with disputed locations drawn as dashed lines and labeled as conjectural. The final deliverable is a single 4.4 MB index.html with all data, 255 base64-embedded illustrations, and no external URLs, so it opens by double-clicking and works offline.

Takeaways
— The base text is the Jiaxu edition with Zhiyanzhai commentary; the project extracts 623,645 characters of body text and 5,634 comments across 80 chapters.
— The structured JSON holds 115 people, 54 places, 51 events, 163 relations, 117 poems/lyrics, and 71 day records.
— The OWL ontology has 7 top-level classes, 22 subclasses, and 21 object properties; the Turtle file parses to 3,428 RDF triples.
— 42 of the 71 daily records are flagged `est: true` because the original text only implies the date; 29 records include modern clock times for written hour markers.
— The final index.html is about 4.4 MB, embedding 255 base64 images and all data with no external URLs.
— Person relations use four-tuples and map to common ontology properties through `onto.rel2prop`, letting the page show fine-grained terms and the graph aggregate by category.
Conclusions

The gap between the 3,311 triples displayed in the graph and the 3,428 parsed from the Turtle file shows that UI counts and data counts can diverge; the author exposes that discrepancy instead of smoothing it over.

Marking inferred dates and disputed map locations as 'estimated' or 'doubtful' keeps a humanities dataset honest when it becomes machine-readable; without those flags, graph queries would treat speculation as fact.

Choosing a single self-contained HTML file trades initial size for zero-friction distribution and offline availability, a practical pattern for archival or teaching tools.

Concepts & terms
TBox/ABox
The two layers of an ontology: TBox (terminological box) defines classes and properties, ABox (assertional box) contains concrete instances. The project uses this split to separate the model from the data.
RDF triple
The atomic unit of data in the Resource Description Framework, expressed as subject-predicate-object. The project's knowledge graph is stored as 3,428 such triples.
Object property
In OWL, a property that links an instance to another instance, such as :jiamu :血亲眷属 :baoyu, as opposed to a data property that links to a literal value.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗