Skip to content

Instantly share code, notes, and snippets.

@baskaufs
baskaufs / test_text.txt
Created February 19, 2024 22:24
Some test text to retrive with HTTP GET
Hello from the Internet!
@baskaufs
baskaufs / sparql_classification_gui.py
Created November 9, 2023 17:32
template script for exploring classification relationships using buttons and SPARQL
# sparql_gui, a script for making SPARQL queries from a graphical interface. sparql_gui.py
SCRIPT_VERSION = '0.1.0'
VERSION_MODIFIED = '2023-08-16'
# (c) 2023 Vanderbilt University. This program is released under a GNU General Public License v3.0 http://www.gnu.org/licenses/gpl-3.0
# Author: Steve Baskauf
# For more information, see https://github.com/HeardLibrary/linked-data/tree/master/sparql
# The Sparqler class code is (c) 2022-2023 Steven J. Baskauf
# and released under a GNU General Public License v3.0 http://www.gnu.org/licenses/gpl-3.0
@baskaufs
baskaufs / sparql_autocomplete.py
Created October 5, 2023 21:02
Python script to acquire autocomplete data via SPARQL queries
from pynput.keyboard import Key, Listener
import requests
import datetime
import time
import json
class Sparqler:
"""Build SPARQL queries of various sorts
Parameters
@baskaufs
baskaufs / work_to_equivalent_classes.rq
Created October 3, 2023 15:51
SPARQL query to find P31 class for gallery item and equivalent AAT and Nom concepts
SELECT DISTINCT ?work ?workLabel ?class ?classLabel ?otherConcepts ?prefLabel ?nomLabel
WHERE {
#bind(wd:Q102962863 as ?work)
bind(wd:Q104031914 as ?work)
?work rdfs:label ?workLabel.
?work wdt:P31 ?class.
?class rdfs:label ?classLabel.
?class skos:exactMatch ?otherConcepts.
optional {
@baskaufs
baskaufs / mineral_names.json
Last active October 3, 2023 01:58
JSON structure for names consistent with the SKOS-XL extension
{
"@context": {
"literalForm": "http://www.w3.org/2008/05/skos-xl#literalForm",
"prefLabel": "http://www.w3.org/2008/05/skos-xl#prefLabel",
"altLabel": "http://www.w3.org/2008/05/skos-xl#altLabel",
"identifier": "@id",
"language": "http://purl.org/dc/elements/1.1/language",
"source": "http://purl.org/dc/elements/1.1/source",
"nameType": "http://rs.tdwg.org/min/terms/nameType"
},
@baskaufs
baskaufs / google_cloud_image_text_detection.json
Created September 14, 2023 23:51
Output from image-detection test of Google Cloud Image AI
{
"textAnnotations": [
{
"locale": "en",
"description": "Fight World Famine\nenroll in\nThe Boys Working Reserve\nU.S. EMPLOYMENT SERVICE\nAPPLY\nTHER COMPANY, BALTO New You\nDEPARTMENT OF LABOR",
"boundingPoly": {
"vertices": [
{
"x": 26,
"y": 1106
@baskaufs
baskaufs / display_named_graphs.rq
Created September 13, 2023 16:13
Query to use Service Description vocabulary to find metadata on named graphs
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
@baskaufs
baskaufs / construct_parent_classes.rq
Last active September 12, 2023 18:25
Construct triples linking classes for Vanderbilt Gallery artworks to their superclasses
construct {
?class wdt:P279 ?superclass.
?base_class rdfs:label ?base_label.
?superclass rdfs:label ?super_label.
}
where {
# Q102971873 is "Soba-choko (noodle sauce cup) with a design in blue underglaze of a stylized rock and grasses"
bind (wd:Q102971873 as ?artwork) # Comment out this line to do all artworks
?artwork wdt:P195 wd:Q18563658. # must be in the Vanderbilt Art Gallery
?artwork wdt:P31 ?base_class. # artwork is an instance of the base class
@baskaufs
baskaufs / construct_artwork_class_graph.rq
Created September 12, 2023 16:54
Construct triples linking Vanderbilt Art Gallery works Wikidata items to the class they are an instance of
construct {
?artwork wdt:P31 ?class.
?artwork rdfs:label ?label.
}
where {
?artwork wdt:P195 wd:Q18563658.
?artwork wdt:P31 ?class.
?artwork rdfs:label ?label.
filter(lang(?label)="en")
}
@baskaufs
baskaufs / broader_types.rq
Created September 12, 2023 15:25
Query of AAT to look at different ways broader subjects are linked
select distinct ?broader_subject ?subject_label ?broader_object ?object_label
from <http://AATOut_2Terms>
from <http://AATOut_HierarchicalRels>
where {
# http://vocab.getty.edu/aat/300043022 is the IRI for "teapots"
bind(<http://vocab.getty.edu/aat/300193015> as ?broader_subject)
?broader_subject gvp:broaderGeneric ?broader_object.