Skip to content

Instantly share code, notes, and snippets.

View dwhieb's full-sized avatar
🗣️
Building the new LinguisticDiscovery.com

Daniel W. Hieber dwhieb

🗣️
Building the new LinguisticDiscovery.com
View GitHub Profile
<div class=igl>
<p class=ex-header>Chitimacha (isolate)</p>
<p class=txn>siksi<em>nk</em> his heːčtiʔi</p>
<ol class=words>
<li class=word>
<p class=word-m>siksi‑<em>nk</em></p>
@dwhieb
dwhieb / transliterate.js
Created February 1, 2018 20:01
A unidirectional transliteration function
/**
* A unidirectional transliteration algorithm which makes a set of substitutions on a string, and handles common edge cases.
* @param {String} [string=''] The String to transliterate
* @param {Object} [substitutions={}] The set of substitutions to make on the String. Each key should be the character(s) to replace, and its value should be the character(s) to replace it with.
* @return {String} Returns a new String with the substitutions made
*/
const transliterate = (string = '', substitutions = {}) => {
// save the string to a new variable for readability
let str = string;
@dwhieb
dwhieb / transliterate-sorted.js
Last active February 1, 2018 19:57
An intermediate transliteration function that handles substrings during substitution but not other edge cases
// An intermediate transliteration function that handles substrings
// but does not handle other edge cases
const sortedTransliterate = (string = '', substitutions = {}) => {
// save the string to a new variable for readability
let str = string;
// get the list of substitutions
Object.entries(substitutions)
@dwhieb
dwhieb / transliterate-simple.js
Last active February 1, 2018 19:58
A basic transliteration function that makes string replacements but does not handle common edge cases
// A simple version of the transliterate method which makes replacements
// but does not handle common edge cases.
const simpleTransliterate = (string = '', substitutions = {}) => {
// save the string to a new variable for readability
let str = string;
// get the list of substitutions
Object.entries(substitutions)