sparql_query
Run a SPARQL SELECT query against DanNet and return standard SPARQL
JSON results ({"head": ..., "results": {"bindings": [...]}}). The common
prefixes (dn, dns, dnc, dnf, wn, ontolex, lexinfo, skos, rdfs, rdf, owl,
marl, dc, ili, en, enl, cor) are declared automatically. timeout is in
ms (max 15000), max_results at most 100, distinct adds DISTINCT, and
inference selects the model: None tries the base model and retries with
inference on an empty result; True forces inference, which inverse
relations like wn:hyponym and wn:holo_* need; False forces the base model.
Performance rules: anchor every query on a known URI or a word lookup (dn:synset-3047 wn:hypernym ?x, never ?x wn:hypernym ?y alone); never FILTER(CONTAINS(...)) over all labels, look the word up first; make every triple pattern share a variable with another; add LIMIT; prefer VALUES over FILTER for several known URIs; the store also holds the English WordNet (en:), so anchor on dn: or "..."@da to stay in Danish.
Templates: Synsets of a word: SELECT DISTINCT ?synset ?label WHERE { ?entry ontolex:canonicalForm/ontolex:writtenRep "hund"@da . ?entry ontolex:sense/ontolex:isLexicalizedSenseOf ?synset . ?synset rdfs:label ?label } Taxonomic ancestors: SELECT DISTINCT ?ancestor ?label WHERE { dn:synset-3047 wn:hypernym+ ?ancestor . ?ancestor rdfs:label ?label } Hyponyms (needs inference=True, or query the inverse wn:hypernym): SELECT DISTINCT ?hyponym ?label WHERE { ?hyponym wn:hypernym dn:synset-3047 . ?hyponym rdfs:label ?label } Ontological types (an RDF bag): SELECT ?type WHERE { dn:synset-3047 dns:ontologicalType/?pos ?type . FILTER(STRSTARTS(STR(?pos), STR(rdf:_))) } Taxonomic similarity (dnf:path, dnf:lch, dnf:wup score two synsets of the same language and part of speech, 1.0 for identical): SELECT ?synset ?score WHERE { ?synset a ontolex:LexicalConcept . FILTER(STRSTARTS(STR(?synset), STR(dn:))) BIND(dnf:wup(dn:synset-3047, ?synset) AS ?score) } ORDER BY DESC(?score) LIMIT 20
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| timeout | No | ||
| distinct | No | ||
| inference | No | ||
| max_results | No |