Skip to content

Instantly share code, notes, and snippets.

@lmullen
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmullen/d2d0162a0cda6301b748 to your computer and use it in GitHub Desktop.
Save lmullen/d2d0162a0cda6301b748 to your computer and use it in GitHub Desktop.
Sample Makefile for Clio 3
analysis
html
text

Example Makefile for Clio 3. Performs some very basic text analysis on Tracts for the Times.

#!/bin/bash
cat $1 | tr -d '[:punct:]' | tr [:space:] '\n' | sort | uniq -c | sort -bnr
#!/bin/bash
lynx -dump $1 | iconv -f WINDOWS-1252 -t UTF-8
ZIP := http://lincolnmullen.com/files/tracts-for-times.zip
TEXT := $(patsubst html/%.html, text/%.txt, $(wildcard html/*.html))
ANALYSIS := $(patsubst text/%.txt, analysis/%.txt, $(wildcard text/*.txt))
all : html $(TEXT) $(ANALYSIS)
tracts-for-times.zip :
@echo Download the zip file
curl -O $(ZIP)
unzip $^ -d $@
html : tracts-for-times.zip
@echo Unzip the tracts into $@
text/%.txt : html/%.html
./html2plaintext.sh $^ > $@
analysis/%.txt : text/%.txt
mkdir -p analysis
./count-words.sh $^ > $@
clean :
rm -f tracts-for-times.zip
rm -f html/*
rm -f text/*
rm -f analysis/*
.PHONY : clean clobber all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment