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

46 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. It's very informative for me.

    ReplyDelete
  5. 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
  6. A friendly reminder window appears on your computer screen. downlodable torrent Just slide your thumb up and down the side of the screen.

    ReplyDelete
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. Described as a cross between Rubik&'s Cube and Lights Out with a new twist, Rotix will satisfy your puzzle cravings. grandrelativesoftwaresagency.ga Not sure how to get to a certain point, click on "Go there" and the navigation will give you the step-by-step instructions.

    ReplyDelete
  21. I want to tell you about a single sit original online casino sites There are many slots and slot machines. Withdrawing money is safe and fast. I play more than a month no complaints no

    ReplyDelete
  22. Thank you for another excellent post. Where else could anybody get that kind of info in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.

    ReplyDelete
  23. I thank you for the information and articles you provided

    ReplyDelete
  24. This is a fantastic website, thanks for sharing. There's no doubt i would fully rate it after i read what the idea about this article is 먹튀검증업체

    ReplyDelete
  25. Nice Informative Blog having nice sharing.. 메이저놀이터

    ReplyDelete
  26. ❤ I favor the idea, such a good deal 토토사이트

    ReplyDelete
  27. You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog 안전놀이터

    ReplyDelete
  28. Someone necessarily help to make severely articles I might state. That is the first time I frequented your web page 해외스포츠중계

    ReplyDelete
  29. Amazing product thanks for sharing with us It is very informative. 바카라사이트

    ReplyDelete
  30. I would want to study better latest transactions from this blog 토토사이트

    ReplyDelete
  31. hey! I just want to give an full-size thumbs up for the pleasant info you've got right here in this put up. 온라인슬롯

    ReplyDelete

  32. Thanks for your marvelous posting! I actually enjoyed reading it, you could be
    a great author.I will remember to bookmark your blog and will
    eventually come back from now on. I want to encourage you to continue your great
    writing, have a nice weekend!

    Website:スロット


    ReplyDelete
  33. In a rustic the place most individuals still lacked financial institution accounts or credit cards, M-Pesa provided a fast and safe means of cost. And a barrage of loosely regulated third-party lending apps that may hyperlink to M-Pesa meant bettors may indulge even when their accounts were empty. In New Jersey — which spearheaded the overturning of PASPA and is consistently battling with Nevada and New York as the highest-grossing state in sports activities betting dollars — 60 % of all bets are positioned on cell phones. In most other states with unrestricted cell betting, cell bets make up between 70 % and ninety % of all bets positioned, and between 50 % to eighty five % of them lose, stated Nower. But compared with other types of gambling, like slots or table games, sports activities bettors have a tendency begin out|to begin} younger, Fong stated, and develop addictive gambling behaviors a lot faster. The smartphone has revolutionized our relationship with know-how, together with the gambling culture 클레오카지노 of right now.

    ReplyDelete
  34. One factor about|wonderful factor about|beauty of} ordering through Costco’s website is the speedy delivery speeds. Depending on your location and what you’re ordering, it’s possible to obtain your items inside two days or generally even get same-day delivery. Alibaba.com features as a search engine, so resellers can browse the listings that seem based on their search queries. Search results could be filtered based on selection of|quite so much of|a big selection of} standards, so you'll be able to|you probably can} slim them down based on your particular preferences. Skincare merchandise include serums, creams, dildos instruments, face masks, and supplements. Accessories are another hot buy that is perfect for this online enterprise mannequin.

    ReplyDelete
  35. The lv neverfull black in Black exudes timeless elegance with its sleek black exterior and signature Monogram canvas. It effortlessly combines classic style with modern sensibility, making it a versatile and sophisticated choice for any occasion.

    ReplyDelete
  36. Trust and quality are paramount in the buy delta resellers industry. As a reseller, you have the responsibility of ensuring that every product you offer meets the highest standards of quality, purity, and transparency. This includes partnering with reputable manufacturers, verifying product certifications, and maintaining rigorous quality control.

    ReplyDelete
  37. I appreciate the articles and information you provide.book your tour with us Desert Safari Dubai.

    ReplyDelete