This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import unicode_literals | |
| from collections import defaultdict | |
| from io import StringIO | |
| from rdflib import URIRef, Literal, Variable | |
| def unroll(triples, vars=None): | |
| """ | |
| Convert list of tuples specifying triples with repeat subjects or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getdate(f): | |
| try: | |
| with file(f) as x: | |
| exif=EXIF.process_file(x, stop_tag="DateTimeOriginal") | |
| return exif["EXIF DateTimeOriginal"].values | |
| except: | |
| return None | |
| def noext(f): | |
| """ remove ALL extensions from filename (os.path.splitext only removes last) """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPARQL source-highlight language definition file | |
| # Author: Gunnar Aastrand Grimnes | |
| # e-Mail: gunnar.grimnes < AT > dfki.de | |
| # the fields used for things is pretty arbitrary, but it makes for nice HTML output | |
| # source-highlight -f latexcolor --lang-def SPARQL.lang -s SPARQL inputdoc.sparql | |
| keyword = "SELECT|WHERE|INSERT|DELETE|FILTER|GROUP BY" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # N3 source-highlight language definition file | |
| # Author: Gunnar Aastrand Grimnes | |
| # e-Mail: gunnar.grimnes < AT > dfki.de | |
| # the fields used for things is pretty arbitrary, but it makes for nice HTML output | |
| # source-highlight -f latexcolor --lang-def n3.lang thesis/examples/bibtexrdf2.n3 | |
| keyword = "prefix|a" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "metadata": { | |
| "name": "allqueries" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rdflib import Graph | |
| g = Graph() | |
| g.parse('http://datahub.io/dataset/semanticquran'); | |
| query = """ | |
| SELECT ?preposition sample(?verseTextAr) WHERE { | |
| ?word gold:PartOfSpeechProperty olia-ar:Preposition; | |
| skos:prefLabel ?preposition; | |
| dcterms:isPart ?verse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def re_sub(pattern, replacement, string): | |
| def _r(m): | |
| # Now this is ugly. | |
| # Python has a "feature" where unmatched groups return None | |
| # then re.sub chokes on this. | |
| # see http://bugs.python.org/issue1519638 | |
| # this works around and hooks into the internal of the re module... |
NewerOlder