From 774d18ed8f651155c3554b9b3851960030f0352f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Michael=20O=2E=20Hegg=C3=B8?= Date: Sat, 6 Dec 2014 21:39:32 +0100 Subject: [PATCH] Add support for Turtle and SPARQL --- .gitmodules | 3 + grammars.yml | 3 + lib/linguist/languages.yml | 15 +++ samples/SPARQL/foaf.sparql | 7 + samples/SPARQL/string-matching.sparql | 40 ++++++ samples/Turtle/gnd-record.ttl | 183 ++++++++++++++++++++++++++ samples/Turtle/rdf-syntax-grammar.ttl | 10 ++ vendor/grammars/turtle.tmbundle | 1 + 8 files changed, 262 insertions(+) create mode 100644 samples/SPARQL/foaf.sparql create mode 100644 samples/SPARQL/string-matching.sparql create mode 100644 samples/Turtle/gnd-record.ttl create mode 100644 samples/Turtle/rdf-syntax-grammar.ttl create mode 160000 vendor/grammars/turtle.tmbundle diff --git a/.gitmodules b/.gitmodules index af8c2d112..79209740d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -546,3 +546,6 @@ [submodule "vendor/grammars/Racket"] path = vendor/grammars/Racket url = https://github.com/soegaard/racket-highlight-for-github +[submodule "vendor/grammars/turtle.tmbundle"] + path = vendor/grammars/turtle.tmbundle + url = https://github.com/peta/turtle.tmbundle diff --git a/grammars.yml b/grammars.yml index bb06d939b..c85b2de62 100644 --- a/grammars.yml +++ b/grammars.yml @@ -452,6 +452,9 @@ vendor/grammars/thrift.tmbundle: - source.thrift vendor/grammars/toml.tmbundle: - source.toml +vendor/grammars/turtle.tmbundle: +- source.sparql +- source.turtle vendor/grammars/verilog.tmbundle: - source.verilog vendor/grammars/x86-assembly-textmate-bundle: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index e1b57dc9a..9f1786638 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2613,6 +2613,14 @@ SCSS: extensions: - .scss +SPARQL: + type: data + tm_scope: source.sparql + ace_mode: text + extensions: + - .sparql + - .rq + SQF: type: programming color: "#FFCB1F" @@ -2970,6 +2978,13 @@ Turing: tm_scope: none ace_mode: text +Turtle: + type: data + extensions: + - .ttl + tm_scope: source.turtle + ace_mode: text + Twig: type: markup group: PHP diff --git a/samples/SPARQL/foaf.sparql b/samples/SPARQL/foaf.sparql new file mode 100644 index 000000000..699360c7e --- /dev/null +++ b/samples/SPARQL/foaf.sparql @@ -0,0 +1,7 @@ +PREFIX foaf: +SELECT ?name ?email +WHERE { + ?person a foaf:Person. + ?person foaf:name ?name. + ?person foaf:mbox ?email. +} diff --git a/samples/SPARQL/string-matching.sparql b/samples/SPARQL/string-matching.sparql new file mode 100644 index 000000000..424ca987c --- /dev/null +++ b/samples/SPARQL/string-matching.sparql @@ -0,0 +1,40 @@ +PREFIX owl: +PREFIX rdf: +PREFIX skos: + +SELECT DISTINCT ?s ?label +WHERE { + SERVICE + { + SELECT DISTINCT ?s ?label ?plabel ?alabel ?hlabel (GROUP_CONCAT(DISTINCT STR(?type)) as ?types) + WHERE { + GRAPH + { + ?s rdf:type + { + ?s rdf:type ?type . + ?s ?prop ?match . + FILTER ( + strstarts(lcase(str(?match)), "test") && !(?match != ?label && strstarts(lcase(str(?label)), "test")) + ) + OPTIONAL { + ?s skos:prefLabel ?label . + FILTER (langMatches(lang(?label), "en")) + } + OPTIONAL { # in case previous OPTIONAL block gives no labels + ?s ?prop ?match . + ?s skos:prefLabel ?label . + FILTER (langMatches(lang(?label), lang(?match))) } + } + FILTER NOT EXISTS { ?s owl:deprecated true } + } + BIND(IF(?prop = skos:prefLabel && ?match != ?label, ?match, "") as ?plabel) + BIND(IF(?prop = skos:altLabel, ?match, "") as ?alabel) + BIND(IF(?prop = skos:hiddenLabel, ?match, "") as ?hlabel) + VALUES (?prop) { (skos:prefLabel) (skos:altLabel) (skos:hiddenLabel) } + } + GROUP BY ?match ?s ?label ?plabel ?alabel ?hlabel ?prop + ORDER BY lcase(str(?match)) lang(?match) + LIMIT 10 + } +} diff --git a/samples/Turtle/gnd-record.ttl b/samples/Turtle/gnd-record.ttl new file mode 100644 index 000000000..ef1d2c352 --- /dev/null +++ b/samples/Turtle/gnd-record.ttl @@ -0,0 +1,183 @@ +@prefix foaf: . +@prefix owl: . +@prefix gndo: . +@prefix xsd: . + + + a ; + foaf:page ; + owl:sameAs , , ; + gndo:gndIdentifier "118514768" ; + gndo:oldAuthorityNumber "(DE-588)1022091077", "(DE-588a)118514768", "(DE-588a)141399074", "(DE-588a)139089691", "(DE-588a)141300248", "(DE-588a)136949541", "(DE-588a)134336232", "(DE-588a)12794544X", "(DE-588a)12736630X", "(DE-588a)12722811X", "(DE-588a)127228098", "(DE-588a)127228101" ; + gndo:variantNameForThePerson "Brêcht, Becton", "Brecht, Bert", "Brecht, Bertolʹ", "Brecht, Berthold", "Brecht, Bertholt", "Brecht, Bertold", "Brecht, B.", "Brecht, Eugen Berthold Friedrich", "Brecht, ...", "Brecht-Eisler, ...", "Becht, Bertolt", "Beituo'erte-Bulaixite", "Berchito, B.", "Brechtas, B.", "Brechts, Bertolts", "Brehd, Berd", "Breht, Bertolt", "Brehts, Bertolts", "Breḳhṭ, Bārṭolṭ", "Brekt, Berṭolṭ", "Brekṭ, Berṭōlṭ", "Breḳṭ, Berṭôlṭ", "Breśṭ, Berṭalṭa", "Breṣṭa, Barṭolṭa", "Brišt, Bartūlt", "Brišt, Birtūld", "Brišt, Birtult", "Buchito, Berutorutu", "Bulaixite, Beituo'erte", "Bulaixite, ...", "Burehito, Berutoruto", "Burehito, ...", "B. B.", "Larsen, Berthold", "Mprecht, Mpertolt", "Mprecht, ...", "Pulaihsit'ê, Peit'oĉrht'ê", "Pulaihsit'ê, ...", "Pŭrehit'ŭ, Peŏt'olt'ŭ", "Bŭrehit'ŭ, Beŏt'olt'ŭ", "برشت، برتولد", "브레히트, 베르톨트", "ברכט, ברטולט", "贝·布莱希特", "布莱希特, 贝", "ブレヒト, ベルトルト" ; + gndo:variantNameEntityForThePerson [ + gndo:forename "Becton" ; + gndo:surname "Brêcht" + ], [ + gndo:forename "Bert" ; + gndo:surname "Brecht" + ], [ + gndo:forename "Bertolʹ" ; + gndo:surname "Brecht" + ], [ + gndo:forename "Berthold" ; + gndo:surname "Brecht" + ], [ + gndo:forename "Bertholt" ; + gndo:surname "Brecht" + ], [ + gndo:forename "Bertold" ; + gndo:surname "Brecht" + ], [ + gndo:forename "B." ; + gndo:surname "Brecht" + ], [ + gndo:forename "Eugen Berthold Friedrich" ; + gndo:surname "Brecht" + ], [ + gndo:forename "..." ; + gndo:surname "Brecht" + ], [ + gndo:forename "..." ; + gndo:surname "Brecht-Eisler" + ], [ + gndo:forename "Bertolt" ; + gndo:surname "Becht" + ], [ gndo:personalName "Beituo'erte-Bulaixite" ], [ + gndo:forename "B." ; + gndo:surname "Berchito" + ], [ + gndo:forename "B." ; + gndo:surname "Brechtas" + ], [ + gndo:forename "Bertolts" ; + gndo:surname "Brechts" + ], [ + gndo:forename "Berd" ; + gndo:surname "Brehd" + ], [ + gndo:forename "Bertolt" ; + gndo:surname "Breht" + ], [ + gndo:forename "Bertolts" ; + gndo:surname "Brehts" + ], [ + gndo:forename "Bārṭolṭ" ; + gndo:surname "Breḳhṭ" + ], [ + gndo:forename "Berṭolṭ" ; + gndo:surname "Brekt" + ], [ + gndo:forename "Berṭōlṭ" ; + gndo:surname "Brekṭ" + ], [ + gndo:forename "Berṭôlṭ" ; + gndo:surname "Breḳṭ" + ], [ + gndo:forename "Berṭalṭa" ; + gndo:surname "Breśṭ" + ], [ + gndo:forename "Barṭolṭa" ; + gndo:surname "Breṣṭa" + ], [ + gndo:forename "Bartūlt" ; + gndo:surname "Brišt" + ], [ + gndo:forename "Birtūld" ; + gndo:surname "Brišt" + ], [ + gndo:forename "Birtult" ; + gndo:surname "Brišt" + ], [ + gndo:forename "Berutorutu" ; + gndo:surname "Buchito" + ], [ + gndo:forename "Beituo'erte" ; + gndo:surname "Bulaixite" + ], [ + gndo:forename "..." ; + gndo:surname "Bulaixite" + ], [ + gndo:forename "Berutoruto" ; + gndo:surname "Burehito" + ], [ + gndo:forename "..." ; + gndo:surname "Burehito" + ], [ gndo:personalName "B. B." ], [ + gndo:forename "Berthold" ; + gndo:surname "Larsen" + ], [ + gndo:forename "Mpertolt" ; + gndo:surname "Mprecht" + ], [ + gndo:forename "..." ; + gndo:surname "Mprecht" + ], [ + gndo:forename "Peit'oĉrht'ê" ; + gndo:surname "Pulaihsit'ê" + ], [ + gndo:forename "..." ; + gndo:surname "Pulaihsit'ê" + ], [ + gndo:forename "Peŏt'olt'ŭ" ; + gndo:surname "Pŭrehit'ŭ" + ], [ + gndo:forename "Beŏt'olt'ŭ" ; + gndo:surname "Bŭrehit'ŭ" + ], [ gndo:personalName "برشت، برتولد" ], [ + gndo:forename "베르톨트" ; + gndo:surname "브레히트" + ], [ + gndo:forename "ברטולט" ; + gndo:surname "ברכט" + ], [ gndo:personalName "贝·布莱希特" ], [ + gndo:forename "贝" ; + gndo:surname "布莱希特" + ], [ + gndo:forename "ベルトルト" ; + gndo:surname "ブレヒト" + ] ; + gndo:preferredNameForThePerson "Brecht, Bertolt" ; + gndo:preferredNameEntityForThePerson [ + gndo:forename "Bertolt" ; + gndo:surname "Brecht" + ] ; + gndo:familialRelationship , , , , , , , , , , , , , , ; + gndo:professionOrOccupation , , , , , , ; + gndo:playedInstrument ; + gndo:gndSubjectCategory , , ; + gndo:geographicAreaCode ; + gndo:languageCode ; + gndo:placeOfBirth ; + gndo:placeOfDeath ; + gndo:placeOfExile , ; + gndo:gender ; + gndo:dateOfBirth "1898-02-10"^^xsd:date ; + gndo:dateOfDeath "1956-08-14"^^xsd:date . + + gndo:preferredNameForThePerson "Brecht, Berthold Friedrich" . + gndo:preferredNameForThePerson "Banholzer, Paula" . + gndo:preferredNameForThePerson "Neher, Carola" . + gndo:preferredNameForThePerson "Banholzer, Frank" . + gndo:preferredNameForThePerson "Berlau, Ruth" . + gndo:preferredNameForThePerson "Steffin, Margarete" . + gndo:preferredNameForThePerson "Zoff, Marianne" . + gndo:preferredNameForThePerson "Weigel, Helene" . + gndo:preferredNameForThePerson "Reichel, Käthe" . + gndo:preferredNameForThePerson "Hiob, Hanne" . + gndo:preferredNameForThePerson "Brecht, Stefan" . + gndo:preferredNameForThePerson "Brecht-Schall, Barbara" . + gndo:preferredNameForThePerson "Schall, Ekkehard" . + gndo:preferredNameForThePerson "Brezing, Joseph Friedrich" . + gndo:preferredNameForThePerson "Brezing, Friederike" . + gndo:preferredNameForTheSubjectHeading "Theaterregisseur" . + gndo:preferredNameForTheSubjectHeading "Dramatiker" . + gndo:preferredNameForTheSubjectHeading "Schauspieler" . + gndo:preferredNameForTheSubjectHeading "Lyriker" . + gndo:preferredNameForTheSubjectHeading "Schriftsteller" . + gndo:preferredNameForTheSubjectHeading "Regisseur" . + gndo:preferredNameForTheSubjectHeading "Drehbuchautor" . + gndo:preferredNameForThePlaceOrGeographicName "Augsburg" . + gndo:preferredNameForThePlaceOrGeographicName "Berlin" . + gndo:preferredNameForThePlaceOrGeographicName "Dänemark" . + gndo:preferredNameForThePlaceOrGeographicName "Schweden" . \ No newline at end of file diff --git a/samples/Turtle/rdf-syntax-grammar.ttl b/samples/Turtle/rdf-syntax-grammar.ttl new file mode 100644 index 000000000..edcd4db27 --- /dev/null +++ b/samples/Turtle/rdf-syntax-grammar.ttl @@ -0,0 +1,10 @@ +@prefix rdf: . +@prefix dc: . +@prefix ex: . + + + dc:title "RDF/XML Syntax Specification (Revised)" ; + ex:editor [ + ex:fullname "Dave Beckett"; + ex:homePage + ] . \ No newline at end of file diff --git a/vendor/grammars/turtle.tmbundle b/vendor/grammars/turtle.tmbundle new file mode 160000 index 000000000..0782b4765 --- /dev/null +++ b/vendor/grammars/turtle.tmbundle @@ -0,0 +1 @@ +Subproject commit 0782b476573a317917fb9b3bbe7e6a68abefa7a5