Created
June 2, 2013 16:57
-
-
Save rameshvarun/5694135 to your computer and use it in GitHub Desktop.
ActionScript Language Confluxer, based off of a python script by Christopher Pound. Given a list of names, it will generate random names that sound similar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Based off of the python script by Christopher Pound - http://generators.christopherpound.com/ | |
public class LanguageConfluxer | |
{ | |
var inits:Map = new Map(); | |
var pairs:Map = new Map(); | |
public function LanguageConfluxer() | |
{ | |
} | |
public function incorporate(input:String, delim:String):void | |
{ | |
var names:Array = input.split(delim); | |
for (var i:int = 0; i < names.length; ++i ) | |
{ | |
names[i] = names[i].substr(0,names[i].length-1); | |
} | |
for each(var name:String in names) | |
{ | |
name += " "; | |
if (name.length > 3) | |
{ | |
var first:String = name.slice(0,2); | |
var last:String = name.slice(2,3); | |
if (inits.has_key(first)) | |
{ | |
var array:Array = Array(inits.get_value(first)); | |
array.push(last); | |
inits.set_value(first,array) | |
} | |
else | |
{ | |
inits.push(first,new Array(last)) | |
} | |
} | |
var pos:int = 0; | |
while (pos < name.length - 2) | |
{ | |
var first:String = name.slice(pos,pos + 2); | |
var last:String = name.charAt(pos+2); | |
if (pairs.has_key(first)) | |
{ | |
var array:Array = Array(pairs.get_value(first)); | |
array.push(last); | |
pairs.set_value(first,array) | |
} | |
else | |
{ | |
pairs.push(first, new Array(last)) | |
} | |
pos = pos + 1; | |
} | |
} | |
} | |
public function generate():String | |
{ | |
var word:String = Generators.RandomObject(inits.keys); | |
while (word.indexOf(" ") == -1) | |
{ | |
TellMeRL.writeLineToLog(word); | |
TellMeRL.writeLineToLog(word.substr(word.length - 2, word.length)); | |
var pair:Object = pairs.get_value(word.substr(word.length - 2, word.length)); | |
if (pair != null) | |
{ | |
TellMeRL.writeLineToLog(Array(pair).toString()); | |
word += Generators.RandomString( Array(pair).toString(), "," ); | |
} | |
else | |
{ | |
break; | |
} | |
} | |
return word.substr(0, word.length - 1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var planets:String = "Earth;Mars;Venus;Mercury;Jupiter;Saturn;Uranus;Neptune;Pluto;Coruscant;Taris;Dagobah;Tatooine;Dantooine;Lail;Tetron;Alderaan;Algoa;Nirn;Alice;Alir;Alleven;Bernero;Berna;Sokolov;Soejima;Sobinov;Solon;Spahr;Spinoy;Durham;Dwornik;Einasto;Ekaterina;Peron;Raeon;Iris;Rowan;Rozov;Rubetra;Felucia;Destinn;Bespin;Disora;Dolero;Marconia;Margon;Marimo"; | |
var PlanetGenerator:LanguageConfluxer = new LanguageConfluxer(); | |
PlanetGenerator.incorporate( planets , ";"); | |
var planetName:String = PlanetGenerator.generate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment