Skip to content

Instantly share code, notes, and snippets.

View mhbeals's full-sized avatar

Melodee Wood (née Beals) mhbeals

View GitHub Profile
@mhbeals
mhbeals / p4hum2.md
Created May 11, 2021 10:49
Visualising Texts

Imports and Exports

First, let us recap yesterday's concordance programme.

I asked you to create a programme to display every instance of the word "to" in our sample sentence, in the context of the word immediately before and after it. I suggested that you use:

  • a List
  • an Iterator / While Loop
  • the .join() and .append() Functions
  • a For Loop
@mhbeals
mhbeals / p4hum1.md
Last active May 10, 2021 09:38
Python for the Humanities Workshop #1

Welcome

Welcome to Programming for the Humanities

First, let us introduce ourselves! Click on the grey box below this one and press RUN at the top of your screen.

The Jupyter Notebook

This is a Jupyter Notebook. It allows you to practice and prototype your code in a cloud environment (rather than directly on your computer) and to document your work through text boxes above and below each section of code.

@mhbeals
mhbeals / gutenberg_barcodes.py
Last active November 10, 2018 20:48
A simple python script (Based on work for Programming for the Humanities and Social Sciences workshop series at Loughborough University) to display a barcode of the n most common words in any Gutenberg eBook.
# import libraries
import re
import requests
from matplotlib import pyplot as plt
# import stop words
stop = ["a","about","above","after","again","against","all","am","an","and","any","are","arent","as","at","be","because","been","before","being","below","between","both","but","by","cant","cannot","could","couldnt","did","didnt","do","does","doesnt","doing","dont","down","during","each","few","for","from","further","had","hadnt","has","hasnt","have","havent","having","he","hed","hell","hes","her","here","heres","hers","herself","him","himself","his","how","hows","i","id","ill","im","ive","if","in","into","is","isnt","it","its","its","itself","lets","me","more","most","mustnt","my","myself","no","nor","not","of","off","on","once","only","or","other","ought","our","ours ourselves","out","over","own","same","shant","she","shed","shell","shes","should","shouldnt","so","some","such","than","that","thats","the","their","theirs","them","themselves","then","there","theres","these","they","theyd","theyll","theyre","
@mhbeals
mhbeals / p4hss_2_hints
Last active October 9, 2018 15:10
P4HSS Hints (Workshop 2)
# First programme:
word_sub_list = []
for word in my_words:
if word.startswith('t'):
word_sub_list.append(word)
print (', '.join(word_sub_list), end ='.')
@mhbeals
mhbeals / DH2018_MHBEALS.md
Created June 10, 2018 10:20
From the 25-29th of June I will be attending Digital Humanities, Mexico City. Here is where you can find me (Updated for breaks and lunches on the day)

From the 25-29th of June I will be attending Digital Humanities, Mexico City. Here is where you can find me, unless someone tempts me to another session with promises of sweet breads.

Tuesday

1630-1830

Opening & Keynote Location: Independencia Janet Chávez Santiago Activista en lenguas indígenas / Indigenous Languages Activist

@mhbeals
mhbeals / TroveNewspapers.tsv
Last active April 19, 2018 05:54
Trove Newspapers as of April 2018
StartDate Title ID
1803-03-05 The Sydney Gazette and New South Wales Advertiser (NSW : 1803 - 1842) 3
1810-04-03 The Derwent Star and Van Diemen's Land Intelligencer (Hobart, Tas. : 1810 - 1812) 1046
1814-05-21 The Van Diemen's Land Gazette and General Advertiser (Hobart, Tas. : 1814) 1047
1816-05-11 The Hobart Town Gazette and Southern Reporter (Tas. : 1816 - 1821) 4
1821-01-20 Hobart Town Gazette and Van Diemen's Land Advertiser (Tas. : 1821 - 1825) 5
1824-10-14 The Australian (Sydney, NSW : 1824 - 1848) 50
1825-01-05 Tasmanian and Port Dalrymple Advertiser (Launceston, Tas. : 1825) 273
1825-06-25 Hobart Town Gazette (Tas. : 1825 - 1827; 1830) 22
1825-08-19 Colonial Times and Tasmanian Advertiser (Hobart, Tas. : 1825 - 1827) 23
@mhbeals
mhbeals / paperspast_all.py
Last active April 18, 2018 00:55
A script to download all (as of April 2018) newspaper articles from Papers Past (NZ)
import requests
number = 1
# Note, this will take a long time!
while number < 1318493:
# Make sure to change your API key at the end of the URL
urltext = "http://api.digitalnz.org/v3/records.xml?api_key=################&and[collection][]=Papers+Past&sort=date&text=+&and[category][]=Newspapers&direction=asc&page=" + str(number)
@mhbeals
mhbeals / trove_newspapers.py
Last active April 19, 2018 09:48
A script to download all (as of April 2018) newspaper articles from Trove
import urllib
import requests
from lxml import etree
import xml.etree.ElementTree as ET
# Use one of these lists or visit https://gist.github.com/mhbeals/1ad7cd04ca0f8fd74e12f6151664873e for full listing
list_pre_1840 = [3,1046,1047,4,5,50,273,22,23,76,1230,19,24,1282,1235,693,95,272,1236,695,696,1237,37,525,944,6,1233,1239,869,694,945,1240,1242,66,170,1013,1238,40,1142,1232,1241,1329,935,171,96,1137,936,1243,41,20,48,1231,984]
list_1840 = [1330,1030,1331,986,181,21,1037,339,292,1014,1015,867,1336,1027,1012,1022,1036,74,1026,1025,1039,35,110,8,1033,1028,1035,190,821,1040,1034,78,1020,1018,1023,1038,1031,1021,690,178,1234,1011,172,58,1029,1016,285,160,1024,1004,1017,1138,937,1019,1032,941,18,14,94,863,864,987,284,26,54,364,13,1100,938,939,55]
list_1850 = [1244,314,464,67,1139,277,56,1041,283,174,805,107,1339,582,31,809,326,1245,948,213,180,874,346,189,484,262,161,669,985,706,193,685,162,496,959,32,1324,33,163,1246,257,1247,7,287,1053,382,380,164,558,1248,104,1054,65,381,353]
list_1860 = [365,415,927,478,10,6
This file has been truncated, but you can view the full file.
@prefix cc: <http://web.resource.org/cc/>
@prefix dc: <http://purl.org/dc/terms/>
@prefix fabio: <http://purl.org/spar/fabio/>
@prefix foaf: <http://xmlns.com/foaf/0.1/>
@prefix frbr: <http://purl.org/spar/frbr/>
@prefix sap: <http://www.scissorsandpaste.net/sapont#>
@prefix sapcorpus: <http://www.scissorsandpaste.net/sapcorpus#>
@prefix sapmemes: <http://www.scissorsandpaste.net/sapmemes#>
@prefix pav: <http://purl.org/pav/>
@prefix prov: <http://www.w3.org/ns/prov#>
@mhbeals
mhbeals / Collabw16 One-Man Crowd Sourcing Demo.md
Last active March 21, 2016 10:20
Instructions (more or less) on One-Man Crowd-Sourcing, as presented at #Collabw16

Introduction

There are many ways you can create a crowd-sourcing platform; the following, although only one of many, allows for a significant degree of flexability and customisation for precisely zero cost. The only requirement is that your initial data be formatted as an XML.

Sign up for services

In order to develop your crowdsourcing site, you will need accounts for the following services:

  • Google: A Free E-Mailand Cloud Storage Provider
  • x10host.com: A Free Hosting Service, allowing full installations of Wordpress