Gibberish

By smilinbob on Sep 16, 2010

Basically this generates random gibberish. It took a bit of work to make it pronounceable(mostly).

There are four identifiers

$syl will return a single syllable
$word(N) will return a word consisting of N syllables
$gibberish(N) will return a sentence consisting of N words
$paragraph(N) will return a paragraph consisting of N Sentences

Words in a sentence have 1-4 syllables, sentences in a paragraph have 1-9 words. There is a limit of 20 words in a sentence, and 10 sentences in a paragraph. A sentence may be a normal sentence, an exclamation(capitalized ending "!") or a question(ending with "?")

Syllables consist of either 1 consonant sound followed by 1 vowel, or 1 vowel sound.

examples:
$gibberish(8) : Chagne ruquu wiezae ishespe chigupu dichi rui üa?
$paragraph(5) : Quo laxuplu bou. Preugna fla ìoiqua glopiü jina. Glaü swië fru sta ifozime. OBRUSEKRE TSUSMU OOTO SEUGLA SHAWE! PA DEQUISNO TSU JORI!

alias gibberish {
  if ($$1 <= 20) {
    var %t = 1
    while (%t <= $$1) {
      var %wl = $rand(1,4)
      var %wn = 1
      while (%wn <= %wl) {
        var %word = %word $+ $syl
        inc %wn
      }
      var %sen = %sen %word
      unset %word
      inc %t
    }
    var %p = $rand(1,100)
    ;echo . %sen
    ;echo . %p
    if (%p <= 70) {
      return $upper($left(%sen,1)) $+ $right(%sen,-1) $+ $chr(46)
    }
    elseif (%p <= 85) {
      return $upper($left(%sen,1)) $+ $right(%sen,-1) $+ $chr(63)
    }
    else {
      return $upper(%sen) $+ $chr(33)
    }
  }
}
alias paragraph {
  if ($$1 <= 10) {
    var %l = $$1
    var %n = 1
    while (%n <= %l) {
      var %s [ $+ [ %n ] ]  $gibberish($rand(1,9))
      inc %n
    }
    return %s1 %s2 %s3 %s4 %s5 %s6 %s7 %s8 %s9 %s10
  }
}
alias syl {
  var %b = $rand(1,100)
  if (%b < 70) {
    return $gettok(b.d.f.g.h.j.k.l.m.n.ñ.p.qu.r.s.t.v.w.x.y.z.bl.br.ch.fr.fl.gr.gl.gn.kl.kr.pr.pl.ph.qu.st.sh.sk.sl.sm.sn.sp.sw.th.tr.ts.wh.zh,$rand(1,48),46) $+ $gettok(a.e.i.o.u,$rand(1,5),46)
  }
  else {
    return $gettok(a.e.i.o.u.ì.á.ü.ë,$rand(1,9),46)
  }
}
alias word {
  var %n = 1
  while (%n <= $$1) {
    var %w = %w $+ $syl
    inc %n
  }
  return %w
}

Comments

Sign in to comment.
smilinbob   -  Sep 17, 2010

See, i knew someone would find a use for it.
Glad you liked it.

 Respond  
Lucius   -  Sep 17, 2010

I like it!
Just the thing for my RPG to give monsters a nonsense language.

8/10
+like

I'd like to see the option of making it all caps or not though (with random choice default)
like:
$gibberish(5,n) <---- normal (first cap)
$gibberish(5,nc) <---- non CAPS
$gibberish(5,c) <---- CAPS

And maybe change the $paragraph alias to $paragib or something, the alias paragraph is a useful one to be used in such a way.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.