-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.js
52 lines (44 loc) · 18.8 KB
/
builder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var _ = require('underscore');
var crypto = require('crypto');
function randomValueHex (len) {
return crypto.randomBytes(Math.floor(len/2))
.toString('hex')
.slice(0,len);
}
function pickRandom (a) {
return a[parseInt(randomValueHex(9),16) % a.length]
};
var adj = ['different','used','important','every','large','available','popular','able','basic','known','various','difficult','several','united','historical','hot','useful','mental','scared','additional','emotional','old','political','similar','healthy','financial','medical','traditional','federal','entire','strong','actual','significant','successful','electrical','expensive','pregnant','intelligent','interesting','poor','happy','responsible','cute','helpful','recent','willing','nice','wonderful','impossible','serious','huge','rare','technical','typical','competitive','critical','electronic','immediate','aware','educational','environmental','global','legal','relevant','accurate','capable','dangerous','dramatic','efficient','powerful','foreign','hungry','practical','psychological','severe','suitable','numerous','sufficient','unusual','consistent','cultural','existing','famous','pure','afraid','obvious','careful','latter','unhappy','acceptable','aggressive','boring','distinct','eastern','logical','reasonable','strict','administrative','automatic','civil','former','massive','southern','unfair','visible','alive','angry','desperate','exciting','friendly','lucky','realistic','sorry','ugly','unlikely','anxious','comprehensive','curious','impressive','informal','inner','pleasant','sexual','sudden','terrible','unable','weak','wooden','asleep','confident','conscious','decent','embarrassed','guilty','lonely','mad','nervous','odd','remarkable','substantial','suspicious','tall','tiny','more','some','one','all','many','most','other','such','even','new','just','good','any','each','much','own','great','another','same','few','free','right','still','best','public','human','both','local','sure','better','general','specific','long','small','less','high','certain','little','common','next','simple','hard','past','big','possible','particular','real','major','personal','current','left','national','least','natural','physical','short','last','single','individual','main','potential','professional','international','lower','open','according','alternative','special','working','true','whole','clear','dry','easy','cold','commercial','full','low','primary','worth','necessary','positive','present','close','creative','green','late','fit','glad','proper','complex','content','due','effective','middle','regular','fast','independent','original','wide','beautiful','complete','active','negative','safe','visual','wrong','ago','quick','ready','straight','white','direct','excellent','extra','junior','pretty','unique','classic','final','overall','private','separate','western','alone','familiar','official','perfect','bright','broad','comfortable','flat','rich','warm','young','heavy','valuable','correct','leading','slow','clean','fresh','normal','secret','tough','brown','cheap','deep','objective','secure','thin','chemical','cool','extreme','exact','fair','fine','formal','opposite','remote','total','vast','lost','smooth','dark','double','equal','firm','frequent','internal','sensitive','constant','minor','previous','raw','soft','solid','weird','amazing','annual','busy','dead','false','round','sharp','thick','wise','equivalent','initial','narrow','nearby','proud','spiritual','wild','adult','apart','brief','crazy','prior','rough','sad','sick','strange','external','illegal','loud','mobile','nasty','ordinary','royal','senior','super','tight','upper','yellow','dependent','funny','gross','ill','spare','sweet','upstairs','usual','brave','calm','dirty','downtown','grand','honest','loose','male','quiet','brilliant','dear','drunk','empty','female','inevitable','neat','ok','representative','silly','slight','smart','stupid','temporary']
var verb = ['accept','care','could','enjoy','lead','open','reduce','settle','teache','account','carry','count','examine','hate','learn','order','refer','shake','tell','achieve','catch','cover','exist','ha','leave','ought','reflect','shall','tend','act','cause','create','expect','head','lend','own','refuse','share','test','add','change','cross','experience','hear','let','pass','regard','shoot','thank','admit','charge','cry','explain','help','lie','pay','relate','should','think','affect','check','cut','express','hide','like','perform','release','shout','throw','afford','choose','damage','extend','hit','limit','pick','remain','show','touch','agree','claim','dance','face','hold','link','place','remember','shut','train','aim','clean','deal','fail','hope','listen','plan','remove','sing','travel','allow','clear','decide','fall','hurt','live','play','repeat','sit','treat','answer','climb','deliver','fasten','identify','look','point','replace','sleep','try','appear','close','demand','feed','imagine','lose','prefer','reply','smile','turn','apply','collect','deny','feel','improve','love','prepare','report','sort','understand','argue','come','depend','fight','include','make','present','represent','sound','use','arrange','commit','describe','fill','increase','manage','press','require','speak','used to','arrive','compare','design','find','indicate','mark','prevent','rest','stand','visit','ask','complain','destroy','finish','influence','matter','produce','result','start','vote','attack','complete','develop','fit','inform','may','promise','return','state','wait','avoid','concern','die','fly','intend','mean','protect','reveal','stay','walk','base','confirm','disappear','fold','introduce','measure','prove','ring','stick','want','be','connect','discover','follow','invite','meet','provide','rise','stop','warn','beat','consider','discuss','force','involve','mention','publish','roll','study','wash','become','consist','divide','forget','join','might','pull','run','succeed','watch','begin','contact','do','forgive','jump','mind','push','save','suffer','wear','believe','contain','dress','form','keep','misse','put','say','suggest','will','belong','continue','drink','found','kick','move','raise','see','suit','win','break','contribute','drive','gain','kill','must','reach','seem','supply','wish','build','control','drop','get','knock','need','read','sell','support','wonder','burn','cook','eat','give','know','notice','realize','send','suppose','work','buy','copy','enable','go','last','obtain','receive','separate','survive','worry','call','correct','encourage','grow','laugh','occur','recognize','serve','take','would','can','cost','end','handle','lay','offer','record','set','talk','write']
.map(function(a){return a + 's'});
var noun = ['people','history','way','art','world','information','map','two','family','government','health','system','computer','meat','year','thanks','music','person','reading','method','data','food','understanding','theory','law','bird','literature','problem','software','control','knowledge','power','ability','economics','love','internet','television','science','library','nature','fact','product','idea','temperature','investment','area','society','activity','story','industry','media','thing','oven','community','definition','safety','quality','development','language','management','player','variety','video','week','security','country','exam','movie','organization','equipment','physics','analysis','policy','series','thought','basis','boyfriend','direction','strategy','technology','army','camera','freedom','paper','environment','child','instance','month','truth','marketing','university','writing','article','department','difference','goal','news','audience','fishing','growth','income','marriage','user','combination','failure','meaning','medicine','philosophy','teacher','communication','night','chemistry','disease','disk','energy','nation','road','role','soup','advertising','location','success','addition','apartment','education','math','moment','painting','politics','attention','decision','event','property','shopping','student','wood','competition','distribution','entertainment','office','population','president','unit','category','cigarette','context','introduction','opportunity','performance','driver','flight','length','magazine','newspaper','relationship','teaching','cell','dealer','finding','lake','member','message','phone','scene','appearance','association','concept','customer','death','discussion','housing','inflation','insurance','mood','woman','advice','blood','effort','expression','importance','opinion','payment','reality','responsibility','situation','skill','statement','wealth','application','city','county','depth','estate','foundation','grandmother','heart','perspective','photo','recipe','studio','topic','collection','depression','imagination','passion','percentage','resource','setting','ad','agency','college','connection','criticism','debt','description','memory','patience','secretary','solution','administration','aspect','attitude','director','personality','psychology','recommendation','response','selection','storage','version','alcohol','argument','complaint','contract','emphasis','highway','loss','membership','possession','preparation','steak','union','agreement','cancer','currency','employment','engineering','entry','interaction','mixture','preference','region','republic','tradition','virus','actor','classroom','delivery','device','difficulty','drama','election','engine','football','guidance','hotel','owner','priority','protection','suggestion','tension','variation','anxiety','atmosphere','awareness','bath','bread','candidate','climate','comparison','confusion','construction','elevator','emotion','employee','employer','guest','height','leadership','mall','manager','operation','recording','sample','transportation','charity','cousin','disaster','editor','efficiency','excitement','extent','feedback','guitar','homework','leader','mom','outcome','permission','presentation','promotion','reflection','refrigerator','resolution','revenue','session','singer','tennis','basket','bonus','cabinet','childhood','church','clothes','coffee','dinner','drawing','hair','hearing','initiative','judgment','lab','measurement','mode','mud','orange','poetry','police','possibility','procedure','queen','ratio','relation','restaurant','satisfaction','sector','signature','significance','song','tooth','town','vehicle','volume','wife','accident','airport','appointment','arrival','assumption','baseball','chapter','committee','conversation','database','enthusiasm','error','explanation','farmer','gate','girl','hall','historian','hospital','injury','instruction','maintenance','manufacturer','meal','perception','pie','poem','presence','proposal','reception','replacement','revolution','river','son','speech','tea','village','warning','winner','worker','writer','assistance','breath','buyer','chest','chocolate','conclusion','contribution','cookie','courage','dad','desk','drawer','establishment','examination','garbage','grocery','honey','impression','improvement','independence','insect','inspection','inspector','king','ladder','menu','penalty','piano','potato','profession','professor','quantity','reaction','requirement','salad','sister','supermarket','tongue','weakness','wedding','affair','ambition','analyst','apple','assignment','assistant','bathroom','bedroom','beer','birthday','celebration','championship','cheek','client','consequence','departure','diamond','dirt','ear','fortune','friendship','funeral','gene','girlfriend','hat','indication','intention','lady','midnight','negotiation','obligation','passenger','pizza','platform','poet','pollution','recognition','reputation','shirt','sir','speaker','stranger','surgery','sympathy','tale','throat','trainer','uncle','youth','time','work','film','water','money','example','while','business','study','game','life','form','air','day','place','number','part','field','fish','back','process','heat','hand','experience','job','book','end','point','type','home','economy','value','body','market','guide','interest','state','radio','course','company','price','size','card','list','mind','trade','line','care','group','risk','word','fat','force','key','light','training','name','school','top','amount','level','order','practice','research','sense','service','piece','web','boss','sport','fun','house','page','term','test','answer','sound','focus','matter','kind','soil','board','oil','picture','access','garden','range','rate','reason','future','site','demand','exercise','image','case','cause','coast','action','age','bad','boat','record','result','section','building','mouse','cash','class','nothing','period','plan','store','tax','side','subject','space','rule','stock','weather','chance','figure','man','model','source','beginning','earth','program','chicken','design','feature','head','material','purpose','question','rock','salt','act','birth','car','dog','object','scale','sun','note','profit','rent','speed','style','war','bank','craft','half','inside','outside','standard','bus','exchange','eye','fire','position','pressure','stress','advantage','benefit','box','frame','issue','step','cycle','face','item','metal','paint','review','room','screen','structure','view','account','ball','discipline','medium','share','balance','bit','black','bottom','choice','gift','impact','machine','shape','tool','wind','address','average','career','culture','morning','pot','sign','table','task','condition','contact','credit','egg','hope','ice','network','north','square','attempt','date','effect','link','post','star','voice','capital','challenge','friend','self','shot','brush','couple','debate','exit','front','function','lack','living','plant','plastic','spot','summer','taste','theme','track','wing','brain','button','click','desire','foot','gas','influence','notice','rain','wall','base','damage','distance','feeling','pair','savings','staff','sugar','target','text','animal','author','budget','discount','file','ground','lesson','minute','officer','phase','reference','register','sky','stage','stick','title','trouble','bowl','bridge','campaign','character','club','edge','evidence','fan','letter','lock','maximum','novel','option','pack','park','plenty','quarter','skin','sort','weight','baby','background','carry','dish','factor','fruit','glass','joint','master','muscle','red','strength','traffic','trip','vegetable','appeal','chart','gear','ideal','kitchen','land','log','mother','net','party','principle','relative','sale','season','signal','spirit','street','tree','wave','belt','bench','commission','copy','drop','minimum','path','progress','project','sea','south','status','stuff','ticket','tour','angle','blue','breakfast','confidence','daughter','degree','doctor','dot','dream','duty','essay','father','fee','finance','hour','juice','limit','luck','milk','mouth','peace','pipe','seat','stable','storm','substance','team','trick','afternoon','bat','beach','blank','catch','chain','consideration','cream','crew','detail','gold','interview','kid','mark','match','mission','pain','pleasure','score','screw','sex','shop','shower','suit','tone','window','agent','band','block','bone','calendar','cap','coat','contest','corner','court','cup','district','door','east','finger','garage','guarantee','hole','hook','implement','layer','lecture','lie','manner','meeting','nose','parking','partner','profile','respect','rice','routine','schedule','swimming','telephone','tip','winter','airline','bag','battle','bed','bill','bother','cake','code','curve','designer','dimension','dress','ease','emergency','evening','extension','farm','fight','gap','grade','holiday','horror','horse','host','husband','loan','mistake','mountain','nail','noise','occasion','package','patient','pause','phrase','proof','race','relief','sand','sentence','shoulder','smoke','stomach','string','tourist','towel','vacation','west','wheel','wine','arm','aside','associate','bet','blow','border','branch','breast','brother','buddy','bunch','chip','coach','cross','document','draft','dust','expert','floor','god','golf','habit','iron','judge','knife','landscape','league','mail','mess','native','opening','parent','pattern','pin','pool','pound','request','salary','shame','shelter','shoe','silver','tackle','tank','trust','assist','bake','bar','bell','bike','blame','boy','brick','chair','closet','clue','collar','comment','conference','devil','diet','fear','fuel','glove','jacket','lunch','monitor','mortgage','nurse','pace','panic','peak','plane','reward','row','sandwich','shock','spite','spray','surprise','till','transition','weekend','welcome','yard','alarm','bend','bicycle','bite','blind','bottle','cable','candle','clerk','cloud','concert','counter','flower','grandfather','harm','knee','lawyer','leather','load','mirror','neck','pension','plate','purple','ruin','ship','skirt','slice','snow','specialist','stroke','switch','trash','tune','zone','anger','award','bid','bitter','boot','bug','camp','candy','carpet','cat','champion','channel','clock','comfort','cow','crack','engineer','entrance','fault','grass','guy','hell','highlight','incident','island','joke','jury','leg','lip','mate','motor','nerve','passage','pen','pride','priest','prize','promise','resident','resort','ring','roof','rope','sail','scheme','script','sock','station','toe','tower','truck','witness'];
var adv = ['usually','really','early','likely','simply','generally','actually','especially','quickly','probably','directly','easily','eventually','exactly','certainly','normally','currently','extremely','finally','constantly','properly','specifically','daily','highly','immediately','relatively','slowly','fairly','primarily','completely','ultimately','widely','recently','seriously','frequently','fully','mostly','naturally','nearly','occasionally','carefully','clearly','essentially','possibly','slightly','equally','greatly','necessarily','personally','rarely','regularly','similarly','basically','closely','effectively','initially','literally','mainly','merely','gently','hopefully','originally','roughly','significantly','totally','obviously','perfectly','physically','successfully','suddenly','truly','virtually','automatically','deeply','definitely','deliberately','hardly','readily','terribly','unfortunately','briefly','strongly','honestly','previously','only','absolutely']
var conj = ['accordingly','also','besides','comparatively','conersely','equally further','hence','however','in comparison','incidentally','instead','meanwhile','namely','next','now','rather','still','then','therefore','undoubtedly','additionally','anyway','certainly','consequently','elsewhere','finally','furthermore','henceforth','in addition','in contrast','indeed','likewise','moreover','nevertheless','nonetheless','otherwise','similary','subsequently','thereafter','thus','yet'];
var sentence = function sentence(structure){
this.structure = structure;
this.makePhrase = function() {
return _.map(this.structure, function(a){
return pickRandom(a)
}).join(' ')};
this.entropy = function() {
return Math.round( 10 * Math.log2(
_.reduce(
_.map(this.structure, function(a){
return a.length
}),
function(a, b){
return a * b
}
)
))/10
}
}
var s = new sentence([
adj, noun, adv, verb , adj, noun
]);
console.log(
s.makePhrase()
);
console.log(
s.entropy() + ' bits of entropy'
);