Skip to content

Instantly share code, notes, and snippets.

@dannybtran
Created April 3, 2014 14:28
Show Gist options
  • Save dannybtran/9955390 to your computer and use it in GitHub Desktop.
Save dannybtran/9955390 to your computer and use it in GitHub Desktop.

Alternatives

{ :book1 dc:title|rdfs:label ?displayString }

.where([book1, [RDF::DC.title,"|",RDF::RDFS.label], :displayString])

Sequence

{
  ?x foaf:mbox <mailto:alice@example> .
  ?x foaf:knows/foaf:name ?name .
}

.where([:x, RDF::FOAF.mbox, RDF::URI.new("mailto:alice@example")])
.where([:x,[RDF::FOAF.knows,"/",RDF::FOAF.name], :name])

{ 
  ?x foaf:mbox <mailto:alice@example> .
  ?x foaf:knows/foaf:knows/foaf:name ?name .
}

.where([:x, RDF::FOAF.mbox, RDF::URI.new("mailto:alice@example")])
.where([:x,[RDF::FOAF.knows,"/", RDF::FOAF.knows, "/", RDF::FOAF.name], :name])

Inverse

{ <mailto:alice@example> ^foaf:mbox ?x }

.where([RDF::URI.new('mailto:alice@example'), ["^",RDF::FOAF.mbox], :x])

Inverse Sequence

{
  ?x foaf:knows/^foaf:knows ?y .  
  FILTER(?x != ?y)
}

.where([RDF::URI.new('mailto:alice@example'), [RDF::FOAF.knows,"/","^",RDF::FOAF.mbox], :x])
.filter("?x != ?y")

Arbitrary Length

{
  ?x foaf:mbox <mailto:alice@example> .
  ?x foaf:knows+/foaf:name ?name .
}

.where([:x, RDF::FOAF.mbox, RDF::URI.new('mailto@alice@example')])
.where([:x, [RDF::FOAF.knows,"+","/",RDF::FOAF.name], :name])

Alternative Arbitrary Length

{ ?ancestor (ex:motherOf|ex:fatherOf)+ <#me> }

.where([:ancestor, [[RDF::EX.motherOf,"|",RDF::EX.fatherOf],"+"], RDF::URI.new("#me")])

All Resources and their Inferred Types

{ ?x rdf:type/rdfs:subClassOf* ?type }

.where([:x, [RDF.type, "/", RDF::RDFS.subClassOf, "*"], :type])

SubProperty

{ ?x ?p ?v . ?p rdfs:subPropertyOf* :property }

.where([:x,:p,:v])
.where([:p, [RDF::RDFS.subPropertyOf,"*"], :property])

Negated

{ ?x !(rdf:type|^rdf:type) ?y }

.where([:x, ["!",[RDF.type,"|","^",RDF.type]], :y])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment