Skip to content

Instantly share code, notes, and snippets.

View paregorios's full-sized avatar

Tom Elliott paregorios

View GitHub Profile
@paregorios
paregorios / findit.py
Last active April 3, 2017 11:48
How to find all Pleiades URIs that correspond to a Trismegistos place URI
# read in the json and get the graph of places
import json
with open('pleiades-places-latest.json', 'r', encoding='utf-8') as f:
pj = json.load(f)
graph = pj['@graph']
# iterate through the graph and test each place for a TM reference
for place in graph:
references = place['references']
tm_geoids = [r['accessURI'] for r in references if 'trismegistos' in r['accessURI']]
@paregorios
paregorios / 59749_Example_of_new_changes.xml
Created February 10, 2017 21:35
59749_Example_of_new_changes.xml
<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="http://www.stoa.org/epidoc/schema/latest/tei-epidoc.rng" type="xml"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="m59749">
<teiHeader>
<fileDesc>
<titleStmt>
<!-- NEW: Display name -->
<title>name for Display</title>
</titleStmt>
<publicationStmt>
import fiona
with fiona.open(countries_fn, 'r') as f:
countries = list(f)
driver = f.driver
crs = f.crs
schema = f.schema
print(
'Read {} country geometries from "{}". '
'driver: {}, crs: {}, schema: {}'.format(
len(countries), countries_fn, driver, crs, schema))
import json
from shapely.geometry import MultiPoint, MultiPolygon, Point, Polygon, shape
with open(args.placefile, 'r') as f:
pj = json.load(f)
places = []
for i, pd in enumerate(pj['@graph']):
try:
if i >= limit:
break
subprocess.run(
[
'saxon',
'-s:{0}'.format(filepath),
'-xsl:{0}'.format('meta2dc.xsl'),
'-o:{0}'.format(os.path.join(out_dir, 'dublin_core.xml'))
]
)
@paregorios
paregorios / gist:58b186811d1ef1b11497
Created October 29, 2015 17:02
Define custom collation in XSL 2 for Saxon 9.6
<xsl:variable
name="mixed-collation"
select="concat('http://saxon.sf.net/collation?rules=',
encode-for-uri('&lt; 0 &lt; 1 &lt; 2 &lt; 3 &lt; 4 &lt; 5 &lt; 6 &lt; 7 &lt; 8 &lt; 9 &lt; a,A &lt; b,B &lt; c,C &lt; d,D &lt; e,E &lt; f,F &lt; g,G &lt; h,H &lt; i,I &lt; j,J &lt; k,K &lt; l,L &lt; m,M &lt; n,N &lt; o,O &lt; p,P &lt; q,Q &lt; r,R &lt; s,S &lt; t,T &lt; u,U &lt; v,V &lt; w,W &lt; x,X &lt; y,Y &lt; z,Z &amp; A = Á &amp; A = Ä &amp; A = Ẵ &amp; A = Ằ &amp; C = Ç &amp; D = Đ &amp; E = É &amp; E = Ễ &amp; O = Ö &amp; a = à &amp; a = á &amp; a = â &amp; a = ä &amp; ae = æ &amp; c = ç &amp; e = è &amp; e = é &amp; e = ê &amp; i = í &amp; i = î &amp; i = ï &amp; n = ñ &amp; o = ó &amp; o = ô &amp; o = ö &amp; o = ø &amp; u = û &amp; u = ü &amp; c = č &amp; e = ē &amp; g = ğ &amp; i = ĭ &amp; i = İ &amp; i = ı &amp; l = ł &amp; n = ń &amp; o = ō &amp; s = ś &amp; s = ş &amp; S = Š &amp; s = š &amp; H = Ḥ &amp; h = ḥ &amp; H = Ḫ &amp; h = ḫ &amp; K = Ḳ &amp; k = ḳ &amp; s = ṣ &amp; T = Ṭ &amp;
08:21:08,125 INFO StreamingUpdateSolrServer:99 - starting runner: org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer$Runner@10d0dd7
08:21:09,961 ERROR StreamingUpdateSolrServer:296 - error
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at org.apache.commons.httpclient.ChunkedOutputStream.flush(ChunkedOutputStream.java:191)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
Feb 05, 2015 11:57:28 AM org.apache.solr.core.QuerySenderListener newSearcher
INFO: QuerySenderListener sending requests to Searcher@10d8868 main
Feb 05, 2015 11:57:28 AM org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException: no field name specified in query and no defaultSearchField defined in schema.xml
at org.apache.solr.search.SolrQueryParser.checkNullField(SolrQueryParser.java:123)
at org.apache.solr.search.SolrQueryParser.getFieldQuery(SolrQueryParser.java:131)
at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1421)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1309)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1237)
at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1226)
root@isaw2:/usr/local/tomcat-solr/logs
$ export SOLR_SH=/usr/local/tomcat-solr/bin/catalina.sh
root@isaw2:/usr/local/tomcat-solr/logs
$ su -s /bin/sh tomcat -c "$SOLR_SH start"
Using CATALINA_BASE: /usr/local/tomcat-solr
Using CATALINA_HOME: /usr/local/tomcat-solr
Using CATALINA_TMPDIR: /usr/local/tomcat-solr/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat-solr/bin/bootstrap.jar:/usr/local/tomcat-solr/bin/tomcat-juli.jar
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
regularize filenames
"""
import argparse
from functools import wraps
import logging
import os