Skip to content

Instantly share code, notes, and snippets.

@dclelland
Last active January 18, 2016 10:23
Show Gist options
  • Save dclelland/fc979f1ca05a3f7f5fb3 to your computer and use it in GitHub Desktop.
Save dclelland/fc979f1ca05a3f7f5fb3 to your computer and use it in GitHub Desktop.
hoonsay: convert Hoon code to a phonetic representation
## hoonsay.sed - Daniel Clelland 2016
## List of regular expressions for converting Hoon to a phonetic representation
##
## Recommended usage:
##
## sed -E -f hoonsay.sed file.hoon > file.txt # Saves contents of hoon.hoon into hoon.txt
## cat hoon.txt | say -o hoon.aiff # Renders hoon.txt using the OS X speech to text engine
##
## Sample output, the add function from chapter 2a in hoon.hoon:
##
## slus. add.
## sig fas. cen add.
## bar tis. sel a tis pat. b tis pat ser.
## ket hep. pat.
## wut col. tis pel 0. a per. b.
## buc pel a. pel dec. a per com. b. lus pel b per per.
# Strip comments and preceding whitespace
s/ *::.*//g
# Insert space after keywords that don't have a space after them
s/([0-9a-zA-Z]+)([^0-9a-zA-Z\s])/\1 \2/g
# Irregular runes
s/==/stet /g
s/--/shed /g
s/\+\+/slus /g
s/->/lark /g
s/-</lush /g
s/\+>/dark /g
s/\+</dish /g
# Main symbols
s/\|/bar /g
s/\\/bas /g
s/\$/buc /g
s/_/cab /g
s/%/cen /g
s/:/col /g
s/,/com /g
s/"/doq /g
s/\./dot /g
s/\//fas /g
s/</gal /g
s/>/gar /g
s/#/hax /g
s/-/hep /g
s/{/kel /g
s/}/ker /g
s/\^/ket /g
s/\+/lus /g
s/&/pam /g
s/@/pat /g
s/\(/pel /g
s/\)/per /g
s/\[/sel /g
s/;/sem /g
s/\]/ser /g
s/~/sig /g
s/'/soq /g
s/\*/tar /g
s/`/tec /g
s/=/tis /g
s/\?/wut /g
s/!/zap /g
# Make sure lines end in a period.
s/([0-9a-zA-Z]) *$/\1./g
# Make sure any gaps have a period.
s/([0-9a-zA-Z]) {2,}/\1. /g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment