Skip to content

Instantly share code, notes, and snippets.

Clifford Anderson CliffordAnderson

Block or report user

Report or block CliffordAnderson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View csv-to-jsonl.xqy
xquery version "3.1";
declare namespace xpf = "http://www.w3.org/2005/xpath-functions";
(: Converts a CSV into JSONL, i.e. one JSON object per line :)
let $csv := fetch:text("https://gist.githubusercontent.com/CliffordAnderson/588774dd0fa7d7bb616abd8da478fe76/raw/33395bdb6fce8d215464738f8681b66b130159e9/books.csv") => csv:parse(map { 'header': true() })
for $record in $csv/csv/record
let $key-values :=
for $entry in $record/*
return
@CliffordAnderson
CliffordAnderson / artists.json
Created Oct 27, 2019
Artist Networks from WIkidata
View artists.json
[
{
"artist": "http://www.wikidata.org/entity/Q30160536",
"artistLabel": "František Podešva",
"influenced_by": "http://www.wikidata.org/entity/Q2104325",
"influenced_byLabel": "Jan Preisler"
},
{
"artist": "http://www.wikidata.org/entity/Q63478",
"artistLabel": "Jonah Bokaer",
@CliffordAnderson
CliffordAnderson / ubahn.html
Created Oct 27, 2019
Sample neovis.js page
View ubahn.html
<!doctype html>
<html>
<head>
<title>Neovis.js Simple Example</title>
<style type="text/css">
html, body {
font: 16pt arial;
}
#viz {
@CliffordAnderson
CliffordAnderson / anderson-graph.xml
Created Oct 26, 2019
Clifford Anderson's Scholarly Graph from Atlas
View anderson-graph.xml
<graphml:graphml xmlns:graphml="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:grapml="http://graphml.graphdrawing.org/xmlns" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graphml:graph id="G" edgedefault="directed">
<graphml:node id="F5EFD5A5849581F4CC1B189C11BC7350" labels=":Author">
<graphml:data key="author">Anderson, Clifford Blake</graphml:data>
</graphml:node>
<graphml:node id="7123B0D8EC557EFFE510337C89E6EEBF" labels=":Author">
<graphml:data key="author">Anderson, Clifford Blake, 1970- ("Author of introduction, etc. ")</graphml:data>
</graphml:node>
<graphml:node id="3739280CA94B7DED2A6DA75A9F662CEE" labels=":Author">
<graphml:data key="author">Anderson, Clifford Blake, 1970- (Editor)</graphml:data>
@CliffordAnderson
CliffordAnderson / neo4j-workshop.md
Last active Oct 27, 2019
Graph Analysis for the Humanities
View neo4j-workshop.md

Graph Analysis for the Humanities

An introduction to using graphs to model and analyze data in the humanities

Berea College Workshop

Berea College Logo

A workshop at Bearea College on Wednesday, October 30th sponsored by The Mellon Partners for Humanities Education

Introduction to Neo4j

View graph_gist_artists.adoc

Artistic Influence

Introduction

This graph studies the relations of infuence between artists. The data comes from this query of Wikidata:

View basic-full-text-query.xqy
for $doc in fn:collection("bpp-quarterly")//FullText[.//text() contains text {"jury", "law"} any using stemming]
let $hits := ft:extract($doc[.//text() contains text {"jury", "law"} all using stemming])
let $count := fn:count($hits//mark)
let $record := fn:doc(fn:base-uri($doc))
order by $count descending
return <hit count="{$count}" url="{$record//URLDocView}" title="{$record//RecordTitle}">{$hits}</hit>
View reports.xqy
let $data := <column name="Reporters">Williams, Brian|Maceda, Jim|Keith, Brian Williams,|Thompson, Anne</column>
let $contributor := $data[@name='Reporters']/text() => fn:tokenize("\|")
return $contributor
@CliffordAnderson
CliffordAnderson / 00-introduction.md
Last active Oct 11, 2019
Text Mining at Scale (XQuery Working Group) Natural Language Processing
View 00-introduction.md

Natural Language Processing

Today, we’ll be exploring patterns in a corpus of genuine and fake news collected in 2016 by Buzz Feed and scored for veracity by professional journalists. As you might imagine, the corpus contains very partisan perspectives; individual articles may contain disturbing language and viewpoints. In the initial code example below, you will need to have downloaded the data set and have created a database called articles.

We’ll begin our investigation of natural language processing by using Aylien, which bill itself as a “News Intelligence Platform,” to classify these articles, analyze their topics, identify the people, places, things they discuss, and to discern the sentiment or tone of the articles. If you would like to follow along, please sign up for a free API key.

View hashtag.xqy
let $appid := "###"
let $key := "###"
let $endpoint := "https://api.aylien.com/api/v1/"
let $service := "hashtags"
let $text := fn:encode-for-uri("Are you serious? Do you think anyone cares about that crazy plan? Get back to Arizona!")
let $request :=
<http:request method="get" href="{$endpoint || $service || '?text=' || $text}">
<http:header name="Accept" value="text/xml"/>
<http:header name="X-AYLIEN-TextAPI-Application-Key" value="{$key}"/>
<http:header name="X-AYLIEN-TextAPI-Application-ID" value="{$appid}"/>
You can’t perform that action at this time.