No images in this repository’s iceberg at this time
Download raw (1.3 KB)
import re import rdflib from django import template from aacore import app, NS register = template.Library() @register.filter(name='URLpath') def URLpath(value, arg=-1): splitted = value.split("/") arg = int(arg) try: if splitted[arg] == "": arg = arg - 1 return splitted[arg] except IndexError: pass @register.filter(name='uncamel') def uncamel(value): return re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', ' \\1', value).lower().strip('_') @register.inclusion_tag('aacore/partials/bigram_list.html') def bigram_list(): rows = app.graph.query(""" SELECT DISTINCT ?o WHERE { ?s stats:bigram ?o . } ORDER BY lcase(?o) """, initNs=NS) return {'rows': rows} @register.inclusion_tag('aacore/partials/bigram_list.html') def character_list(): rows = app.graph.query(""" SELECT DISTINCT ?o WHERE { ?s stats:hasCharacter ?o . } ORDER BY lcase(?o) """, initNs=NS) return {'rows': rows} @register.inclusion_tag('aacore/partials/bigram_list.html') def oracle_list(): g = app.graph.get_context(rdflib.URIRef("http://kavan.land/statements/zotero/zotero.rdf")) rows = g.query(""" SELECT DISTINCT ?o WHERE { ?s dc:subject ?o . } ORDER BY lcase(?o) """, initNs=NS) return {'rows': rows}