Sioc admin
Posts : 2785 Join date : 2009-12-19
| Subject: BC Name.js pronounceable names generator Sun 25 Apr 2010, 08:37 | |
| This is a small BC javascript that is able to create random names that are more or less pronounceable Editable parameters:- minsyl : minimum number of syllables
- maxsyl : maximum number of syllables
- prefix : put "" if you don't want any prefix, otherwise for example "sioc-", "kn1-", etc. (should not be longer than 5 chars)
- withnumber : do you want a number at the end of the name? Either "true" or "false"
- minnum : if you want a number at the end of the name, what is its minimum value?
- maxnum : if you want a number at the end of the name, what is its maximum value?
Of course there's no guarantee at all you'll get kick-ass names, but at least you won't get something like "spczpdygj"... ;-) Installation:Just replace your Name.js file by the code below. Do not forget to modify the editable parameters according to your needs. - Spoiler:
- Code:
-
//BC pronounceable names generator v1.00 by Sioc. //Inspired from Totro by David A. Wheeler
function createName() { //========================================================================================= //EDITABLE PARAMETERS //========================================================================================= var minsyl = 3; //Minimum number of syllables var maxsyl = 6; //Maximum number of syllables var prefix = ""; //Prefix: put "" if you don't want any prefix (should not be longer than 5 chars) var withnumber = false; //Do you want a number at the end of the name? Either true or false var minnum = 1; //If you want a number at the end of the name, what is its minimum value? var maxnum = 999; //If you want a number at the end of the name, what is its maximum value? //========================================================================================= //END OF EDITABLE PARAMETERS //========================================================================================= var s = prefix; var vowels = new Array(["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["a", 7], ["e", 7], ["i", 7], ["o", 7], ["u", 7], ["ae", 7], ["ai", 7], ["ao", 7], ["au", 7], ["aa", 7], ["ea", 7], ["eo", 7], ["eu", 7], ["ee", 7], ["ia", 7], ["io", 7], ["iu", 7], ["ii", 7], ["oa", 7], ["oe", 7], ["oi", 7], ["ou", 7], ["oo", 7], ["eau", 7], ["y", 7]) var consonants = new Array(["b", 7], ["c", 7], ["d", 7], ["f", 7], ["g", 7], ["h", 7], ["j", 7], ["k", 7], ["l", 7], ["m", 7], ["n", 7], ["p", 7], ["qu", 6], ["r", 7], ["s", 7], ["t", 7], ["v", 7], ["w", 7],["x", 7], ["y", 7], ["z", 7], ["sc", 7], ["ch", 7], ["gh", 7], ["ph", 7], ["sh", 7], ["th", 7], ["wh", 6],["ck", 5], ["nk", 5], ["rk", 5], ["sk", 7], ["wk", 0],["cl", 6], ["fl", 6], ["gl", 6], ["kl", 6], ["ll", 6], ["pl", 6], ["sl", 6],["br", 6], ["cr", 6], ["dr", 6], ["fr", 6], ["gr", 6], ["kr", 6], ["pr", 6], ["sr", 6], ["tr", 6],["ss", 5],["st", 7], ["str", 6],["b", 7], ["c", 7], ["d", 7], ["f", 7], ["g", 7], ["h", 7], ["j", 7], ["k", 7], ["l", 7], ["m", 7], ["n", 7], ["p", 7], ["r", 7], ["s", 7], ["t", 7], ["v", 7], ["w", 7],["b", 7], ["c", 7], ["d", 7], ["f", 7], ["g", 7], ["h", 7], ["j", 7], ["k", 7], ["l", 7], ["m", 7], ["n", 7], ["p", 7], ["r", 7], ["s", 7], ["t", 7], ["v", 7], ["w", 7],["br", 6], ["dr", 6], ["fr", 6], ["gr", 6], ["kr", 6]) var data = ""; var leng = rnd(minsyl, maxsyl); // Compute number of syllables in the name var isvowel = rnd(0, 1); // randomly start with vowel or consonant for (var i = 1; i <= leng; i++) { // syllable #. Start is 1 (not 0) do { if (isvowel) { data = vowels[rnd(0, vowels.length - 1)]; } else { data = consonants[rnd(0, consonants.length - 1)]; } if ( i == 1) { // first syllable. if (data[1] & 2) {break;} } else if (i == leng) { // last syllable. if (data[1] & 1) {break;} } else { // middle syllable. if (data[1] & 4) {break;} } } while (1) s += data[0]; isvowel = 1 - isvowel; // Alternate between vowels and consonants. } if(withnumber){s += rnd(minnum,maxnum)}; return s; }
function rnd(minv, maxv){ if (maxv < minv) return 0; return Math.floor(Math.random()*(maxv-minv+1)) + minv; }
Testing:If you want to try it out you can create a blank *.html file with the code below and replace "//PASTE THE NAME.JS CODE HERE" by the Name.js code in the spoiler above, then open that *.html file in your browser: - Spoiler:
- Code:
-
<html><head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <script language="JavaScript">
//PASTE THE NAME.JS CODE HERE
</script> </head><body> <input name="generate" value="Generate name" onclick="window.alert(createName())" type="button"> </body></html>
Examples:Here are just a few random examples generated by the script: - Spoiler:
afroun astuzo owedo duruk waicro glefrim itusae ewhool esosc edagra ousrokli sesoo clush ahao afroj ipork aloss fur iryg bub droco crub eaunael phaugrej groolliph mosh sredoow frah stefluk ile flewa freule slix vatu plisc koeje krenkaest fraod orak ovi oucin ulubru exal kuji heaudek egath phubrif jav deark ucag gheh onitu fon giac ebro ucrin sephian riif nokoph jeev
Last edited by Sioc on Thu 08 Jul 2010, 08:20; edited 5 times in total (Reason for editing : Thanks Stsin for the hint about the prefix!) | |
|