Another ruinous addition to Wilbur
Wilbur won't let you query for literals. This, for example, won't work:The reason why, of course, is that the triple index for objects is a Lisp hash table. This has four options for comparison: EQ, EQL, EQUAL, and EQUALP. None of these will successfully compare a wilbur::literal with a string with the same value, and Wilbur makes EQ hash tables anyway.(query nil nil "Richard")
What we really want is a hash table with a smarter equality function; not even literal=, but one that also compares nodes and strings. Thankfully, Ingvar Mattsson has his genhash library, which allows hash tables with custom hash/equality functions.
70 lines of Common Lisp later and we have this file, which sets things up to allow queries over literals.
Now I await the inevitable backlash!(setf *db* (make-instance 'db))
#<DB size 78 {99D7B19}>
* (db-add-triple *db* (triple !rdf:type !rdfs:label (db-make-literal *db* "type")))
#<TRIPLE !rdf:type !rdfs:label #<LITERAL "type" {9A0B5B9}> {9A0B631}>
T
* (query nil nil "type")
(#<TRIPLE !rdf:type !rdfs:label #<LITERAL "type" {9A0B5B9}> {9A0B631}>)
Posted at 2005-05-27 14:43:03 by Richard • Link to Another ruinous ad…
Comments, trackbacks.
