Skip to content

Instantly share code, notes, and snippets.

@egonw
Created February 27, 2009 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egonw/71677 to your computer and use it in GitHub Desktop.
Save egonw/71677 to your computer and use it in GitHub Desktop.
var ons = rdf.createStore()
// output: RDFStore: 0 triples
rdf.importURL(ons,
"http://github.com/egonw/onssolubility/raw/master/ons.solubility.rdf/ons.rdf")
// output: RDFStore: 1206 triples
var results = rdf.sparql(ons, "PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
"PREFIX ons: <http://spreadsheet.google.com/plwwufp30hfq0udnEmRD1aQ/onto#> " +
"SELECT DISTINCT ?same WHERE { " +
" ?solvent a ons:Solvent . " +
" ?solvent owl:sameAs ?same" +
"}"
)
for (i=0; i<results.size(); i++) {
var row = results.get(i);
for (j=0; j<row.size(); j++) {
// use the owl:sameAs to find more triples
var uri = row.get(j);
print("Adding " + uri + "...\n");
rdf.importURL(ons, uri);
}
}
rdf.sparql(ons, "PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
"PREFIX ons: <http://spreadsheet.google.com/plwwufp30hfq0udnEmRD1aQ/onto#> " +
"PREFIX rdfonm: <http://rdf.openmolecules.net/#> " +
"PREFIX dc: <http://purl.org/dc/elements/1.1/> " +
"SELECT DISTINCT ?title ?chebi WHERE { " +
" ?solvent a ons:Solvent . " +
" ?solvent dc:title ?title . " +
" ?solvent owl:sameAs ?same ." +
" ?same rdfonm:chebiid ?chebi" +
"}"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment