2010-08-29

A REBOL Dialect For Constructed Languages

I have had a fascination for languages ever since I read Tolkien and discovered that he had created the Elvish languages from scratch. It was this hobby of “conlang” design that ultimately led me to become a programmer.

My first programs (written in line-oriented GW-BASIC) were intended to generate random words according to specific rules. I would then pick the most interesting ones for inclusion in whatever language it was I was designing at the time. Each program was language-specific. That is, I would choose a set of phonemes, create a set of rules for their combination, develop an orthography, and then write a program to generate valid words.

When I discovered REBOL, I realized that its dialecting capabilities would be perfect for this task, but instead of having to create a program per language, or struggle with other less-than-ideal techniques such as XML configuration files, I could simply create a REBOL dialect to describe the task.

To illustrate my Conlang Dialect, we‘ll go through the process of creating a brutally simple language. Obviously we won’t bother with grammar and syntax. We are dealing just with the sounds. We will call this simple language Na. Na has only four consonants, s k t n, and three vowels, a i u. The consonants are as one would expect, and the vowels are pronounced more or less as in Spanish.

A syllable in Na must always end with a vowel, and must begin with at least one and at most two consonants. Thus a is not a valid syllable in Na, but ta and tki are. Words can consist of any number of syllables, but we will stick with those between two and five.

The Conlang Dialect consists of three verbs, rand, rept and join. Verbs are followed by one or more arguments. Our first verb, rand, can be followed either by a string or a by a REBOL block in a specific format. When followed by a string, rand instructs the Conlang Dialect to randomly choose one of the characters from the string.

rand "aiu"

When the expression above is evaluated in the Conlang Dialect, it will result either in "a", "i", or "u". However, sometimes we want to say that one choice can occur more frequently than other choices. In the Na language, "a" is more common than either "i" or "u", which are about equally common. We can express this as follows.

rand [
 3 "a"
 1 rand "iu"
]

This means that 3 out of 4 times, the evaluation of the whole statement will result in "a", otherwise it will result in the evaluation of the expression rand "iu". Thus, Conlang Dialect expression can be nested within each other, and often are.

Now that we have a way to randomly choose strings, we need a way to stitch them together. This is performed by the join verb, which takes a block containing the expressions we want to join.

join [
 rand "sktn"
 rand [
  3 "a"
  1 rand "iu"
 ]
]

This instructs the Conlang Dialect to take the result of the two expressions inside of the block and combine them. So, for instance, we could get results like "ki" and "su" from the whole expression above.

The last verb in our repertoire is rept. This verb takes three arguments, and is best illustrated with an example.

rept 1 3 join [
 rand "sktn"
 rand [
  3 "a"
  1 rand "iu"
 ]
]

The first two arguments of rept tell the Conlang Dialect to repeat the evaluation of the expression given in the third argument from one to three times, in this case. In other words, pick a random number between 1 and 3 and execute the join expression that number of times, stitching the result together. The result of this expression could be words such as "ka", "kasiki", "sita", and so on.

This is all we need to create the Conlang Dialect, but unfortunately it has some drawbacks. It would be nice if we could assign expressions to names and reuse them, and so we can:

na: [
 consonant: rand "sktn"
 onset: rand [
  3 consonant
  1 join [
   consonant
   consonant
  ]
 ]
 vowel: rand [
  3 "a"
  1 rand "iu"
 ]
 syllable: join [onset vowel]
 main: rept 1 5 syllable
]

Here we have a full specification written in the Conlang Dialect. Expressions are assigned to names using a standard REBOL set-word. It should be fairly obvious from the above example how they are used. Assigning expressions in this way is not required, with one exception: The main expression is required, as it serves as the entry point into the specification. Using named expressions makes the Conlang Dialect much more usable, so I highly encourage their use.

Each verb has a much shorter synonym, and I tend to use these exclusively.

rand?
rept*
join&

Here is a full program using the Conlang Dialect to produce words in our imaginary Na language. This uses the abbreviated synonyms given above.

REBOL [
 needs: [
  2.100.99.2.5
  http://r3.revolucent.net/net.revolucent.conlang.v1.r 1.0.2
 ]
 license: 'mit
]

na: [
 consonant: ? "sktn"
 onset: ? [
  3 consonant
  & [
   consonant
   consonant
  ]
 ]
 vowel: ? [
  3 "a"
  ? "iu"
 ]
 syllable: & [onset vowel]
 main: * 1 5 syllable
]

random/seed now
generator: parse-conlang na
words: []
while [greater? 10 length? words] [
 unless find words word: generator/eval [
  append words word
 ]
]
print words

And here is a list of ten words generated by executing the program. Of course, subsequent executions are almost certain to produce a different set of words.

nkasanatana
ntusnana
sata
sanuna
kasakukana
skannatu
suknakaka
naka
natasasa
kanika

33 comments:

  1. WoW! That's awesome. Seems like the REBOL Language is really expressive. But I am wondering why it never gained much wider popularity?

    ReplyDelete
  2. I think it's because at first glance it doesn't look like much. When people first look at the language, they see things like this:

    foreach x [1 2 3] [print x]

    And they think, "Someone has created a pretty standard programming language in which the curly braces are replaced with square ones. Big deal." And then they never bother to dig deeper and see how truly unique REBOL really is.

    ReplyDelete
  3. Also, Rebol being a tiny company and not being Open Source is a big issue for many folks to adopt that for critical projects.

    ReplyDelete
  4. Thanks for sharing, nice blog. This is a great article. It gave me a lot of useful information. plese visit me
    IDM 6.5 Build 5 kegan
    Trend Micro Antivirus
    Windows 7 Product Key
    Adobe Illustrator CC 2016 Crack

    ReplyDelete
  5. Hello my friend! I want to say that this post is awesome, great written and include almost all
    important infos.I really love this post I will visit again to read your post in a very short time and I hope you will make more posts like this.

    T H A N K S
    F O R
    S H A R I N G

    WinAVI Video Converter 11.5 Keygen
    Trend Micro Antivirus
    Movie Converter 7 Keygen
    Neuratron Audio Score Ultimate Keygen

    ReplyDelete
  6. It's very informative for me.

    ReplyDelete
  7. This blog is so nice to me. I will continue to come here again and again. Visit my link as well. Good luck
    http://www.jualobataborsiherbal.com/ obat aborsi
    http://caramenggugurkankandungan.info/ cara menggugurkan kandungan
    http://obataborsi59.com/ obat aborsi
    http://obataborsi59.com/cara-menggugurkan-kandungan-dengan-cepat-dan-aman/ cara menggugurkan kandungan
    http://obattelatdatangbulan.info/ obat telat datang bulan
    http://klinikobataborsi.com/ jual obat aborsi
    http://jualobatpenggugurkandungan.net/ obat penggugur kandungan
    http://tandatandakehamilan.net/ tanda tanda kehamilan
    http://tandatandakehamilan.net/cara-cepat-dan-selamat-menggugurkan-kandungan/ cara menggugurkan kandungan

    ReplyDelete
  8. You can check certain cookies so you can concentrate on the ones you want. checkout this. From this screen you can make changes if needed or proceed to the results screen.

    ReplyDelete
  9. A friendly reminder window appears on your computer screen. downlodable torrent Just slide your thumb up and down the side of the screen.

    ReplyDelete
  10. Mobilize your own team, equip your heroes and get prepared for battle. download software The interactions make the reader a true part of the storyline.

    ReplyDelete
  11. Great Information,it has lot for stuff which is informative. Project Management MBA Capstone Project Help I will share the post with my friends.

    ReplyDelete
  12. I personally like your post, you have shared good article. harvard case solutions It will help me in great deal.

    ReplyDelete
  13. Game Reminders - Get notifications when your favorite game starts. downlodable torrent Thanks to our community of trendyful people: we love your creativity and taste.

    ReplyDelete
  14. View the Party List to see who's in a Buddy's party and maybe add new Buddies to your network. checkout this. "-Dean | 2/27/2010"I dedicated myself to RST 3 months ago and shot my 3 lowest rounds (74,76,77) ever in my last 5 rounds played.

    ReplyDelete
  15. Each time mystery pagodas appear they are replaced at random by a new picture symbol - most often a dragon wildcard. downloadawesomethingsonline.top Want offers from some businesses, but not from others.

    ReplyDelete
  16. NOISE: Computer - Synth Firefly - Hypnosis - Old Clock - Sine - White Noise - Keyboard Typing - Vinyl. essto.ru These can be used to test the App while you obtain MemoryTag labels.

    ReplyDelete
  17. Use this article to increase your knowledge . cara menggugurkan kandungan

    ReplyDelete
  18. The Wind chill is the apparent temperature felt on exposed skin due to wind. myvirtualhome 2.3 torrent DynaFont is a registered trademark of DynaComware Taiwan, Inc.

    ReplyDelete
  19. You can then decide which visa would be the most appropriate for you to apply for. http://downloadfreethingshere.gdn The number of photos in the library and number of filters continues to grow.

    ReplyDelete
  20. You can access the tests at anytime and anywhere with your device. downloadwarezfromashley.club The IT security state (antivirus) of the machines is displayed.

    ReplyDelete
  21. Creates a system restore point before deleting files. downlodable torrent Arnold Schwarzenegger Ronnie Coleman Jay Cutler Dexter Jackson Lee Haney Samir Bannout Chris Dickerson Frank Zane.

    ReplyDelete
  22. Thanks a lot for sharing this with all of us, I like it and we can communicate. Do you need buy app ratings and reviews. To boost app ranking and double app downloads now.

    ReplyDelete
  23. Includes Octave and 1/3 Octave modes, with selectable decay times, as well as Peak Hold and true linear Average mode. http://downloadingisnice.gdn Participate in our competition, win and become a legend.

    ReplyDelete
  24. Swipe through multiple Fireworks at once to create exciting and amazing spectacles in the Sky ,and get Combos and Score High !Level Up to Unlock. http://downloadsoftwarefromriley.download ###Features###-An authentic Japanese style bullet curtain (danmaku) shooter experience on the iphone/itouch!-Vibrant, detailed graphics.

    ReplyDelete
  25. Even though its name is PotholeSnitch, you can snitch on more than potholes. downloadwarezfrompenelope.online Improved navigation transitions, you can now swipe back from locations to the location view.

    ReplyDelete