October 27, 2021, 08:11:53

Author Topic: [bmx] Generate Random English Words or Names  (Read 1370 times)

Offline GW

  • Full Member
  • ***
  • Posts: 222
[bmx] Generate Random English Words or Names
« on: February 03, 2021, 01:29:30 »
Code: [Select]
SuperStrict
Framework brl.basic
Import brl.retro
Import brl.map

SeedRnd(MilliSecs())

Global Segments:TMap = CreateMap()
Global SegList:TList = CreateList()

BuildSegments()


'-------
' Demo:
'-------
Print "~nLength:1"
For Local i% = 0 Until 20
    Print MakeWord(1)
Next
Print "~nLength:2"
For Local i% = 0 Until 20
    Print MakeWord(2)
Next
Print "~nLength:3"
For Local i% = 0 Until 20
    Print MakeWord(3)
Next
   



'----------------------------------------------------------------------------------------------------------------------------
Function MakeWord$(Syllables%)
    If Syllables<1 Then Syllables:+1
    Local L% = Seglist.Count()-1
    Local w$= Chr(Rand(97,122))
    If "aeiou".Contains(W) Then w=""
    For Local i% = 0 Until Syllables
        w :+ String(SegList.ValueAtIndex(Rand(L)) )
    Next
    Local r%=Rand(0,25)
    If(r<5) Then w = w+ "aeiou"[r..r+1]
    Return w
End Function

'----------------------------------------------------------------------------------------------------------------------------
Function BuildSegments()
    Local ss$ ="ab,abb,abl,aby,ac,acc,ach,ack,ackg,acks,ackst,ackw,act,actl,ad,adc,add,adl,af,aff,ag,agg,ags,ak,akl" + ..
    "akw,al,ald,aldl,alk,all,alr,alt,alth,aly,am,amb,amp,amph,ams,an,anc,and,andc,ands,andt,andw,ang,angs " + ..
    "ank,ankl,ann,ans,ansc,ant,antl,antr,anw,ap,aph,aphy,app,apt,ar,arb,arc,arch,ard,ardl,ards,arg,ark"+..
    "arl,arm,armt,arn,arp,arpl,arr,ars,arsh,arshl,art,arth,arthl,artl,arty,artyr,ary,aryn,as,ash,ask,asm"+..
    "asp,ass,ast,astl,at,atc,atch,ath,athl,atl,att,av,aw,awn,ax,ay,ayd,ayg,az,azz,eb,ebl,ec,ech,eck,ect"+..
    "ectl,ed,edd,edl,ef,efl,eg,egy,ek,ekl,el,elc,eld,elf,elfr,ell,elly,elp,els,elt,em,emb,embl,emp,empt"+..
    "en,enc,end,endl,ends,eng,engt,ength,enk,enl,ent,entl,enz,ep,epl,ept,epth,er,erb,erc,erf,erg,erk,erl"+..
    "erm,ern,ernl,erp,err,ers,ert,erth,erw,ery,eryt,eryw,es,esc,esd,esh,esp,ess,essl,est,estl,et,etc,etl"+..
    "etr,ett,ew,ewd,ewl,ews,ewsf,ex,exc,exp,ext,ey,eyl,ez,ezz,ib,ibb,ibl,ic,ich,ick,ickl,icl,ict,ictl,icy"+..
    "icyc,id,idd,iddl,idl,idn,ids,idt,if,iff,ift,iftl,ig,igg,igh,ighl,ight,ightl,ign,il,ild,ildl,ilk,ill"+..
    "ilm,ils,ilt,ilth,ilts,ilv,im,imb,imbl,iml,imp,impl,ims,in,inc,inch,inct,inctl,ind,indl,ing,ingl,ink"+..
    "inl,inn,ins,insc,int,intl,ip,ipp,ips,ir,irc,ird,irl,irm,irml,irs,irst,irt,is,isc,isf,isg,ish,ishl"+..
    "isk,iskl,ism,isp,iss,ist,istr,it,itc,ith,iths,itl,itp,itt,ix,ixt,iz,izz,ob,obb,oc,ock,oct,od,ods,odt"+..
    "ody,of,oft,oftl,og,ogg,oh,ok,oks,ol,olc,old,oldl,olds,oll,olp,ols,olt,oly,olys,olysy,olysyl,om,omb"+..
    "omp,ompt,omptl,on,onc,ond,ondl,onf,ong,ongl,onl,onp,ons,onst,ont,onth,ony,onym,op,oph,or,orc,ord"+..
    "ords,ork,orks,orl,orm,orn,orp,orr,ors,ort,orth,ortl,os,osp,oss,ossl,ost,ostl,ot,oth,ots,ott,ow,owd"+..
    "owl,own,ows,owt,ox,oy,ub,ubb,ubl,ubs,ubsc,ubt,ubtl,uc,uch,uck,ucks,uct,ud,udd,udg,udl,uf,uff,uft,ug"+..
    "ugg,ugh,ughl,ught,ughtc,ul,uld,ulf,ulk,ull,ulp,ult,um,umb,umbl,umm,umn,ump,ums,un,unc,und,ung,ungr"+..
    "unk,unn,uns,unt,untr,untry,up,upp,uppl,upt,uptl,ur,urc,urd,url,urn,urp,urr,urs,urt,us,usc,ush,usl"+..
    "uss,ust,ustl,ustr,ut,utc,utf,uth,uts,utt,uv,uz,uzz"
   
    For Local s$ = EachIn ss.Split(",")
        SegList.AddLast(s)
    Next
    Return
End Function


   
   
rem
    '// If you want to make your own words(segments) in another language, Here is how it's done.

    'https://dl.packetstormsecurity.net/Crackers/wordlists/literature/1984.txt.gz
    Local file$ = LoadText("C:\temp\1984.txt") 'list of unique words in 1984 novel
    Local aFile$[] = file.Split("~n")
    Local s2$
    Local activelist:TList
       
    For Local s$ = EachIn aFile
        If s.Length < 3 Then Continue
        Local f%=0
        For Local L% = 0 Until s.Length
            Local c$ = Chr(s[L]).ToLower()
             If "aeiou".Contains(c) Then f = L
             If f<>0 And (Not "aeiou".Contains(c)) Then AddSeg(s[f..L].ToLower())
        Next
    Next
   
    For Local s$ = EachIn Segments.Keys()
        SegList.AddLast(s)
        Print s
    Next
   
    Function AddSeg(s$)
        'using a map to prune duplicates
        If "aeiou".Contains(s) Then Return
        'Print s
        If Segments.Contains(s) Then Return
        Segments.Insert(s,"#")       
    End Function
endrem



Length:1
vodtody
quff
vuff
resc
zonyma
gorm
wal
qighl
nartyr
qernl
lexc
qazz
tenk
ress
widl
jipp
unn
owdowl
zuck
oftl

Length:2
jorted
huckismu
jecims
dintif
dempendl
ferbatu
utiml
olal
zibbex
ismusc
temptenend
jaltift
lanscestl
lesithso
dertildl
zeyald
kechur
falthiddl
latends
zenzurra

Length:3
hispistraldl
kurelcay
luptlustan
yartyolsoh
armoltinca
tiggackoph
ekuthards
wundipubtl
onsindlelfr
zantleplength
julirmorm
burlonglock
iggondlign
nulkardachu
impidtabli
entucksomptli
hinnertinctl
corthernlepl
hisklarshlorn
noldsummarbi
« Last Edit: February 03, 2021, 01:31:52 by GW »

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal