Skip to content

Instantly share code, notes, and snippets.

@lawlesst
lawlesst / search_z3950.py
Created July 23, 2011 13:09
Sample Z39.50 search with Python.
"""
Simple script to search a Z39.50 target using Python
and PyZ3950.
"""
from PyZ3950 import zoom
ISBNs = ['9781905017799', '9780596513986']
@lawlesst
lawlesst / rdflib_neptune.py
Created March 15, 2019 20:05
Connect RDFLib's SPARQL Store to Amazon Neptune
"""
RDFLib SPARQLStore wrapper for use with Neptune
"""
import sys
import os
import warnings
from rdflib import URIRef, Graph, ConjunctiveGraph
@lawlesst
lawlesst / cleaner.py
Created November 19, 2012 14:29
cleaning invalid characters from xml
def invalid_xml_remove(c):
#http://stackoverflow.com/questions/1707890/fast-way-to-filter-illegal-xml-unicode-chars-in-python
illegal_unichrs = [ (0x00, 0x08), (0x0B, 0x1F), (0x7F, 0x84), (0x86, 0x9F),
(0xD800, 0xDFFF), (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF),
(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF), (0x3FFFE, 0x3FFFF),
(0x4FFFE, 0x4FFFF), (0x5FFFE, 0x5FFFF), (0x6FFFE, 0x6FFFF),
(0x7FFFE, 0x7FFFF), (0x8FFFE, 0x8FFFF), (0x9FFFE, 0x9FFFF),
(0xAFFFE, 0xAFFFF), (0xBFFFE, 0xBFFFF), (0xCFFFE, 0xCFFFF),
(0xDFFFE, 0xDFFFF), (0xEFFFE, 0xEFFFF), (0xFFFFE, 0xFFFFF),
@lawlesst
lawlesst / fuseki-fulltext-config.ttl
Last active November 15, 2021 16:45
Minimal working Fuseki TDB with with full text search.
@prefix : <http://localhost/jena_example/#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix text: <http://jena.apache.org/text#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
## Example of a TDB dataset and text index
## Initialize TDB
@lawlesst
lawlesst / .gitignore
Last active October 8, 2021 20:45
Sample notebooks for Constellate: https://constellate.org
.ipynb_checkpoints/*
@lawlesst
lawlesst / rdflib_stardog.py
Last active July 14, 2021 03:38
Example code for working with Stardog from Python.
"""
Example code for connecting to Stardog (http://stardog.com/) with
Python's RDFLib (http://github.com/rdflib).
See longer description: http://lawlesst.github.io/notebook/rdflib-stardog.html
"""
@lawlesst
lawlesst / tesseract-setup.ipynb
Last active June 3, 2021 15:33
Constellate Binder Tesseract
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lawlesst
lawlesst / .gitignore
Last active July 7, 2020 16:06
tdm-pilot.org gists
datasets/
.ipynb*
@lawlesst
lawlesst / oaipmh_marc_harvest.py
Created October 28, 2011 20:57
OAI-PMH harvesting with Python
"""
Harvest MARC records via OAI-PMH.
"""
#Mostly from - http://code.google.com/p/oldmapsonline/source/browse/trunk/oai-pmh/oaipmh-client-pyoai-pymarc.py
# MarcXML reader - parsing done by pymarc
#Handle utf-8 strings
import codecs, sys
@lawlesst
lawlesst / clean_nbs.py
Last active May 21, 2020 11:28 — forked from cmoscardi/clean_nbs.py
Jupyter Notebook Output Cleaning Script
import io
import sys
from nbformat import read, write
# Handle either stdin or a filename
if __name__ == '__main__':
for filename in sys.argv[1:]:
print(filename, file=sys.stderr)