Skip to content

Instantly share code, notes, and snippets.

@lawlesst
lawlesst / demo.html
Created July 13, 2013 22:44
Working with examples of semantic-ko: https://github.com/antoniogarrote/semantic-ko
<!doctype html>
<!--[if lt IE 8]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="no-js ie9 oldie" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>edit publications</title>
prefix publisher journals dois
10.12679 0 0
10.7579 123Doc Education 0 0
10.3731 21st Century COE Program (Toplogical Science and Technology) 1 40
10.5775 A. I. Rosu Cultural Scientific Foundation Fundatia cultural-stiintifica A. I. Rosu 1 80
10.4037 AACN Publishing 2 766
10.1306 AAPG/Datapages 4 21817
10.3183 AB Svensk Papperstidning 1 1550
10.5769 ABEAT - Associacao Brasileira de Especialistas em Alta Tecnologia 1 57
10.7597 ACOPIOS - Revista Iberica de Mineralogia 1 9
@lawlesst
lawlesst / vivo_models.py
Created June 25, 2013 20:27
Sample RDFAlchemy models for use in VIVO. These have been used to create RDF for ingest but will require review and change before using in real code.
class MostSpecificType(rdfSubject):
rdf_type = VITRO.mostSpecificType
class Thing(rdfSubject):
rdf_type = OWL.Thing
label = rdfSingle(RDFS.label)
most_specific_type = rdfSingle(VITRO.mostSpecificType)
class Date(rdfSubject):
rdf_type = VIVO.DateTimeValue
@lawlesst
lawlesst / make_grapy.py
Last active December 17, 2015 10:59
Example of creating individuals with multiple types with RDFAlchemy and RDFLib.
"""
Quick example of creating indivduals with multiple types
using RDFAlchemy or just plain RDFLib.
"""
from rdflib import Namespace, Graph, Literal, RDF, URIRef
from rdfalchemy.rdfSubject import rdfSubject
from rdfalchemy import rdfSingle
@lawlesst
lawlesst / generate_listview.py
Last active August 11, 2017 17:39
A Python script to parse VIVO list view config XML files and issue SPARQL queries contained within them.
"""
Utility script to parse VIVO listViewConfig.xml files.
Requires
- rdflib_sparql
- SPARQLWrapper
Run as
$ python generate_listview.py /path/to/listViewConfig-awardOrHonor.xml
@lawlesst
lawlesst / app.py
Last active December 12, 2015 05:28
Flask app for stackview.
import os
from flask import Flask, url_for
from flask import request, current_app
from flask import jsonify
from flask import render_template
from functools import wraps
from fetch_data import stackview_data, get_by_bib
@lawlesst
lawlesst / merge_resources.py
Created January 30, 2013 18:08
Merge VIVO resoruces.
"""
Script to login to the VIVO interface as use the
'Merge Resources' tool under 'Ingest Tools' in the admin interface.
An incoming CSV file without headers is expected.
- the primary resource URI is in the first column
- the duplicate resource URI is in the second column
This script relies on the python requests package:
http://docs.python-requests.org/en/latest/user/install/
@lawlesst
lawlesst / scan_updates.py
Last active December 11, 2015 11:58
Jython script to scan MARC records exported from III for updates.
"""
Scans III exports and finds records updated within a
particular time period.
Command line options:
-f file
-d days - number of days to go back and look for updates
-o output - directory to store the MARC records.
-s start - start date for updates
-e end - end dates for updates
@lawlesst
lawlesst / export_vivo.py
Last active February 7, 2018 09:30
Jython script to connect to VIVO via SDB and export a model.
"""
Jython script to connect to VIVO via SDB and export a model.
Requires Jython 2.5 or later. Download from: http://www.jython.org/downloads.html
Assumes the VIVO harvester is on your path.
- change the database connection information to point to your VIVO database.
- change the model name to specify the VIVO model you would like to export.
- change the output_file name to the location where you want to save the RDF.
- for larger models you will want to increase the memory available to Java.
@lawlesst
lawlesst / vivordfalchemy.py
Last active June 29, 2017 19:05
Reading and writing RDF for VIVO using RDFAlchemy.
import csv
from pprint import pprint
import urllib
from rdflib import Namespace
from rdfalchemy import rdfSingle
from rdfalchemy.rdfSubject import rdfSubject
from rdflib import Literal, BNode, Namespace, URIRef
from rdflib import RDF, RDFS, Graph, OWL