ASN SPARQL Endpoint
From JES & Co. Standards
[edit] What is SPARQL?
SPARQL (SPARQL Protocol And RDF Query Language) is two things:
- a structured query language for RDF and
- a protocol for sending SPARQL queries and returning the formatted results.
SPARQL queries:
- Have four query forms:
- SELECT - Returns all, or a subset of, the variables bound in a query pattern match.
- CONSTRUCT - Returns an RDF graph constructed by substituting variables in a set of triple templates.
- ASK - Returns a boolean indicating whether a query pattern matches or not.
- DESCRIBE - Returns an RDF graph that describes the resources found.
- Follow the RDF triple pattern of subject, predicate, object, e.g.:
- http://asn.jesandco.org/resources/D1000333, dc:title, Alabama Course of Study: English Language Arts
- Any non-literal value (URI) that appears in a query must be surrounded by brackets <>, e.g.:
- <http://asn.jesandco.org/resources/D1000333>
- Any literal value (text) that appears in a query must be surrounded by quotes "", e.g.:
- "some text to find"
[edit] What is the ASN SPARQL endpoint?
The ASN SPARQL endpoint allows anyone to make read-only queries (using the SPARQL query language) against the ASN RDF store. A user can request that the endpoint respond in a variety of formats including:
- HTML
- Spreadsheet
- XML
- JSON
- JavaScript
- NTriples
- RDF/XML
- CSV
We currently limit the number of results a single query can request to 1500. If you require a larger result set please contact us.
[edit] How do I access the ASN SPARQL endpoint?
The ASN SPARQL Endpoint is located at: http://sparql.jesandco.org:8890/sparql
You can submit URL encoded SPARQL queries against the endpoint and parse the results in a format you request e.g. (&format=xml, &format=json).
For a complete listing of URL parameters and request formats see the sections: HTTP Request Methods, HTTP Request Parameters and HTTP Response Formats listed here
Example URL encoded SPARQL Query - HTML response:
Example URL encoded SPARQL Query - XML response:
Example URL encoded SPARQL Query - JSON response:
[edit] Are there named graphs in the ASN RDF store?
Yes. Each ASN Standard Document has been loaded into its own named graph. The graph name is the same as the ASN Standard Document URI.
So for example the ASN Standard Document Alabama Course of Study: English Language Arts (http://asn.jesandco.org/resources/D1000333) has also been loaded into the named graph: http://asn.jesandco.org/resources/D1000333
Graphs can be queried as follows:
Goal: Find all grade levels that are used in the Alabama Course of Study: English Language Arts ASN Standard Document by explicitly searching that named graph
SELECT DISTINCT ?grades FROM <http://asn.jesandco.org/resources/D1000333> WHERE { ?s dcterms:educationLevel ?grades }
XML Response:
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="grades"/> </head> <results distinct="false" ordered="true"> <result> <binding name="grades"><uri>http://purl.org/ASN/scheme/ASNEducationLevel/K</uri></binding> </result> <result> <binding name="grades"><uri>http://purl.org/ASN/scheme/ASNEducationLevel/1</uri></binding> </result> ... </results> </sparql>
[edit] Show me some ASN specific SPARQL examples
[edit] Textual Search
[edit] Contains
Goal: Search all ASN statement descriptions where the phrase "chemical reactions" appears with a limit of 15 results.
SELECT * WHERE { ?asnURI dcterms:description ?literalValue. ?literalValue bif:contains "'chemical reactions'". } LIMIT 15
XML Response:
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="asnURI"/> <variable name="literalValue"/> </head> <results distinct="false" ordered="true"> <result> <binding name="asnURI"><uri>http://asn.jesandco.org/resources/S113594B</uri></binding> <binding name="literalValue"><literal xml:lang="en-us">8.3. Broad Concept: Chemical reactions are processes in which atoms are rearranged into different combinations of molecules. As a basis for understanding this concept, students:</literal></binding> </result> <result> <binding name="asnURI"><uri>http://asn.jesandco.org/resources/S1135B81</uri></binding> <binding name="literalValue"><literal xml:lang="en-us">3. Explain how the idea of atoms, as proposed by John Dalton, explains the conservation of matter: In chemical reactions, the number of atoms stays the same no matter how they are arranged, and the mass of atoms does not change significantly in chemical reactions, so their total mass stays the same.</literal></binding> </result> ... </results> </sparql>
[edit] Near
Goal: Search all ASN statement descriptions where the word "waves" is in proximity (+/- 100 words) to the word "ocean" with a limit of 15 results.
SELECT * WHERE { ?asnURI dcterms:description ?literalValue. ?literalValue bif:contains "waves NEAR ocean". } LIMIT 15
XML Response:
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="asnURI"/> <variable name="literalValue"/> </head> <results distinct="false" ordered="true"> <result> <binding name="asnURI"><uri>http://asn.jesandco.org/resources/S103ABA6</uri></binding> <binding name="literalValue"><literal xml:lang="en-us">4. Recognize interactions between the atmosphere and the ocean.<ul> <li>Describing how waves, ocean currents, and tides are generated</li></ul> </literal></binding> </result> <result> <binding name="asnURI"><uri>http://asn.jesandco.org/resources/S104AED5</uri></binding> <binding name="literalValue"><literal xml:lang="en-us">2. Use the elements of time, space, and energy to create an effect through dance. <ul>Example: creating the effect of ocean waves by using contrasts in level, size, and tempo</ul></literal></binding> </result> ... </results> </sparql>
[edit] Wildcard
Goal: Search all ASN statement descriptions that contain a word beginning with "volcan" with a limit of 15 results.
SELECT * WHERE { ?asnURI dcterms:description ?literalValue. ?literalValue bif:contains "'volcan*'". } LIMIT 15
XML Response:
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="asnURI"/> <variable name="literalValue"/> </head> <results distinct="false" ordered="true"> <results distinct="false" ordered="true"> <result> <binding name="asnURI"><uri>http://asn.jesandco.org/resources/S1135C37</uri></binding> <binding name="literalValue"><literal xml:lang="en-us">2. Explain how the surface of the Earth changes over various time scales due to processes, such as erosion and weathering, landslides, volcanic eruptions, earthquakes, and mountain building.</literal></binding> </result> <result> <binding name="asnURI"><uri>http://asn.jesandco.org/resources/S1135BFC</uri></binding> <binding name="literalValue"><literal xml:lang="en-us">5. Describe how climates may have changed abruptly in the past as a result of changes in Earth's crust, such as gas and dust from volcanic eruptions or impacts of meteorites, asteroids, and comets from space.</literal></binding> </result> ... </results> </sparql>
[edit] And/Or
Goal: Search Florida, grade 9 standards that have a statement description containing the word "develop" AND "timeline" and return the description and ASN URI.
select ?asnURI ?description where { ?asnURI dcterms:description ?description; dcterms:isPartOf ?standardDocument. ?standardDocument asn:jurisdiction <http://purl.org/ASN/scheme/ASNJurisdiction/FL>. ?description bif:contains "Develop AND timeline". }
XML Response:
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="asnURI"/> <variable name="description"/> </head> <results distinct="false" ordered="true"> <result> <binding name="asnURI"><uri>http://asn.jesandco.org/resources/S1139838</uri></binding> <binding name="description"><literal xml:lang="en-us">Develop an understanding of how to use and create a timeline.</literal></binding> </result> </results> </sparql>
[edit] Search by Rank
[edit] Text Score
A text score is a composite of matched word frequency and proximity in the matched resource that is assigned to all literal values when the ASN RDF is indexed. So for example, you may search and sort SPARQL results by this text score.
Goal: Search the ASN for standards that contain the words "chemical" AND "saftey" and return those results sorted by the text score (high-to-low).
SELECT ?asnURI ?description ?textScore WHERE { ?asnURI dcterms:description ?description . ?description bif:contains "chemical AND safety" option (score ?textScore) . } order by desc(?textScore) limit 15
[edit] IRI Ranking
[edit] Property Search
[edit] Aggregate Functions
[edit] Count
Goal: Return a count of how many ASN Standard Documents are in the RDF store.
SELECT count(?document) WHERE { ?document rdf:type <http://purl.org/ASN/schema/core/StandardDocument> }
XML Response:
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="callret-0"/> </head> <results distinct="false" ordered="true"> <result> <binding name="callret-0"><literal datatype="http://www.w3.org/2001/XMLSchema#integer">995</literal></binding> </result> </results> </sparql>
[edit] Combinations
[edit] Build Your Own
[edit] Find ASN statements that are: between grades 7-8, "leaf" nodes (no children), contain the text "spell" in the description, part of a published document and limit the return to 15 results.
SELECT ?statementURI ?statementDescription ?standardDocument WHERE { ?statementURI dcterms:educationLevel <http://purl.org/ASN/scheme/ASNEducationLevel/7>; dcterms:educationLevel <http://purl.org/ASN/scheme/ASNEducationLevel/8>; dcterms:isPartOf ?standardDocument; dcterms:description ?statementDescription. ?standardDocument asn:publicationStatus <http://purl.org/ASN/scheme/ASNPublicationStatus/Published>. OPTIONAL {?statementURI gemq:hasChild ?childStatement} FILTER (!bound(?childStatement)) FILTER bif:contains(?statementDescription, "spell") }limit 15
See the results of this query in a HTML table
XML Response
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="statementURI"/> <variable name="statementDescription"/> <variable name="standardDocument"/> </head> <results distinct="false" ordered="true"> <result> <binding name="statementURI"><uri>http://asn.jesandco.org/resources/S101F68C</uri></binding> <binding name="statementDescription"><literal xml:lang="en-us">In writing, use dictionary, spell-check and other resourcesto spell correctly</literal></binding> <binding name="standardDocument"><uri>http://asn.jesandco.org/resources/D1000019</uri></binding> </result> <result> <binding name="statementURI"><uri>http://asn.jesandco.org/resources/S100EC97</uri></binding> <binding name="statementDescription"><literal xml:lang="en-us">PO 7. Spell high frequency words correctly.</literal></binding> <binding name="standardDocument"><uri>http://asn.jesandco.org/resources/D100001E</uri></binding> </result> ... </results> </sparql>
[edit] Find the last 25 documents added to the ASN
SELECT ?documentUri ?date WHERE { ?licenseUri dcterms:created ?date; foaf:primaryTopic ?documentUri. } ORDER by DESC (?date) LIMIT 25
See the results of this query in a HTML table
XML Response
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="documentUri"/> <variable name="date"/> </head> <results distinct="false" ordered="true"> <result> <binding name="documentUri"><uri>http://asn.jesandco.org/resources/D2381866</uri></binding> <binding name="date"><literal datatype="http://www.w3.org/2001/XMLSchema#date">2012-09-03T15:45:57-04:00</literal></binding> </result> <result> <binding name="documentUri"><uri>http://asn.jesandco.org/resources/D2386177</uri></binding> <binding name="date"><literal datatype="http://www.w3.org/2001/XMLSchema#date">2012-08-29T23:28:42-04:00</literal></binding> </result> ... </results> </sparql>
[edit] Where can I learn more about SPARQL?
Here are some helpful online tutorials about getting started with SPARQL: