Skip to content

Instantly share code, notes, and snippets.

@justin2004
justin2004 / a.sh
Last active October 24, 2021 17:11
NLP dates and SPARQL
curl --silent -H 'Accept: text/csv' 'http://localhost:3000/sparql.anything' \
--data-urlencode 'query=
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX ns: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix xhtml: <http://www.w3.org/1999/xhtml#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX fn: <java:datething.core.proxy$org.apache.jena.sparql.function.>
# this approach from the book favors making properties for each kind of participation
_:event1 a ex:Conference;
dc:title "Lego Hack Day";
ex:organizer ex:mary;
ex:attendee ex:bob;
ex:sponsor ex:legoinc;
ex:location ex:conferenceCentre.
@justin2004
justin2004 / 1_notes.txt
Last active October 28, 2021 00:21
my notes on "RML-star: A Declarative Mapping Languagefor RDF-star Generation"
# paper https://biblio.ugent.be/publication/8724424/file/8724427
"However, no mapping language supports the generation of RDF-star graphs so far."
Apache Jena SPARQL-star constructs do: https://jena.apache.org/documentation/rdf-star/.
You can generate RDF-star graphs with SPARQL-star construct statements. SPARQL/SPARQL-star construct statements
*are* mappings from graphs to graphs. If you can express mappings with SPARQL/SPARQL-star that seems like it passes
the test for being a mapping language.
@justin2004
justin2004 / example.sh
Created December 20, 2021 14:27
python nltk from clojure -- error
root@parens:/mnt# cat project.clj
(defproject nltk-work "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[clj-python/libpython-clj "2.003"]
[org.clojure/clojure "1.10.0"]]
:repl-options {:init-ns nltk-work.core})
@justin2004
justin2004 / 0_overview.txt
Last active February 19, 2022 13:51
using jsonld framing
the goal
(https://twitter.com/yamalight/status/1488183981887696903?s=20&t=Ku7RU7QTOoMTm5Ojxb9FUA)
is to start with 1_input.ttl and arrive at 2_desired_output.json.
first, we transform 1_input.ttl with a sparql construct query: 3_query.rq.
then we take the output of that construct query (4_after_construct.ttl) and
apply this (5_frame.json) jsonld frame against it.
NOTE: you can use https://json-ld.org/playground/1.0/ to apply the jsonld
frame but i used apache jena's org.apache.jena.riot.writer.JsonLDWriter.
@justin2004
justin2004 / 0_README.md
Last active January 2, 2023 15:55
RDFS Reasoner Challenge (Tbox with 3M triples)

RDFS Reasoner Challenge (~3M Tbox triples, 1 Abox triple)

Goal

The goal is simple: infer class membership (using rdfs:subClassOf and rdf:type predicates). Don't do it with a property path or something. You must let the reasoner do it.

Attempts

I've tried to do this with a few reasoners. All unsuccessful.

  • Apache Jena wasn't able to do it with 12GB of RAM.
  • Stardog wasn't able to do it with 12GB of RAM.
@justin2004
justin2004 / 0.md
Last active April 6, 2022 13:33
jdb
justin@parens:~/repos/mine/forks/new/sparql.anything$ cat a.txt 
next
qtp90045638-25[1] read /app/a.txt
*** Reading commands from /app/a.txt
@justin2004
justin2004 / DISCUSSION.md
Created July 19, 2022 13:17
discussion: Shipwreck Cafe's sign out front

Does anyone know the name of the artist that designed the ship in the bottle used on the cafe's logo?

@justin2004
justin2004 / a.rq
Last active August 9, 2022 20:32
owl:intersectionOf deductions
# https://twitter.com/quoll/status/1556831573370175489?s=20&t=R5BxG0YCqncmHW_AG7cBeg
# "If something is an instance of *every* class described in an owl:intersectionOf then
# it can be inferred to be an instance of the intersection."
#
# this query doesn't handle chaining of this rule (you'd have to just run it, insert the triples, then continue until
# no more results)
#
# also i used a construct so the results can be seen
PREFIX : <http://example.com/>
@justin2004
justin2004 / 0_readme.md
Last active September 20, 2022 12:18
RDFox reasoning vs Apache Jena reasoning

Apache Jena's OWL reasoner imports tbox.ttl and abox.ttl then derives jena_output_subset.ttl as expected.

RDFox won't import tbox.ttl and produce derivations. But it looks like OWL 2 RL recognizes:

  • intersection of class expressions (ObjectIntersectionOf)
  • existential quantification to a class expression (ObjectSomeValuesFrom)
  • existential quantification to an individual (ObjectHasValue)

Which are used in tbox.ttl. From the docs it looks like RDFox supports OWL 2 RL.