Giblang

Giblang

This is a little script I use to generate asemic titles and names for the things I work on. It is notably used to generate titles for my Breathing Cards.

The main idea is to build up words one syllable at a time. A syllable is a random pairing of a consonant sound and a vowel sound.

Janet Implementation

This is the version I use most frequently, most notably in the Candy Crystal Rainbow Codex.

(def cons (array
           "b" "c" "d" "f"
           "g" "h" "j" "k"
           "l" "m" "n" "p"
           "r" "s" "t" "v"
           "w" "z" "ch" "sh"
           "zh"))

(def vow (array "a" "e" "i" "o" "u" "y" "ee" "ai" "ae"))

(defn rpick (t)
  (t (math/floor (* (math/random) (length t)))))


(defn seed () (math/seedrandom (os/time)))

(defn syl () (string (rpick cons) (rpick vow)))

(defn word ()
  (do
    (var str "")
    (for i 0 (+ (math/floor (* (math/random) 3)) 1)
      (set str (string str (syl))))
    (cond (> (math/random) 0.2)
          (set str (string str (rpick cons))))
    (string str)))

(seed)
(print (word))

Lua Implementation (Original)

This is the original Giblang program, which was originally implemented in Lua. I found this in an email from July 2015, where I was helping someone generate placeholder text (I think they wanted "real" words lorem-ipsum style, oh well). It appears I have this configured to generate 3 paragraphs of text.

It was this code that generated the title for tiziku, an audio-visual composition.

require("math")
math.randomseed(os.time())

cons =
{"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", 
"w", "z"}

vow =
{"a", "e", "i", "o", "u", "y"}

wordlist = {}

function syl()
    return cons[math.random(#cons)] .. vow[math.random(#vow)]
end

function word()
    str = ""
    for i=1,math.random(3) do
        str = str .. syl()
    end
    if(math.random() > 0.2) then
        str = str .. cons[math.random(#cons)]
    end
    return str
end


function sentence()
    local str = word()
    str = str:gsub("^%l", string.upper)
    nwords = math.random(10)
    local punc = {",", ":", ";"}
    local ending = {".", ".", ".", "!", "?", "..."}
    table.insert(wordlist, word())
    curword = str
    prevword = str
    for i=1,nwords do

        if(math.random() < 0.7) then
            curword = word()
            table.insert(wordlist, curword)
        else
            curword = wordlist[math.random(#wordlist)]
        end

        str = str .. " " .. curword

        prevword = curword

        if(i ~= nwords and math.random() < 0.1) then
           str = str .. punc[math.random(#punc)]
        end
    end
    return str .. ending[math.random(#ending)] .. " "
end

function paragraph()
    str = ""
    for i = 1, math.random(10) do
        str = str .. sentence()
    end
    return str .. "\n"
end

print(paragraph())
print(paragraph())
print(paragraph())

home | index