Skip to content

Instantly share code, notes, and snippets.

@wsalesky
wsalesky / strip-diacritics.xq
Last active October 4, 2017 15:27 — forked from joewiz/strip-diacritics.xq
Strip diacritics, with XQuery
xquery version "3.1";
declare function local:strip-diacritics($string as xs:string) as xs:string {
let $normalized := normalize-unicode($string, 'NFD')
let $stripped := replace($normalized, '\p{M}', '')
return
$stripped
};
declare function local:inspect-diacritics($string as xs:string) as element() {
let $list := ("http://syriaca.org/person/1631", "http://syriaca.org/person/1442")
for $item in $list
let $uri := $item
return
for $idno in fn:collection('/db/apps/srophe-data/data/persons/tei')//tei:person[tei:idno[. = $uri]]
let $name := $idno/tei:persName[@xml:lang="en"][contains(@syriaca-tags,"#syriaca-headword")]
let $newName :=
<persName xmlns="http://www.tei-c.org/ns/1.0" xml:id="{concat('name',substring-after($idno,'/person/'),'-a')}"
xml:lang="en" syriaca-tags="#syriaca-headword">Anonymi {substring-after($idno,'/person/')}</persName>
xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare function local:download-xml($node, $filename) {
response:set-header("Content-Disposition", concat("attachment;
filename=", $filename))
,
response:stream(
$node,
'indent=yes' (: serialization :)
@wsalesky
wsalesky / name-matches.xq
Last active September 2, 2015 17:24 — forked from joewiz/highlight-matches.xq
Repurpose @joewiz highlight-match.xql to do primitive NER on Syriaca.org data. Matches against Syriaca.org English place names. XQuery highlights regex pattern matches in XML while preserving node structure, with XQuery
xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace fn="http://www.w3.org/2005/xpath-functions";
(:
: A simple addaptation of @joewiz highlight-match.xql [https://gist.github.com/joewiz/5937897] for POC of simple NER based on predefined list.
: Allow placeName recognition against a pre determined list of names, in this case uses place names in https://github.com/srophe/srophe-app-data
: Names a wrapped in a placeName tag with a @ref attribute linking them to the authority record in https://github.com/srophe/srophe-app-data
:)
@wsalesky
wsalesky / get-names.xql
Last active August 29, 2015 14:25 — forked from davidamichelson/gist:857733cac083c270013b
Get all Syriac names and English counterparts from Syriaca.org data.
xquery version "1.0";
declare namespace tei="http://www.tei-c.org/ns/1.0";
<root>
{
(
for $place in collection('/db/apps/srophe-data/data/places/tei')//tei:place[tei:placeName[matches(@xml:lang, '^syr')]]
let $id := $place/tei:idno[starts-with(.,'http://syriaca.org/')]/text()
return
<row>
@wsalesky
wsalesky / README.md
Last active August 29, 2015 14:13 — forked from emeeks/README.md

The range sliders at the top change the values for the force-directed algorithm and the buttons load new graphs and apply various techniques. This will hopefully serve as a tool for teaching network analysis and visualization principles during my Gephi courses and general Networks in the Humanities presentations.

Notice this includes a pretty straightforward way to load CSV node and edge lists as exported from Gephi.

It also includes a pathfinding algorithm built for the standard data structure of force-directed networks in D3. This requires the addition of .id attributes for the nodes, however.

Now with Clustering Coefficients!

Also, it loads images for nodes but the images are not in the gist. The code also refers to different network types but the data files on Gist only refer to the transportation network.