From 3717c044facd2c4671b77c799d829505c916ff54 Mon Sep 17 00:00:00 2001 From: Jesse Johnston Date: Thu, 12 Nov 2026 09:27:55 -0500 Subject: [PATCH 1/6] update link to show archived version; minor revisions about Programming Historian --- episodes/06-free-text.md | 57 +++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/episodes/06-free-text.md b/episodes/06-free-text.md index ebff8cde..73f108a6 100644 --- a/episodes/06-free-text.md +++ b/episodes/06-free-text.md @@ -25,7 +25,7 @@ Thankfully there are plenty of folks out there doing this sort of work and we ca Before going any further, speak to the person next to you and choose which type of text you'd like to work on together. You have three options: - [Option 1](#option-1-hand-transcribed-text): An example of hand transcribed text: *Gulliver's Travels* (1735) -- [Option 2](#option-2-optical-character-recognised-text): An example of text captured by an optical character recognition process: *General Report on the Physiography of Maryland. A dissertation, etc. (Reprinted from Report of Maryland State Weather Service.) [With maps and illustrations.]* 1898 (Retrieved from [doi.org/10.21250/db12](https://doi.org/10.21250/db12)) +- [Option 2](#option-2-optical-character-recognised-text): An example of text captured by an optical character recognition process: *General Report on the Physiography of Maryland. A dissertation, etc. (Reprinted from Report of Maryland State Weather Service.) \[With maps and illustrations.\]* 1898 (Retrieved from [doi.org/10.21250/db12](https://doi.org/10.21250/db12)) - [Option 3](#option-3-a-webpage): An example of a webpage: Piper's World (a GeoCities page from 1999 saved at [archive.org](https://wayback.archive.org/web/20091020080943/http:/geocities.com/Heartland/Hills/7649/diary.html)) ## Option 1: Hand transcribed text @@ -36,11 +36,11 @@ We're going to work with the `gulliver.txt` file, which we made in [Episode 3, ' Let's look at the file. -```bash +``` bash $ less -N gulliver.txt ``` -```output +``` output 1 The Project Gutenberg eBook, Gulliver's Travels, by Jonatha 1 n Swift 2 @@ -83,13 +83,13 @@ $ less -N gulliver.txt We're going to start by using the `sed` command. The command allows you to edit files directly. -```bash +``` bash $ sed '9352,9714d' gulliver.txt > gulliver-nofoot.txt ``` The command `sed` in combination with the `d` value will look at `gulliver.txt` and delete all values between the rows specified. The `>` action then prompts the script to this edited text to the new file specified. -```bash +``` bash $ sed '1,37d' gulliver-nofoot.txt > gulliver-noheadfoot.txt ``` @@ -99,7 +99,7 @@ You now have a cleaner text. The next step is to prepare it even further for rig We now use the `tr` command, used for translating or deleting characters. Type and run: -```bash +``` bash $ tr -d '[:punct:]\r' < gulliver-noheadfoot.txt > gulliver-noheadfootpunct.txt ``` @@ -107,7 +107,7 @@ This uses the translate command and a special syntax to remove all punctuation ( Finally regularise the text by removing all the uppercase lettering. -```bash +``` bash $ tr '[:upper:]' '[:lower:]' < gulliver-noheadfootpunct.txt > gulliver-clean.txt ``` @@ -117,7 +117,7 @@ Open the `gulliver-clean.txt` in a text editor. Note how the text has been trans We are now ready to pull the text apart. -```bash +``` bash $ tr ' ' '\n' < gulliver-clean.txt | sort | uniq -c | sort -nr > gulliver-final.txt ``` @@ -129,7 +129,7 @@ The third part uses `uniq`, another new command, in combination with the `-c` fl The fourth and final part sorts the text again by the counts of duplicates generated in step three. -::::::::::::::::::::::::::::::::::::::: challenge +::::::::::::::::::::::::::::::::::::::: challenge ## Challenge @@ -139,7 +139,7 @@ Hint: These quote marks are not among the 128 characters of the ASCII standard, As a reminder, use the text editor of your choice to write a file that looks like this: -```bash +``` bash #!/bin/bash # This script removes quote marks from gulliver-clean.txt and saves the result as gulliver-noquotes.txt (replace this line with your solution) @@ -147,15 +147,15 @@ As a reminder, use the text editor of your choice to write a file that looks lik Save the file as `remove-quotes.sh` and run it from the command line like this: -```bash +``` bash bash remove-quotes.sh ``` -::::::::::::::: solution +::::::::::::::: solution ## Solution -```bash +``` bash #!/bin/bash # This script removes quote marks from gulliver-clean.txt and saves the result as gulliver-noquotes.txt sed -Ee 's/[""‘']//g' gulliver-clean.txt > gulliver-noquotes.txt @@ -179,11 +179,11 @@ We're going to work with `201403160_01_text.json`. Let's look at the file. -```bash +``` bash $ less -N 201403160_01_text.json ``` -```output +``` output 1 [[1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "A GENERAL RE 1 PORT ON THE PHYSIOGRAPHY OF MARYLAND A DISSERTATION PRESENTED TO THE PRE 1 SIDENT AND FACULTY OF THE JOHNS HOPKINS UNIVERSITY FOR THE DEGREE OF DOC @@ -211,7 +211,7 @@ $ less -N 201403160_01_text.json We're going to start by using the `tr` command, used for translating or deleting characters. Type and run: -```bash +``` bash $ tr -d '[:punct:]' < 201403160_01_text.json > 201403160_01_text-nopunct.txt ``` @@ -219,7 +219,7 @@ This uses the translate command and a special syntax to remove all punctuation. Finally regularise the text by removing all the uppercase lettering. -```bash +``` bash $ tr '[:upper:]' '[:lower:]' < 201403160_01_text-nopunct.txt > 201403160_01_text-clean.txt ``` @@ -229,7 +229,7 @@ Open the `201403160_01_text-clean.txt` in a text editor. Note how the text has b We are now ready to pull the text apart. -```bash +``` bash $ tr ' ' '\n' < 201403160_01_text-clean.txt | sort | uniq -c | sort -nr > 201403160_01_text-final.txt ``` @@ -255,11 +255,11 @@ We're going to work with `diary.html`. Let's look at the file. -```bash +``` bash $ less -N diary.html ``` -```output +``` output 1 2 3 @@ -283,18 +283,17 @@ $ less -N diary.html 17 content="shih tzu, dog, pet, quotations, award, diary, advice, book, rev 17 iew, piper"> 18