initial import from personnal project

master
Cédric Ronvel 2017-09-03 17:52:39 +02:00
commit 7c10074064
51 changed files with 5040 additions and 0 deletions

51
.gitignore vendored Normal file
View File

@ -0,0 +1,51 @@
# Specific #
############
package-lock.json
*.local.*
*.local
*.log
*.html.gz
*.css.gz
*.js.gz
*.tmp
.spellcast
build
_build
_templates
_static
# gitignore / Node.gitignore #
##############################
lib-cov
lcov.info
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
build
.grunt
node_modules
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

41
.jshintrc Normal file
View File

@ -0,0 +1,41 @@
{
// Generic options
"maxerr" : 20,
// Predefined globals (node.js, browser, etc...)
"node" : true,
"browser" : false,
"jquery" : false,
// Security
"eqeqeq" : true, // true: Require triple equals (===) for comparison
//"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"latedef" : false, // true: Require variables/functions to be defined before being used
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : true, // true: Require all defined variables be used
// Style
"indent" : 4, // Specify indentation spacing
"camelcase" : true,
// "maxlen" : 120,
"curly" : true,
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : false, // Prohibit use of constructors for side-effects.
"plusplus" : false, // Prohibit use of `++` & `--`.
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"smarttabs" : true, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
"trailing" : true, // Prohibit trailing whitespaces.
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"quotmark" : false, // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"maxparams" : 6, // {int} Max number of formal params allowed per function
"maxdepth" : 5, // {int} Max depth of nested blocks (within functions)
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"esversion": 6
}

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Cédric Ronvel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

97
Makefile Normal file
View File

@ -0,0 +1,97 @@
# User rules
# The first rule is the default rule, when invoking "make" without argument...
# Build every buildable things
all: install doc
# Just install things so it works, basicaly: it just performs a "npm install --production" ATM
install: log/npm-install.log
# Just install things so it works, basicaly: it just performs a "npm install" ATM
dev-install: log/npm-dev-install.log
# This run the JsHint & Mocha BDD test, display it to STDOUT & save it to log/mocha.log and log/jshint.log
test: log/jshint.log log/mocha.log
# This run the JsHint, display it to STDOUT & save it to log/jshint.log
lint: log/jshint.log
# This run the Mocha BDD test, display it to STDOUT & save it to log/mocha.log
unit: log/mocha.log
# This build the doc and README.md
doc: README.md
# This publish to NPM and push to Github, if we are on master branch only
publish: log/npm-publish.log log/github-push.log
# Clean temporary things, or things that can be automatically regenerated
clean: clean-all
# Variables
MOCHA=../node_modules/mocha/bin/mocha -c
JSHINT=./node_modules/jshint/bin/jshint --verbose
# Files rules
# JsHint STDOUT test
log/jshint.log: log/npm-dev-install.log lib/*.js test/*.js
${JSHINT} lib/*.js test/*.js | tee log/jshint.log ; exit $${PIPESTATUS[0]}
# Mocha BDD STDOUT test
log/mocha.log: log/npm-dev-install.log lib/*.js test/*.js
cd test ; ${MOCHA} *.js -R spec | tee ../log/mocha.log ; exit $${PIPESTATUS[0]}
# README
README.md: documentation.md
cat documentation.md > README.md
# Mocha Markdown BDD spec
bdd-spec.md: log/npm-dev-install.log lib/*.js test/*.js
cd test ; ${MOCHA} *.js -R markdown > ../bdd-spec.md
# Upgrade version in package.json
log/upgrade-package.log: lib/*.js test/*.js documentation.md
npm version patch -m "Upgrade package.json version to %s" | tee log/upgrade-package.log ; exit $${PIPESTATUS[0]}
# Publish to NPM
log/npm-publish.log: check-if-master-branch log/upgrade-package.log
npm publish | tee log/npm-publish.log ; exit $${PIPESTATUS[0]}
# Push to Github/master
log/github-push.log: lib/*.js test/*.js package.json
#'npm version patch' create the git tag by itself...
#git tag v`cat package.json | grep version | sed -r 's/.*"([0-9.]*)".*/\1/'`
git push origin master --tags | tee log/github-push.log ; exit $${PIPESTATUS[0]}
# NPM install
log/npm-install.log: package.json
npm install --production | tee log/npm-install.log ; exit $${PIPESTATUS[0]}
# NPM install for developpement usage
log/npm-dev-install.log: package.json
npm install | tee log/npm-dev-install.log ; exit $${PIPESTATUS[0]}
# PHONY rules
.PHONY: clean-all check-if-master-branch
# Delete files, mostly log and non-versioned files
clean-all:
rm -rf log/*.log README.md bdd-spec.md node_modules
# This will fail if we are not on master branch (grep exit 1 if nothing found)
check-if-master-branch:
git branch | grep "^* master$$"

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# Nomi
Early alpha.

24
TODO Normal file
View File

@ -0,0 +1,24 @@
Jutsu:
- Input filtering customization.
Markov:
- Non-integer markov order: create 2 graph each with the next and previous order, randomly use one of them.
E.g.: order 2.3 will have 70% of chance to use order 2 and 30% of chance to use order 3 for each step.
- Varying markov order: start low, grow at the middle of the word, finish low. Allow more creative words
but keep solid root at the middle.
Non-markov generators:
- Just join random element from arrays.
Generating elvish name is easiest this way: just concatenate an adjective with a suffixe.
- Create "portmanteau" word, created by picking two word randomly from a pool, markov may help joining them.

2
bin/nomi Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require( '../lib/Nomi.js' ).cli() ;

View File

@ -0,0 +1,84 @@
slugId: ancient-scandinavian-female
order: 2
atomMin: 3
atomMax: 12
outputSanitizers:
- capitalize
samples:
- alfhildr
- arnbjörg
- ása
- ásdís
- áslaug
- ásta
- ástríðr
- aðalbjörg
- auðrhildr
- bergljót
- björg
- borghildr
- bóthildr
- brynhildr
- brynja
- dagmær
- dagný
- dagrún
- edda
- eydís
- fríða
- grímhildr
- gulla
- gunna
- gunnbjörg
- gunnhildr
- gunnvör
- guðlaug
- guðleif
- guðríðr
- guðrún
- gyða
- hallþóra
- helga
- hildr
- hjördís
- hlíf
- hreiðunn
- inga
- ingibjörg
- ingigerðr
- ingríðr
- ingvildr
- iðunn
- jórunnr
- ketilriðr
- magnhildr
- myrgjöl
- ragna
- ragnbjörg
- ragnfríðr
- ragnheiðr
- ragnhildr
- rúna
- signý
- sigríðr
- sigrún
- sólveig
- svanhildr
- þone
- þóra
- þórbjörg
- þórdís
- þórfríðr
- þórhildr
- þórný
- þórveig
- þórví
- þýri
- tófa
- unnr
- valdís
- vígdís
- yngvildr

View File

@ -0,0 +1,139 @@
slugId: ancient-scandinavian-male
order: 2
atomMin: 3
atomMax: 12
outputSanitizers:
- capitalize
samples:
- aghi
- agmundr
- áki
- áleifr
- alfarr
- ari
- arnfinnr
- árni
- arnórr
- arnþórr
- arnviðr
- ásbjörn
- ásgeirr
- ásketill
- ásmundr
- ásvaldr
- aðalsteinn
- bárðr
- birgir
- bjarni
- bjartr
- björn
- brandr
- brynjarr
- búi
- dagfinnr
- dagr
- danr
- egill
- eileifr
- einarr
- eindriði
- eiríkr
- erlendr
- erlingr
- eysteinn
- eyvindr
- finnr
- fólki
- friðþjófr
- fróði
- gautstafr
- geirr
- gulbrandr
- gunnarr
- gunni
- guðbrandr
- guðfriðr
- guðleifr
- guðmundr
- hákon
- hálfdan
- hallbjörn
- halli
- hallr
- hallsteinn
- hallþórr
- hallvarðr
- haraldr
- hávarðr
- helgi
- hemingr
- herleifr
- hjálmarr
- hólmgeirr
- hrafn
- hreiðarr
- hróaldr
- hróarr
- hrœrekr
- hrólfr
- hróðgeirr
- hróðólfr
- hróðvaldr
- hugleikr
- ingi
- ingimárr
- ingólfr
- ívarr
- jarl
- kári
- ketill
- knútr
- kóri
- leifr
- magni
- njáll
- oddr
- ragnarr
- ragnvaldr
- randúlfr
- ráðúlfr
- rúni
- sigfrøðr
- sigmundr
- sigsteinn
- sigurðr
- sindri
- snorri
- somarliðr
- steinarr
- steinn
- stígandr
- stigr
- svantepolk
- sveinn
- sverrir
- þórarinn
- þórbjörn
- þórfastr
- þórfreðr
- þórgeirr
- þórgísl
- þórgnýr
- þórir
- þórketill
- þórleifr
- þórleikr
- þórmóðr
- þórsteinn
- þórvaldr
- þróndr
- tófi
- tryggvi
- úlfr
- valdimárr
- vígi
- víkingr
- yngvarr

View File

@ -0,0 +1,152 @@
slugId: biblic-female
order: 2
atomMin: 3
atomMax: 13
outputSanitizers:
- capitalize
samples:
- abiah
- abigail
- abijah
- abilene
- abishag
- abital
- adah
- agrippa
- ahinoam
- anah
- anna
- apphia
- aquila
- ariel
- asenath
- ashtoreth
- atarah
- athaliah
- avital
- azubah
- basemath
- bashemath
- basmath
- bathsheba
- bernice
- bethany
- bethel
- beulah
- bilhah
- bithiah
- candace
- chloe
- claudia
- damaris
- deborah
- delilah
- diklah
- dinah
- dorcas
- drusilla
- edna
- elisabeth
- elisheba
- elizabeth
- ephrath
- esther
- eunice
- eve
- gethsemane
- gomer
- hadassah
- hagar
- haggith
- hannah
- havilah
- helah
- hephzibah
- hepzibah
- hodiah
- hosanna
- hulda
- huldah
- iscah
- ivah
- jael
- jahel
- jedidah
- jemima
- jerusha
- jescha
- jezebel
- joanna
- jochebed
- judith
- julia
- junia
- kandake
- keren-happuch
- keturah
- kezia
- keziah
- leah
- lois
- lydia
- magdalene
- mahalath
- mahlah
- mara
- martha
- mary
- mehetabel
- mehitabel
- merab
- micaiah
- michal
- milka
- miriam
- moriah
- naamah
- naomi
- noa
- noah
- nogah
- orpah
- orpha
- peninnah
- persis
- phebe
- phoebe
- prisca
- priscilla
- rachel
- rahab
- rebecca
- rebekah
- rhoda
- ruth
- salome
- sapphira
- sarah
- sarai
- sela
- selah
- sherah
- shiloh
- shiphrah
- shulamite
- shulammite
- susanna
- susannah
- syntyche
- tabitha
- talitha
- tamar
- tirzah
- tryphena
- tryphosa
- vashti
- zibiah
- zillah
- zilpah
- zipporah

View File

@ -0,0 +1,421 @@
slugId: biblic-male
order: 2
atomMin: 3
atomMax: 14
outputSanitizers:
- capitalize
samples:
- aaron
- abaddon
- abednego
- abel
- abiah
- abidan
- abiel
- abihu
- abijah
- abimael
- abimelech
- abiram
- abishai
- abner
- abraham
- abram
- absalom
- achaicus
- achan
- achim
- adalia
- adam
- adina
- adino
- adlai
- adonijah
- adoniram
- agrippa
- ahab
- alexander
- allon
- alphaeus
- alvah
- amal
- amariah
- ami
- amittai
- ammiel
- amnon
- amos
- amram
- anah
- anaiah
- anan
- anani
- ananias
- anath
- andrew
- annas
- aquila
- aran
- archelaus
- areli
- aretas
- aridai
- arieh
- ariel
- artaxerxes
- asa
- asaph
- asher
- athaliah
- azarel
- azaria
- azariah
- azazel
- azaziah
- azel
- azriel
- barak
- barnabas
- bartholomew
- baruch
- beelzebub
- belial
- belshazzar
- benaiah
- benjamin
- bethuel
- boaz
- buz
- caiaphas
- cain
- cainan
- caleb
- canaan
- carmi
- carpus
- cephas
- chenaniah
- cleopas
- cleophas
- clopas
- cornelius
- cyrus
- dan
- daniel
- darius
- dathan
- david
- delaiah
- diklah
- dionysius
- ebenezer
- eder
- edom
- efraim
- ehud
- elam
- eldad
- eleazar
- eli
- eliakim
- eliezer
- elihu
- elijah
- elioenai
- eliphalet
- eliphelet
- elisha
- eliud
- elkanah
- elnathan
- elon
- emmanuel
- enoch
- enos
- enosh
- epaphras
- ephraim
- eran
- erastus
- esau
- esdras
- ethan
- eutychus
- ezar
- ezekiel
- ezer
- ezra
- felix
- festus
- gabriel
- gad
- gaius
- gamaliel
- gedaliah
- gemariah
- gera
- gershom
- gershon
- gideon
- gilead
- goliath
- gomer
- habakkuk
- haggai
- ham
- hanan
- hananiah
- haran
- havilah
- hazael
- heber
- heli
- herod
- herodion
- hezekiah
- hillel
- hirah
- hiram
- hizkiah
- hosea
- hoshea
- huri
- ichabod
- immanuel
- ira
- isaac
- isaiah
- isaias
- ishmael
- ishmerai
- ishvi
- israel
- issachar
- ithai
- ithamar
- ithiel
- ittai
- jaala
- jaasau
- jabez
- jabin
- jachin
- jacob
- jada
- jadon
- jahleel
- jahzeel
- jair
- jairus
- james
- jamin
- japheth
- jarah
- jared
- jason
- javan
- jedidiah
- jehiel
- jehoash
- jehoiachin
- jehoiakim
- jehonathan
- jehoram
- jehoshaphat
- jehu
- jehudi
- jephtha
- jephthah
- jeremiah
- jeremiel
- jeremy
- jeriah
- jericho
- jesse
- jesus
- jethro
- joab
- joash
- job
- joel
- john
- joktan
- jonah
- jonas
- jonathan
- joram
- josaphat
- joseph
- joses
- joshua
- josiah
- josias
- jotham
- jubal
- judah
- judas
- jude
- kenan
- kenaniah
- laban
- lael
- lamech
- lazarus
- lehi
- lemuel
- levi
- lot
- lucius
- luke
- madai
- mahalah
- mahali
- mahlah
- mahli
- malachi
- manasseh
- manasses
- mark
- mattan
- mattaniah
- matthan
- matthew
- matthias
- medad
- melech
- menahem
- merari
- meshach
- meshullam
- methuselah
- micah
- micaiah
- micajah
- michael
- mnason
- moab
- mordecai
- moses
- nadab
- nahor
- nahum
- naphtali
- narcissus
- nathan
- nathanael
- nathaniel
- nebo
- nebuchadnezzar
- nehemiah
- nekoda
- nereus
- neriah
- nethanel
- nethaniah
- nicodemus
- nimrod
- noah
- nogah
- obadiah
- obed
- oded
- ohad
- omar
- omri
- onesimus
- onesiphorus
- ophir
- ophrah
- oshea
- othniel
- pallu
- paul
- peleg
- penuel
- perez
- peter
- phanuel
- pharez
- philemon
- philetus
- philip
- phineas
- phinehas
- pontius
- prochorus
- ram
- raphael
- rehoboam
- reuben
- reuel
- rufus
- salathiel
- samson
- samuel
- satan
- saul
- seraiah
- seth
- shadrach
- shamgar
- sharar
- shealtiel
- sheba
- shelah
- shem
- shemaiah
- shemer
- shiloh
- silas
- silvanus
- simeon
- simon
- solomon
- stephen
- talmai
- tekoa
- teman
- terah
- thaddaeus
- thaddeus
- theophilus
- thomas
- timaeus
- timeus
- timon
- timothy
- tiras
- titus
- tobiah
- tobias
- urban
- uri
- uriah
- uriel
- urijah
- uzzi
- uzziah
- uzziel
- zaccai
- zacchaeus
- zachariah
- zacharias
- zadok
- zalmon
- zarah
- zebadiah
- zebedee
- zebulon
- zebulun
- zechariah
- zedekiah
- zelophehad
- zephaniah
- zerah
- ziba
- zimri
- zion
- zuriel

99
data/generators/elf.kfg Normal file
View File

@ -0,0 +1,99 @@
slugId: elf
order: 2
atomMin: 3
atomMax: 12
outputSanitizers:
- capitalize
samples:
# https://en.wikipedia.org/wiki/List_of_Middle-earth_Elves
- aegnor
- amarië
- amdír
- amras
- amrod
- amroth
- anairë
- angrod
- annael
- aredhel
- beleg
- caranthir
- celeborn
- celebrían
- celebrimbor
- celegorm
- círdan
- curufin
- daeron
- denethor
- duilin
- eärwen
- eärendil
- ecthelion
- edrahil
- egalmoth
- eldalótë
- elemmakil
- elemmírë
- elenwë
- elmo
- elrond
- enel
- enelyë
- enerdhil
- eöl
- erestor
- fëanor
- finarfin
- findis
- finduilas
- fingolfin
- fingon
- finwë
- galadhon
- galadriel
- galathil
- galion
- gimli
- glorfindel
- gwindor
- haldir
- idril
- imin
- iminyë
- indis
- inglor
- ingwë
- ingwion
- irimë
- legolas
- lindir
- lúthien
- mablung
- maedhros
- maeglin
- maglor
- mahtan
- míriel
- mithrellas
- nellas
- nerdanel
- nimrodel
- olwë
- orodreth
- oropher
- orophin
- pengolodh
- penlod
- rog
- saeros
- salgant
- tata
- tatië
- thranduil
- turgon
- tuor
- voronwë

View File

@ -0,0 +1,14 @@
generators:
- @@lorem-ipsum.kfg
- @@elf.kfg
- @@ancient-scandinavian-female.kfg
- @@ancient-scandinavian-male.kfg
- @@mythic-greek-female.kfg
- @@mythic-greek-male.kfg
- @@mythic-norse-male.kfg
- @@mythic-norse-female.kfg
- @@biblic-male.kfg
- @@biblic-female.kfg
- @@old-english-female.kfg
- @@old-english-male.kfg

View File

@ -0,0 +1,14 @@
slugId: lorem-ipsum
order: 2
atomMin: 7
atomMax: 20
#rebranching: 3
sourceSplitter: <regex> /\. */
#sampleSplitter: / +|(?=,)/
sampleSplitter: <regex> /(?=,| )/
sampleAppend: .
samples: @@lorem-ipsum.txt

View File

@ -0,0 +1 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac commodo odio. Mauris elit sem, ornare vel porttitor non, volutpat eget lacus. Nam interdum gravida tortor vitae pulvinar. Fusce accumsan eleifend tellus, id viverra erat eleifend vitae. Morbi auctor mi vel nisi semper consequat. Nunc pretium elit vel dolor aliquam placerat. Etiam ac sem vitae nisl sodales varius vel id lorem. Maecenas et cursus nulla, aliquet volutpat nulla. Cras ultricies aliquet euismod. Nullam mollis justo vitae metus pulvinar accumsan. Etiam sodales orci vel odio feugiat lacinia. Etiam est massa, euismod a eros ac, sodales imperdiet libero. Proin vel dignissim est, eu hendrerit elit. Donec eget ipsum id velit aliquam volutpat. Phasellus vitae lorem non lorem pulvinar imperdiet eget id massa. Donec massa arcu, ultrices nec scelerisque vehicula, dapibus eget dui. Pellentesque tristique lorem sed varius tristique. Nam volutpat interdum massa, sit amet lobortis ex. Sed sed egestas diam, eget tristique sem. Nullam et nisi quis urna interdum convallis. Cras dictum purus id elit aliquam mattis. Nulla sed porta urna, vitae fringilla tortor. Proin et odio tristique, sagittis tellus id, vestibulum enim. Aliquam erat volutpat. Quisque varius eros ac sollicitudin sodales. Mauris porttitor nisl id quam dignissim tempor. Nulla a sollicitudin orci. Nullam eu eleifend orci. Duis eleifend felis vel tortor finibus, ut bibendum sapien rhoncus. Morbi ante nisi, eleifend a risus at, dapibus tincidunt magna. Vestibulum sit amet neque ut urna scelerisque ornare. Donec scelerisque fringilla sollicitudin. Morbi a mollis justo. Cras gravida tristique gravida. Nam felis sapien, imperdiet id porta a, auctor sed metus. Donec eu lorem nisl. Sed sit amet semper nibh. Sed sollicitudin eleifend malesuada. Proin vestibulum odio at neque consequat, nec consequat augue ornare. Phasellus consectetur et eros sed fringilla. Sed consectetur ultricies tortor, sit amet blandit mi commodo vitae. Mauris finibus sem vitae mauris luctus, non facilisis tortor aliquam. Nullam semper ipsum non mollis venenatis. Nunc sem dui, tincidunt eu sem vulputate, accumsan condimentum neque. Ut fringilla risus vitae diam commodo, id tincidunt odio tincidunt. Curabitur in blandit risus, eu malesuada nisi. Donec sed nisi metus. Suspendisse dolor leo, vulputate egestas aliquam vel, dictum et dolor. Nullam gravida orci risus, a auctor elit volutpat id. Aenean ultricies mauris sit amet laoreet maximus. In imperdiet fermentum imperdiet. Sed quam justo, finibus quis tempus posuere, feugiat id turpis. Pellentesque sit amet erat at diam condimentum ullamcorper a eget ante. Sed volutpat velit nec sollicitudin ornare. Pellentesque elementum quis odio non auctor. Etiam mollis urna in ligula pharetra, vel pellentesque metus consectetur. Aenean condimentum enim nec arcu molestie imperdiet. Sed egestas, orci nec blandit iaculis, leo elit varius tortor, eget rutrum libero dolor at quam. Nulla vel lacinia massa. Proin placerat ipsum non fringilla interdum. Fusce eu eros turpis. Mauris iaculis massa ac metus suscipit porttitor. Suspendisse maximus est sed lacus vulputate luctus. Praesent eleifend ac arcu eget scelerisque. Integer rutrum erat consectetur ornare ultrices. Donec consequat diam id nulla volutpat efficitur. Donec aliquet ex at quam ultrices gravida. Phasellus tempus, odio sit amet varius eleifend, tellus ex ultrices magna, eget ornare nisi nisl id ex. Vestibulum non justo varius, facilisis libero vitae, blandit arcu.

View File

@ -0,0 +1,207 @@
slugId: mythic-greek-female
order: 2
atomMin: 4
atomMax: 14
outputSanitizers:
- capitalize
samples:
- acantha
- adrastea
- adrasteia
- aegle
- aella
- agaue
- aglaea
- aglaia
- aigle
- akantha
- alcippe
- alcyone
- alecto
- alekto
- alexandra
- alkippe
- alkyone
- althea
- amalthea
- andromache
- andromeda
- anthea
- antheia
- antigone
- antiope
- aoede
- aoide
- aphrodite
- arachne
- arethousa
- arethusa
- ariadne
- artemis
- astraea
- astraia
- atalanta
- athena
- athene
- atropos
- briseis
- calliope
- callisto
- calypso
- carme
- cassandra
- cassiopea
- cassiopeia
- chloe
- chloris
- chryseis
- circe
- clio
- clotho
- clytemnestra
- clytia
- cora
- cynthia
- danaë
- daphne
- delia
- demeter
- despoina
- dike
- dione
- doris
- echo
- eileithyia
- eirene
- electra
- elektra
- elpis
- enyo
- eos
- erato
- eris
- euadne
- euanthe
- eudora
- eunomia
- euphrosyne
- europa
- europe
- eurydice
- eurydike
- euterpe
- evadne
- gaea
- gaia
- halcyone
- halkyone
- harmonia
- hebe
- hecate
- hecuba
- hekabe
- hekate
- helen
- helena
- helene
- helle
- hemera
- hera
- hermione
- hero
- hestia
- hippolyta
- hippolyte
- ianthe
- ilithyia
- io
- iole
- ione
- iphigeneia
- iphigenia
- irene
- iris
- ismene
- jocasta
- kalliope
- kallisto
- kalypso
- karme
- kassandra
- kassiopeia
- kirke
- kleio
- klotho
- klytaimnestra
- klytië
- kore
- korë
- kynthia
- lachesis
- lamia
- larisa
- leda
- leto
- ligeia
- maia
- medea
- medeia
- medousa
- medusa
- megaera
- megaira
- melaina
- melete
- melia
- melissa
- melpomene
- mneme
- mnemosyne
- nausicaa
- nausikaa
- nemesis
- nephele
- nike
- nikephoros
- niobe
- nyx
- oenone
- oinone
- ourania
- pallas
- pandora
- parthenia
- parthenope
- penelope
- persephone
- phaedra
- phaenna
- phaidra
- philomela
- phoebe
- phoibe
- phyllis
- pistis
- polyhymnia
- polymnia
- polyxena
- polyxene
- praxis
- psyche
- rhea
- rheia
- selena
- selene
- semele
- terpsichore
- tethys
- thaleia
- thalia
- theia
- themis
- tisiphone
- urania
- xanthe

View File

@ -0,0 +1,156 @@
slugId: mythic-greek-male
order: 2
atomMin: 4
atomMax: 12
outputSanitizers:
- capitalize
samples:
- achilles
- achilleus
- adonis
- adrastos
- aeolus
- aeson
- agamemnon
- aias
- aineias
- aiolos
- ajax
- alcides
- alexander
- alexandros
- alkeides
- apollo
- apollon
- ares
- argus
- aristaeus
- aristaios
- aristodemos
- asklepios
- atlas
- bacchus
- brontes
- castor
- cephalus
- cepheus
- cerberus
- charon
- chryses
- coeus
- crius
- cronus
- daedalus
- damocles
- damokles
- damon
- dardanos
- deimos
- diomedes
- dionysos
- dionysus
- endymion
- epimetheus
- erebos
- erebus
- eros
- euandros
- evander
- ganymede
- ganymedes
- glaucus
- glaukos
- hades
- hector
- hektor
- helios
- hephaestus
- hephaistos
- heracles
- herakles
- hermes
- hippolytos
- hyacinth
- hyacinthus
- hyakinthos
- hyperion
- iacchus
- iapetos
- iapetus
- iason
- icarus
- ion
- jason
- kastor
- kephalos
- kepheus
- kerberos
- koios
- kreios
- kronos
- leander
- leandros
- linos
- linus
- lycurgus
- lycus
- lykos
- lykourgos
- melanthios
- menelaos
- menelaus
- mentor
- midas
- morpheus
- narcissus
- narkissos
- neoptolemos
- neoptolemus
- nereus
- nestor
- nikephoros
- oceanus
- odysseus
- oedipus
- oidipous
- okeanos
- orestes
- orion
- orpheus
- ouranos
- pallas
- pan
- paris
- patroclus
- patroklos
- pegasus
- perseus
- philander
- philandros
- phobos
- phoebus
- phoibos
- phrixos
- phrixus
- plouton
- pluto
- polydeukes
- poseidon
- priam
- priamos
- prometheus
- proteus
- pyrrhos
- pyrrhus
- pythios
- sarpedon
- thanatos
- theseus
- uranus
- zephyr
- zephyros
- zephyrus
- zeus

View File

@ -0,0 +1,47 @@
slugId: mythic-norse-female
order: 2
atomMin: 3
atomMax: 12
outputSanitizers:
- capitalize
samples:
- borghild
- borghildr
- brynhildr
- eir
- embla
- erna
- frea
- freya
- freyja
- frigg
- gerd
- grid
- grímhildr
- gróa
- gudrun
- gunnr
- guðrún
- heidrun
- heiðrún
- hel
- hildr
- huld
- hulda
- idun
- iðunn
- nanna
- saga
- sif
- signý
- sigrún
- siv
- skaði
- skuld
- svanhild
- svanhildr
- urd
- verdandi

View File

@ -0,0 +1,45 @@
slugId: mythic-norse-male
order: 2
atomMin: 3
atomMax: 12
outputSanitizers:
- capitalize
samples:
- alf
- alfr
- alvis
- ask
- askr
- balder
- baldr
- frey
- freyr
- gandalf
- gunnar
- gunnarr
- jarl
- loke
- loki
- njáll
- njord
- njörðr
- oden
- odin
- ǫrvar
- orvar
- óðinn
- sigurd
- sigurðr
- sindri
- thor
- þórr
- týr
- tyr
- vidar
- víðarr
- völund
- völundr
- yngvi

View File

@ -0,0 +1,109 @@
slugId: old-english-female
order: 2
atomMin: 4
atomMax: 12
outputSanitizers:
- capitalize
samples:
- adgith
- aldgith
- aldwyn
- bledgifu
- bledswith
- bledwyn
- brunhild
- brunwyn
- burnhild
- burnwyn
- cwendar
- cwenhild
- cwenswith
- cynefled
- cynegith
- cynered
- cynewise
- cynewyn
- darfled
- dargifu
- darwise
- darwyn
- dawfled
- dawyn
- eafled
- eawyn
- edhild
- elfgifu
- elfhild
- elfwise
- engifu
- eowyn
- estmund
- estrun
- estswith
- estwyn
- ethelfled
- frithild
- garfled
- gledhild
- gledswith
- godliss
- godswith
- hild
- ides
- lúfa
- layfled
- layrun
- laywyn
- leofgifu
- leofled
- lissgifu
- lisswyn
- merefled
- meregifu
- meregith
- mereliss
- merewyn
- merthgifu
- merthgith
- merthwyn
- mildgith
- mildwyn
- olfete
- rosefled
- runfled
- runhild
- runwise
- runwyn
- saulred
- saulwyn
- shadufled
- shadugifu
- shaduwyn
- sigeburga
- sigerun
- sigewyn
- sorgifu
- sorrun
- sorwyn
- sunnfled
- sunngifu
- sunnwyn
- swetefled
- swetelayu
- sweterun
- swetewyn
- théodburga
- théodrun
- théodwyn
- trewfled
- trewgifu
- trewhild
- trewred
- trewrun
- trewyn
- wilfled
- wilrun
- wynfled

View File

@ -0,0 +1,109 @@
slugId: old-english-male
order: 2
atomMin: 4
atomMax: 12
outputSanitizers:
- capitalize
samples:
- éomer
- éomund
- adwig
- adwine
- aldor
- aldwine
- ardwulf
- baldhelm
- baldmund
- baldor
- baldred
- baldric
- baldwig
- baldwine
- bertric
- brego
- britta
- cadda
- celmund
- cenhelm
- cenric
- cenulf
- déor
- deorwine
- dernhelm
- dungar
- dunhere
- dunsig
- dunstan
- dunwine
- edbert
- edgar
- eforhild
- eforwine
- elfbert
- elfgar
- elfhelm
- elfred
- elfstan
- elfswith
- elfwine
- eofor
- eorl
- eothain
- erkenbrand
- ethelfrith
- ethelred
- ethelward
- ethelwine
- fastred
- fastwine
- felaróf
- fengel
- folca
- folcred
- folcwine
- fréa
- fréaláf
- fréawine
- fram
- freca
- frithbert
- frithdag
- frumgar
- gamling
- garwine
- gladwine
- goldwine
- gríma
- gram
- grimmund
- grimwine
- háma
- hefric
- helm
- hereward
- hild
- hildred
- hulac
- léod
- léofa
- leofdag
- leofric
- leofstan
- leofwine
- ordlac
- ordred
- ordstan
- sewine
- théodred
- thengel
- tirwald
- tordag
- torfrith
- wald
- wigbald
- wulf
- wulfgan
- wulfstan

View File

@ -0,0 +1,53 @@
name: drunken-master
info:
> Drunken master are powerful fearless fighter that use unorthodox fighting style,
> they use their drunkeness to fool their foe with strange, unusual and unpredictable move.
(merge) @@iaido-no-jutsu.kfg
replace: (<*) @@monkey-style.kfg#replace
replace:
" ":
- " "
a:
- ^
b:
- ß
- |:
- P>
c:
- ç
- ¢
- ©
d:
- I>
e:
- €
f:
- ƒ
l:
- £
n:
- ᴎ
r:
- ®
- я
s:
- §
t:
- †
u:
- µ
w:
- vv
y:
- ¥
z:
- ≥
"!":
- ¡
"?":
- ¿

83
data/jutsu/genin.kfg Normal file
View File

@ -0,0 +1,83 @@
name: genin
info: Genin are rookie still learning the art.
replace:
a:
- a
- A
b:
- b
- B
c:
- c
- C
d:
- d
- D
e:
- e
- E
f:
- f
- F
g:
- g
- G
h:
- h
- H
i:
- i
- I
j:
- j
- J
k:
- k
- K
l:
- l
- L
m:
- m
- M
n:
- n
- N
o:
- o
- O
p:
- p
- P
q:
- q
- Q
r:
- r
- R
s:
- s
- S
t:
- t
- T
u:
- u
- U
v:
- v
- V
w:
- w
- W
x:
- x
- X
y:
- y
- Y
z:
- z
- Z

19
data/jutsu/genjutsu.kfg Normal file
View File

@ -0,0 +1,19 @@
name: genjutsu
info:
> Genjutsu is the art of illusion. This art fool the senses of the foe, in a way he doesn't even know
> he is not seeing the reality anymore.
replace:
m:
- rn
u:
- u
- µ
w:
- w
- vv
x:
- x
- ×

View File

@ -0,0 +1,28 @@
name: iaido-no-jutsu
info:
> Iaido is the art of drawing the ninjato out of the saya and performing one or two fast deadly strikes,
> then cleaning and resheathing the sword.
(merge) @@taijutsu.kfg
replace:
a:
- "@"
c:
- "<"
- "["
- "("
i:
- "!"
- "¦"
- ":"
j:
- ";"
l:
- "|"
s:
- "$"
t:
- "+"

61
data/jutsu/kendo.kfg Normal file
View File

@ -0,0 +1,61 @@
name: kendo
info: Kendo is the way of the blade.
letterSpacing: " "
replace:
" ":
- " "
a:
- > /~\
b:
- > )3
c:
- > <
d:
- > |)
e:
- > (-
f:
- > )=
g:
- > (,
h:
- > )-(
i:
- > ¦
j:
- > _)
k:
- > )<
l:
- > )_
m:
- > )V(
n:
- > )\(
o:
- > ()
p:
- > )`
q:
- > '(
r:
- > )2
s:
- > _\¯
t:
- > ¯)¯
u:
- > )_(
v:
- > )/
w:
- > )/\(
x:
- > ,\
y:
- > `/
z:
- > ¯/_

84
data/jutsu/kinjutsu.kfg Normal file
View File

@ -0,0 +1,84 @@
name: kinjutsu
info: Forbidden art that have been banned, being way too dangerous for the world.
(merge) @@monkey-style.kfg
replace:
a:
- > /-|
- > |-\
e:
- > (~
g:
- > (_+
- > C-
h:
- > ]-[
- > }{
- > }-{
- > )-(
j:
- > </
k:
- > |{
- > )<
- > ){
l:
- > [_,
m:
- > |v|
- > /v\
- > )V(
- > (V)
- > (\/)
- > [V]
- > [\/]
- > /|/|
- > //.
- > /^^\
- > .\\
- > /\/\
n:
- > |V
- > /|/
o:
- > ()
p:
- > |°
- > |*
r:
- > ,-
- > /2
q:
- > 0_
- > ()_
- > (_,)
- > °|
s:
- > _/¯
t:
- > -|-
u:
- > (_)
- > (_|
- > L|
v:
- > |/
w:
- > (/\)
- > [/\]
- > \_|_/
- > \X/
- > \V/
- > vv
- > VV
- > '//
- > \\'
- > \^/
x:
- > ,\
z:
- > 7_
- > '/_
- > >_

View File

@ -0,0 +1,94 @@
name: kuchiyose
info: Kuchiyose no jutsu is the art of summoning occult forces, using mystical symbols to form complex seal.
# ˇ~#{[|`\^@]}~ø`´¡÷׿¹≤
# æâ€êþÿûîœôäßë‘’ðüïŀö«»© ↓¬
# ¸˛É˘—–‑È™ÇÀ≠±˚دÙ−∕⋅…≥
# Æ¢ÊÞŸÛÎŒÔÄ„Ë‚¥ÐÜÏĿÖ“”®←↑→
# ¢ł»¢“”n·@ßðđŋħjĸłµæ«€¶ŧ←↓→ø
replace:
a:
- α
- Δ
- Λ
b:
- β
- ß
c:
- ς
- ¢
d:
- Ð
- ð
e:
- ε
- ξ
- Σ
- ϵ
- ϶
f:
- ϝ
g:
- ϑ
h:
- ϗ
- ϰ
- ħ
i:
- ι
j:
- j
k:
- κ
l:
- λ
- ł
m:
- Π
- Ω
n:
- η
o:
- σ
- ø
- Ø
- θ
- Θ
p:
- ρ
- ϸ
- Ϸ
q:
- φ
- ψ
- Ψ
- Ϙ
- ϙ
r:
- π
s:
- ϟ
t:
- τ
- ŧ
u:
- μ
v:
- ν
- υ
w:
- ω
x:
- χ
- Ξ
y:
- γ
- ϒ
- ¥
z:
- ʒ
- ʓ
- ζ
- Ϟ

View File

@ -0,0 +1,77 @@
name: monkey-style
info:
> Monkey style is the secret art of a mythic monkey king that was traveling in China
> with a magical staff that can extend and retract at will.
replace:
" ":
- " "
a:
- > /-\
- > /\
b:
- > |3
c:
- > [
d:
- > |)
- > [)
e:
- > [-
f:
# - |=
- > /=
g:
- > [,
h:
- > |-|
i:
- > ¦
j:
- > _]
- > _/
- > _|
k:
- > |<
l:
- > |_
m:
- > |\/|
- > /|\
- > /\/\
- > |V|
- > /V\
n:
- > |\|
o:
- > []
p:
- > |>
- > |¯'
q:
- > > <|
- > '¯|
- > []_
r:
- > |2
- > |Z
s:
- > _\¯
t:
- > ¯|¯
u:
- > |_|
v:
- > \/
w:
- > \/\/
- > \|/
- > |/\|
x:
- > ><
y:
- > `/
z:
- > ¯/_

View File

@ -0,0 +1,60 @@
name: suiton-no-jutsu
info: Suiton no jutsu is the mystical art that manipulate water.
replace:
" ":
- " "
a:
- > (-)
b:
- > (3
c:
- > (
d:
- > |)
e:
- > (~
f:
- > (=
g:
- > (,
h:
- > )~(
- > }~{
i:
- > ¦
j:
- > _)
k:
- > |{
l:
- > )_
m:
- > (V)
n:
- > (\)
o:
- > ()
p:
- > (°
q:
- > ()_
r:
- > (2
s:
- > _/¯
t:
- > ¯)¯
u:
- > (_)
v:
- > \)
w:
- > (/\)
x:
- > ,\
y:
- > `/
z:
- > ¯/_

26
data/jutsu/taijutsu.kfg Normal file
View File

@ -0,0 +1,26 @@
name: taijutsu
info: Taijutsu is the powerful ninja's martial art. With those jutsu, ninja are able to fool most common foe.
replace: (<*) @@genin.kfg#replace
replace:
a:
- 4
b:
- 8
e:
- 3
g:
- 9
- 6
l:
- 1
o:
- 0
r:
- 2
s:
- 5
t:
- 7

7
documentation.md Normal file
View File

@ -0,0 +1,7 @@
# Nomi
Early alpha.

62
lib/KungFigExt.js Normal file
View File

@ -0,0 +1,62 @@
/*
The Cedric's Swiss Knife (CSK) - Nomi no Jutsu
Copyright (c) 2015 - 2016 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Load modules
var kungFig = require( 'kung-fig' ) ;
var tree = require( 'tree-kit' ) ;
module.exports = kungFig.extendOperators( {
merge: {
priority: -20 ,
stack: function( source , target , key , baseKey ) {
target[ key ] = source[ key ] ;
/*
if ( ! Array.isArray( target[ key ] ) ) { target[ key ] = [] ; }
if ( ! Array.isArray( source[ key ] ) ) { source[ key ] = [ source[ key ] ] ; }
target[ key ] = target[ key ].concat( source[ key ] ) ;
*/
} ,
reduce: function( target , key , baseKey ) {
var k , source = target[ key ] ;
this.reduce( source ) ;
for ( k in source.replace )
{
if ( ! target.replace[ k ] ) { target.replace[ k ] = source.replace[ k ] ; }
else { target.replace[ k ] = target.replace[ k ].concat( source.replace[ k ] ) ; }
}
delete target[ key ] ;
}
}
} ) ;

100
lib/NinjaStyle.js Normal file
View File

@ -0,0 +1,100 @@
/*
The Cedric's Swiss Knife (CSK) - Nomi no Jutsu
Copyright (c) 2015 - 2016 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
"use strict" ;
// Load modules
var kungFig = require( './KungFigExt.js' ) ;
var math = require( 'math-kit' ) ;
var string = require( 'string-kit' ) ;
function NinjaStyle() { throw new Error( '[NinjaStyle] Use NinjaStyle.create() instead.' ) ; }
module.exports = NinjaStyle ;
NinjaStyle.create = function create( options )
{
var ninjaStyle = Object.create( NinjaStyle.prototype , {
jutsuList: { value: [] , enumerable: true } ,
rng: { value: new math.random.MersenneTwister() } ,
} ) ;
ninjaStyle.rng.betterInit() ;
return ninjaStyle ;
} ;
/*
learnJutsu( jutsuName , [opacity] )
- jutsuName `string` the name of the jutsu to apply
*/
NinjaStyle.prototype.learnJutsu = function learnJutsu( jutsuName )
{
var jutsu = kungFig.load( __dirname + '/../data/jutsu/' + jutsuName + '.kfg' ) ;
this.jutsuList.push( jutsu ) ;
} ;
NinjaStyle.prototype.performJutsu = function performJutsu( input )
{
var i , iMax , j , jMax , c , output = '' ;
input = input.toLowerCase( input ) ;
// unaccent
input = string.latinize( input ) ;
for ( i = 0 , iMax = input.length ; i < iMax ; i ++ )
{
c = input[ i ] ;
for ( j = 0 , jMax = this.jutsuList.length ; j < jMax ; j ++ )
{
if ( Array.isArray( this.jutsuList[ j ].replace[ c ] ) )
{
c = this.rng.randomElement( this.jutsuList[ j ].replace[ c ] ) ;
break ;
}
}
output += c ;
if ( this.jutsuList[ 0 ].letterSpacing ) { output += this.jutsuList[ 0 ].letterSpacing ; }
}
return output ;
} ;

385
lib/Nomi.js Normal file
View File

@ -0,0 +1,385 @@
/*
The Cedric's Swiss Knife (CSK) - Nomi no Jutsu
Copyright (c) 2015 - 2016 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
"use strict" ;
// Load modules
var tree = require( 'tree-kit' ) ;
var string = require( 'string-kit' ) ;
var math = require( 'math-kit' ) ;
var doormen = require( 'doormen' ) ;
function Nomi() { throw new Error( '[nomi] Use Nomi.create() instead.' ) ; }
module.exports = Nomi ;
Nomi.cli = require( './cli.js' ) ;
/*
Nomi.create( options )
* order `number` Markov order
* sourceSplitter `string` or `RegExp` what is used to split the source into samples, if it is not an array
* sampleSplitter `string` or `RegExp` what is used to split a sample into atom chain, if it is not an array
* atomList `Array` of `string` contains atoms that have a length greater than one
* atomMin `number` minimal number of atom the generator will try to produce, if possible
* atomMax `number` maximal number of atom the generator will try to produce, if possible
* rebranching `number` if >0, when the generator cannot reach the atomMin due to a high Markov order,
it will try to generate "as if" the current generating string contains more atoms at the begining
* sampleJoint `string` what is used to join atoms when generating
* sampleAppend `string` a string append at the end of the sample when generating
*/
Nomi.create = function create( options )
{
if ( ! options || typeof options !== 'object' ) { options = {} ; }
var nomi = Object.create( Nomi.prototype , {
order: {
enumerable: true ,
value: ( typeof options.order === 'number' && options.order > 0 ) ? options.order : 2
} ,
sourceSplitter: {
enumerable: true ,
writable: true ,
value: ( typeof options.sourceSplitter === 'string' || options.sourceSplitter instanceof RegExp ) ? options.sourceSplitter : null
} ,
sampleSplitter: {
enumerable: true ,
writable: true ,
value: ( typeof options.sampleSplitter === 'string' || options.sampleSplitter instanceof RegExp ) ? options.sampleSplitter : ''
} ,
sampleJoint: {
enumerable: true ,
writable: true ,
value: typeof options.sampleJoint === 'string' ? options.sampleJoint : ''
} ,
sampleAppend: {
enumerable: true ,
writable: true ,
value: typeof options.sampleAppend === 'string' ? options.sampleAppend : ''
} ,
outputSanitizers: {
enumerable: true ,
writable: true ,
value: options.outputSanitizers || null ,
} ,
atomList: {
enumerable: true ,
writable: true ,
value: Array.isArray( options.atomList ) ? options.atomList : null
} ,
graph: {
enumerable: true ,
//writable: true ,
value: Object.create( tree.path.prototype )
} ,
atomMin: { enumerable: true , writable: true , value: options.atomMin || 0 } ,
atomMax: { enumerable: true , writable: true , value: options.atomMax || Infinity } ,
rebranching: { enumerable: true , writable: true , value: options.rebranching || 0 } ,
rng: { value: new math.random.MersenneTwister() } ,
} ) ;
nomi.rng.betterInit() ;
return nomi ;
} ;
/*
addSamples( samples , [options] )
* samples `array` or `string`
* options `object`, where:
* sourceSplitter `string` or `RegExp` what is used to split the source into samples, if it is not an array
* sampleSplitter `string` or `RegExp` what is used to split a sample into atom chain, if it is not an array
* atomList `Array` of `string` contains atoms that have a length greater than one
*/
Nomi.prototype.addSamples = function addSamples( samples , options )
{
var i , sample , startingChain , sourceSplitter , sampleSplitter , atomList , atomListPattern ;
if ( ! options || typeof options !== 'object' ) { options = {} ; }
if ( ! Array.isArray( samples ) )
{
sourceSplitter = ( typeof options.sourceSplitter === 'string' || options.sourceSplitter instanceof RegExp ) ?
options.sourceSplitter : this.sourceSplitter ;
console.log( samples , sourceSplitter ) ;
if ( ! sourceSplitter ) { throw new TypeError( '[nomi] .addSamples(): argument #0 should be an Array, or a sourceSplitter should be provided' ) ; }
samples = samples.split( sourceSplitter ) ;
}
sampleSplitter = ( typeof options.sampleSplitter === 'string' || options.sampleSplitter instanceof RegExp ) ?
options.sampleSplitter : this.sampleSplitter ;
atomList = Array.isArray( options.atomList ) ? options.atomList : this.atomList ;
if ( atomList )
{
atomListPattern = string.regexp.array2alternatives( atomList ) ;
atomListPattern = '(' + atomListPattern + ')|.' ;
}
startingChain = [] ;
for ( i = 0 ; i < this.order ; i ++ ) { startingChain[ i ] = '' ; }
for ( i = 0 ; i < samples.length ; i ++ )
{
if ( typeof samples[ i ] === 'string' )
{
sample = string2sample( samples[ i ] , sampleSplitter , atomListPattern ) ;
}
else if ( Array.isArray( samples[ i ] ) )
{
sample = samples[ i ].slice() ;
}
else
{
continue ;
}
// Always add the empty string, that is used as the string terminator
sample.push( '' ) ;
//console.log( "Sample:" , sample ) ;
this.addSampleToGraph( sample , startingChain ) ;
}
//# debugGraph : console.error( 'Graph:\n' + string.inspect( { depth: Infinity , style: 'color' } , this.graph ) ) ;
} ;
// Transform a string to a sample (array).
function string2sample( str , sampleSplitter , atomListPattern )
{
var sample , atomRegexp , match , accumulator ;
if ( ! atomListPattern ) { return str.split( sampleSplitter ) ; }
// Split the sample using both the atom's list and the sample splitter
//console.log( '>>>>>>>>>>>>>>>>>>>>>>' , samples[ i ] ) ;
accumulator = '' ;
sample = [] ;
atomRegexp = new RegExp( atomListPattern , 'g' ) ;
while ( ( match = atomRegexp.exec( str ) ) !== null )
{
if ( match[ 1 ] )
{
if ( accumulator )
{
sample = sample.concat( accumulator.split( sampleSplitter ) ) ;
accumulator = '' ;
}
sample.push( match[ 1 ] ) ;
}
else
{
accumulator += match[ 0 ] ;
}
}
if ( accumulator ) { sample = sample.concat( accumulator.split( sampleSplitter ) ) ; }
//console.log( sample ) ;
return sample ;
}
// Add one sample (array) to the graph
Nomi.prototype.addSampleToGraph = function addSampleToGraph( sample , startingChain )
{
var i , atom , leaf , chain = startingChain.slice() ;
for ( i = 0 ; i < sample.length ; i ++ )
{
atom = sample[ i ] ;
leaf = this.graph.define( chain , { sum: 0 , nexts: {} } ) ;
leaf.sum ++ ;
if ( atom in leaf.nexts ) { leaf.nexts[ atom ] ++ ; }
else { leaf.nexts[ atom ] = 1 ; }
//console.log( '#' + i , chain ) ;
chain.unshift( sample[ i ] ) ;
chain.pop() ;
}
} ;
/*
The graph is in reverse order to gain flexibility.
For example, it is possible to use a kind of dynamic Markov order (by lowering it).
"abc"-> b.a.c (the last is the leaf, the first is the last added atom).
*/
/*
generate( [options] )
* sampleJoint `string` what is used to join atoms when generating
* sampleAppend `string` a string append at the end of the sample when generating
* arrayMode `boolean` true if this function should output an array of atoms instead of a string
*/
Nomi.prototype.generate = function generate( options )
{
var i , key , length , chain , leaf , str = [] , r , atomCount = 0 , sampleJoint , sampleAppend ,
rebranch , rebranchCount = this.rebranching ;
if ( ! options || typeof options !== 'object' ) { options = {} ; }
sampleJoint = options.sampleJoint || this.sampleJoint ;
sampleAppend = options.sampleAppend || this.sampleAppend ;
chain = [] ;
for ( i = 0 ; i < this.order ; i ++ ) { chain[ i ] = '' ; }
while( true )
{
leaf = this.graph.get( chain ) ;
if ( ! leaf ) { throw new Error( '[nomi] .generate(): unexpected error, leaf not found...' ) ; }
if ( atomCount < this.atomMin && leaf.nexts[''] && ( ( length = Object.keys( leaf.nexts ).length ) > 1 || rebranchCount ) )
{
if ( rebranchCount && length <= 1 )
{
rebranch = this.rebranch( chain , atomCount ) ;
if ( ! rebranch ) { rebranchCount = 0 ; }
else { chain = rebranch ; rebranchCount -- ; }
continue ;
}
else
{
// We don't want to exit, remove the '' key
r = this.rng.random( 1 , leaf.sum - leaf.nexts[''] ) ;
for ( key in leaf.nexts )
{
if ( key === '' ) { continue ; }
r -= leaf.nexts[ key ] ;
if ( r <= 0 ) { break ; }
}
if ( r > 0 ) { throw new Error( "[nomi] .generate() - unexpected internal error: 'r' is still positive" ) ; }
}
}
else if ( atomCount >= this.atomMax && leaf.nexts[''] )
{
// We want to exit and it is possible
key = '' ;
}
else
{
// Normal case
r = this.rng.random( 1 , leaf.sum ) ;
for ( key in leaf.nexts )
{
r -= leaf.nexts[ key ] ;
if ( r <= 0 ) { break ; }
}
if ( r > 0 ) { throw new Error( "[nomi] .generate() - unexpected internal error: 'r' is still positive" ) ; }
}
str.push( key ) ;
if ( key === '' ) { break ; }
atomCount ++ ;
if ( rebranchCount && atomCount >= this.order ) { rebranchCount = 0 ; }
chain.unshift( key ) ;
chain.pop() ;
}
str.pop() ;
if ( options.arrayMode ) { return str ; }
str = str.join( sampleJoint ) + sampleAppend ;
if ( this.outputSanitizers )
{
str = doormen( { sanitize: this.outputSanitizers } , str ) ;
}
return str ;
} ;
Nomi.prototype.rebranch = function rebranch( chain , place )
{
var newChain = chain.slice() , i , shortNode , shortKeys , key ,
originalKey = chain[ place ] , indexOf ;
//# debugRebranch : console.error( '>>> Trying to rebranch from' , chain.join( ' - ' ) , ' original key:' , originalKey ) ;
//# debugRebranch : console.error( 'Leaf:' , this.graph.get( chain ) ) ;
shortNode = this.graph.get( newChain.slice( 0 , place ) ) ;
shortKeys = Object.keys( shortNode ) ;
//# debugRebranch : console.error( 'shortNode:' , shortNode ) ;
if ( shortKeys.length === 1 ) { return false ; }
indexOf = shortKeys.indexOf( originalKey ) ;
shortKeys.splice( indexOf , 1 ) ;
key = shortKeys[ this.rng.random( shortKeys.length ) ] ;
newChain[ place ] = key ;
for ( i = place + 1 ; i < this.order ; i ++ )
{
shortNode = shortNode[ key ] ;
shortKeys = Object.keys( shortNode ) ;
key = shortKeys[ this.rng.random( shortKeys.length ) ] ;
newChain[ i ] = key ;
}
//# debugRebranch : console.error( 'Rebranching to' , newChain.join( ' - ' ) ) ;
return newChain ;
} ;

84
lib/cli.js Normal file
View File

@ -0,0 +1,84 @@
/*
The Cedric's Swiss Knife (CSK) - Nomi no Jutsu
Copyright (c) 2015 - 2016 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Load modules
var Nomi = require( '../lib/Nomi.js' ) ;
var minimist = require( 'minimist' ) ;
var kungFig = require( 'kung-fig' ) ;
var tree = require( 'tree-kit' ) ;
function cli()
{
var nomi , configPath , config , count , port ,
args = minimist( process.argv.slice( 2 ) ) ;
if ( ! args._.length )
{
console.log( 'Usage is ./nomi <config-file-path> [count] [--order <value>] [--port <port-number>]' ) ;
process.exit() ;
}
configPath = args._[ 0 ] ;
count = args._[ 1 ] || 1 ;
delete args._ ;
if ( args.port )
{
port = args.port ;
delete args.port ;
}
config = kungFig.load( configPath ) ;
tree.extend( { deep: true } , config , args ) ;
//console.log( config ) ;
nomi = Nomi.create( config ) ;
nomi.addSamples( config.samples ) ;
if ( port )
{
var httpModule = require( './httpModule.js' ) ;
httpModule.createServer( port , nomi ) ;
}
else
{
while ( count > 0 )
{
console.log( nomi.generate() ) ;
count -- ;
}
}
}
module.exports = cli ;

1
log/touch Normal file
View File

@ -0,0 +1 @@

39
package.json Normal file
View File

@ -0,0 +1,39 @@
{
"name": "str-gen",
"version": "0.0.0",
"description": "String generator and filter",
"main": "lib/strgen.js",
"directories": {
"test": "test"
},
"bin": {
"nomi": "./bin/nomi"
},
"dependencies": {
"kung-fig": "^0.38.6",
"math-kit": "^0.11.12",
"minimist": "^1.2.0",
"string-kit": "^0.6.1",
"tree-kit": "^0.5.26"
},
"devDependencies": {
"expect.js": "^0.3.1",
"jshint": "^2.9.2",
"mocha": "^2.4.5"
},
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "https://github.com/cronvel/nomi.git"
},
"keywords": [
"nomi"
],
"author": "Cédric Ronvel",
"license": "MIT",
"bugs": {
"url": "https://github.com/cronvel/nomi/issues"
}
}

52
sample/IT.kfg Normal file
View File

@ -0,0 +1,52 @@
order: 2
atomMin: 5
atomMax: 12
#rebranching: 3
samples:
- microsoft
- google
- apple
- twitter
- facebook
- sharepoint
- dropbox
- pivotal
- redmine
- mozilla
- firefox
- chrome
- chromium
- windows
- linux
- github
- trello
- javascript
- thunderbird
- wikipedia
- intel
- youtube
- reddit
- 4chan
- deviantart
- nvidia
- netflix
- oracle
- linkedin
- ebay
- blizzard
- wmware
- capgemini
- infosys
- cognizant
- accenture
- symantec
- intuit
- samsung
- foxconn
- amazon
- panasonic
- toshiba
- yahoo
- compuware

495
sample/elf.kfg Normal file
View File

@ -0,0 +1,495 @@
order: 2
atomMin: 4
atomMax: 10
samples:
- Amadrieriand
- Amáril
- Amelad
- Ameldor
- Amendel
- Ameng
- Amilmaldur
- Amilmalith
- Amilmandir
- Amind
- Amiol
- Amiorion
- Amithrarion
- Amóldor
- Amorfimir
- Amorfir
- Amowyn
- Amulas
- Amundil
- Anán
- Anebrin
- Anebrir
- Anémbor
- Anénduil
- Anerion
- Anilad
- Anil-Gawyn
- Anilmambor
- Anilmariand
- Anior
- Anithranduil
- Anol
- Anon
- Anorfing
- Anundil
- Belán
- Belandil
- Belarandel
- Belel
- Belén
- Belil-Gandil
- Belilmand
- Belilmang
- Beliondil
- Beliril
- Belithraldor
- Belithrawyn
- Belólad
- Belómir
- Belondel
- Belyrion
- Cadriembor
- Cadrieriand
- Cálad
- Caladrielas
- Calándel
- Caldur
- Cáldur
- Calebrindel
- Calebrindir
- Calénduil
- Calil-Gandir
- Calil-Gawyn
- Calioriand
- Caliril
- Calónduil
- Caloril
- Cándir
- Canduil
- Caraldur
- Carang
- Célad
- Celadrieriand
- Celang
- Celaral
- Celarandil
- Celáriand
- Celebririon
- Celelas
- Celendel
- Celér
- Celilmalas
- Celiondir
- Celior
- Celiorion
- Celong
- Celór
- Celóril
- Celorion
- Celundir
- Celuwyn
- Celyndel
- Cénduil
- Cindil
- Ciong
- Cithralad
- Cithraldur
- Cithrand
- Cithrandel
- Cithraril
- Col
- Corfil
- Corfildur
- Cówyn
- Cun
- Cundir
- Cylas
- Delán
- Delánd
- Delandel
- Delaraldur
- Deláril
- Delawyn
- Deléng
- Delilmaldor
- Deliol
- Delithrar
- Deliwyn
- Delóldor
- Delorfilad
- Delorfilith
- Delorion
- Delundil
- Eäradriendel
- Eäradrier
- Eäránduil
- Eäraralad
- Eärebrindel
- Eäréldor
- Eäreng
- Eärérion
- Eärithrandil
- Eäromir
- Eärorfiriand
- Eäryldur
- Eäryriand
- Eladrieng
- Elálith
- Elánd
- Elándil
- Elebrildor
- Elebrindel
- Elebriril
- Elélas
- Elémbor
- Elemir
- Elen
- Elil-Garil
- Elilmaldur
- Eliomir
- Eliondil
- Elolas
- Elólas
- Elor
- Elorfilad
- Elradrien
- Elralith
- Elran
- Elreldur
- Elrilmand
- Elrioldor
- Elriolith
- Elrithralith
- Elrithranduil
- Elrorfir
- Elval
- Elvandir
- Elvaramir
- Elváwyn
- Elvebrind
- Elvebrindel
- Elvélith
- Elvémir
- Elverion
- Elvil-Garion
- Elvilmaldur
- Elvilmaril
- Elvioldur
- Elvombor
- Elvónduil
- Elvorfimir
- Elvorfiriand
- Elvorfiril
- Elvóriand
- Elvund
- Elyldor
- Elyrion
- Eowambor
- Eowanduil
- Eowar
- Eowaraldor
- Eowaran
- Eowarar
- Eowariand
- Eowarion
- Eowebrind
- Eowémir
- Eowil-Garion
- Eowimbor
- Eowiomir
- Eowithrawyn
- Eowóldur
- Eoworfildor
- Eowówyn
- Eowylas
- Fadriendel
- Fandel
- Farandir
- Fáwyn
- Fendel
- Fer
- Filman
- Fioril
- Fithraril
- Forfilas
- Fyrion
- Gadriendil
- Gadrieng
- Galadrieldor
- Galálad
- Galálas
- Galalith
- Galar
- Galelas
- Galeldur
- Galelith
- Galémbor
- Galithrariand
- Galoldur
- Galuldur
- Galur
- Galurion
- Gambor
- Gán
- Ganduil
- Garaldor
- Gararil
- Gelad
- Géril
- Gil-Gandel
- Gil-Gang
- Giombor
- Githral
- Githralad
- Gladriendil
- Glal
- Glámbor
- Glandil
- Glarang
- Glararil
- Glilmal
- Glimir
- Glior
- Glólas
- Gloldor
- Glómir
- Glon
- Glul
- Golad
- Gor
- Gumbor
- Gyl
- Gymbor
- Gyn
- Harariand
- Háriand
- Hebril
- Hemir
- Hénduil
- Hilas
- Hil-Garion
- Hilmariand
- Hiong
- Hirion
- Hithrandel
- Horfilad
- Horfindel
- Hundel
- Hymir
- Hyrion
- Hywyn
- Isadrieng
- Isándir
- Isarandel
- Isarar
- Iselas
- Isér
- Isilmandel
- Isirion
- Isithral
- Isól
- Isóndel
- Isóng
- Isorfilad
- Isorfindir
- Isuwyn
- Isyndel
- Legal
- Legaran
- Legémir
- Legéril
- Legilad
- Legil-Gal
- Legiondel
- Legithralith
- Legorfindil
- Legorfirion
- Legówyn
- Legyl
- Legyn
- Linduilas
- Lómadrieril
- Lómarand
- Lómariand
- Lómebrilad
- Lómebrind
- Lómémbor
- Lómilmaril
- Lómiriand
- Lómorfindil
- Lómowyn
- Madrieril
- Maldur
- Mánduil
- Maraldur
- Mebrin
- Méng
- Mérion
- Miolith
- Miomir
- Mithrand
- Mondir
- Móndir
- Morfilas
- Morfin
- Morfiriand
- Mylith
- Nadrieldor
- Nalith
- Nán
- Nél
- Nil-Galas
- Nil-Galith
- Nil-Gar
- Nilmar
- Nóndel
- Norfildor
- Norfilith
- Norfindil
- Norfindir
- Numbor
- Nyldur
- Padrieriand
- Padrieril
- Pamir
- Paraldor
- Parariand
- Pilmalad
- Pindir
- Pór
- Porfildur
- Pumbor
- Pyldur
- Rebrir
- Réndir
- Rilmandil
- Rithrandil
- Ról
- Róldor
- Roldur
- Róldur
- Rorfilad
- Rorfindil
- Rówyn
- Ryn
- Sadrielas
- Sebrin
- Sebriril
- Sénd
- Sil-Gal
- Sólad
- Sorfind
- Sóriand
- Tadriendir
- Taral
- Taraldur
- Táriand
- Tendel
- Téwyn
- Thradrieriand
- Thrambor
- Thraral
- Threbring
- Thrélad
- Thréldur
- Thril-Gamir
- Thril-Gandir
- Thril-Gar
- Thrilmandel
- Thrimir
- Thrion
- Thrithran
- Throlas
- Thrón
- Thróng
- Thrund
- Thryriand
- Til-Gan
- Tilmalad
- Tilmalas
- Tinandir
- Tinarambor
- Tinarariand
- Tinén
- Tinil-Ganduil
- Tinilmand
- Tinilmawyn
- Tinimir
- Tinindil
- Tinithrar
- Tinoldor
- Tinond
- Tinorfind
- Tinorfiriand
- Tinóriand
- Tinowyn
- Tinun
- Tinyl
- Tion
- Tolas
- Torfildur
- Tówyn
- Tylad
- Unadrieldor
- Unadrier
- Unál
- Unalas
- Unálas
- Unaraldur
- Unaril
- Unárion
- Unebrin
- Unebrind
- Uneldor
- Unil
- Unil-Gan
- Uniolith
- Unioril
- Unólith
- Unombor
- Unóndel
- Unondir
- Unorfildor
- Unorfiril
- Unorfiwyn
- Unulad
- Uradrielas
- Uradrierion
- Urálas
- Urálith
- Urambor
- Urér
- Uril-Gambor
- Urilmalith
- Uróldor
- Urorfildor
- Urul
- Urymir
- Válad
- Ván
- Vándel
- Vandir
- Varalas
- Vararion
- Vebril
- Vebrilas
- Vebrinduil
- Vel
- Vilith
- Vol
- Vólas
- Vóldur
- Vondel
- Vorfin
- Vorfindil
- Vulas
- Vuldur
- Vunduil
- Vylas
- Vyldor

142
sample/french-town.kfg Normal file
View File

@ -0,0 +1,142 @@
order: 2
atomMin: 2
atomMax: 10
atomList:
- Chateau
- Saint
- les
- le
- la
- de
- du
- en
- sur
- eau
- ou
samples:
- Aix-les-Bains
- Aix-en-Provence
- Ambazac
- Ambroise
- Andorre
- Anvers
- Arcachon
- Armagnac
- Arnac-la-Poste
- Artenay
- Asnières-Gennevilliers
- Aubagne
- Aubenas
- Aubusson
- Avignon
- Bayonne
- Bazillac
- Bel-Air
- Belle-Ville
- Bergerac
- Biscarosse
- Brest
- Brocéliande
- Bordeaux
- Boulogne
- Bourg-la-Reine
- Bourges
- Calais
- Carcassonne
- Carnac
- Carpentras
- Castel
- Cavaillon
- Chamberry
- Champagne
- Charleroi
- Chartres
- Chateauneuf
- Chateauroux
- Chatelet
- Chatenay
- Chatillon
- Choisy-le-Roi
- Clermont
- Clichy
- Cognac
- Cressensac
- Dax
- D'Artignac
- Dior
- Dunkerque
- Evry
- Fleury-Mérogis
- Garonne
- Gévaudan
- Issoudun
- Issy
- Ivry
- La Muette
- La Rochelle
- La Roche-sur-Yon
- La Trinité-sur-Mer
- Le Blanc
- Le Bourg
- Le Havre
- Le Pontet
- Les Courtilles
- Lièges
- Lorient
- Marne-la-Vallée
- Marseille
- Mérignac
- Mesnil
- Metz
- Mimizan
- Mirabeau
- Montélimar
- Montrouge
- Montmartre
- Mont-Blanc
- Mont-Dore
- Mont-Ferrand
- Morlaix
- Narbonne
- Nevers
- Noirmoutier
- Notre-Dame
- Les Sables-d'Olonne
- Oléron
- Orléans
- Périgueux
- Plaisance
- Ploucastel
- Poitiers
- Quiberon
- Quimper
- Rochefort
- Romorentin
- Roubaix
- Royan
- Salbris
- Saint-Brieuc
- Saint-George
- Saint-Jean-de-Luz
- Saint-Louis
- Saint-Malo
- Saint-Maur
- Saint-Palais
- Saint-Sulpice
- Sainte-Marie-de-la-Mer
- Sauvigny
- Sète
- Sèvre
- Tarascon
- Tourcoing
- Varenne
- Valençay
- Valras
- Versailles
- Vichy
- Villeneuve
- Villiers-sur-Marne
- Vierzon

238
sample/lizard.kfg Normal file
View File

@ -0,0 +1,238 @@
order: 2
atomMin: 3
atomMax: 12
samples:
- Amprixta
- Anexir
- Anitraz
- Arix
- Axiz
- BzzKza
- Chamil
- Cleezi
- Clezz
- Fazzis
- Fizztrax
- Flixta
- Flizzil
- Frikes
- Frizzle
- Hasz
- Heffez
- Hertrazzir
- Hesz
- Hezzir
- Hezzis
- Hix
- Inexis
- Irix
- Jezzix
- Jizz
- Kaliez
- Kepzs
- Kernix
- Kersezz
- Kertrasz
- Kerx
- Kerxenix
- Kezz
- Klexaz
- Klezyx
- Krarax
- Krenarex
- Krex
- Krinex
- Krisess
- Laizix
- Lazki
- Lixeez
- Merax
- Mexiss
- Moxanzz
- Naxisz
- Nix
- Pekzs
- Plaxis
- Plesix
- Presch
- Sailik
- Salanix
- Salik
- Sandix
- Saprazz
- Satras
- Skalix
- Skandix
- Skazix
- Skeely
- Skeezix
- Sklizle
- Skrez
- Slizilx
- Sprizz
- Ssexur
- Ssizer
- Ssorix
- Sszasz
- Sterizz
- Talerez
- Tarex
- Tarnix
- Tezzaz
- Tirasch
- Tirax
- Tirix
- Trezz
- Venezz
- Vriss
- Waks
- Xaffrasz
- Xartrez
- Xasz
- Xaztex
- Xerxix
- Xirasz
- Xirr
- Xirtras
- Xirtrez
- Xirz
- Zandler
- Zedrix
- Zilrix
- Zizzasz
- Zslap
- Zzalkz
- Zzupde
- Abraxas
- Aleiss
- Amail
- Axmail
- Blanal
- Bleii
- Blo
- Bress
- Briss
- Gaxmol
- Griam
- Griss
- Grissileii
- Hailoss
- Hainoss
- Harxos
- Huzel
- Inaloss
- Ineii
- Issal
- Klezel
- Kras
- Krezkps
- Kzap
- Lamaiss
- Lameii
- Lexpek
- Liness
- Lobor
- Maissol
- Malinos
- Milbor
- Mileii
- Nildloss
- Oxpeii
- Poniaz
- Psell
- Pson
- Pzakp
- Reii
- Sassal
- Saxil
- Saxrireii
- Sekol
- Silas
- Skell
- Skepz
- Slell
- Snol
- Soill
- Sorkol
- Srell
- Trixoz
- Vilail
- Vissal
- Vlanis
- Xabrak
- Xamalel
- Xinas
- Xnamos
- Xopkon
- Zalsp
- Zlek
- Zpsek
- Zsekp
- Aliasse
- Amailis
- Axmailia
- Blai
- Blanalai
- Bli
- Bliana
- Brassas
- Brissal
- Gaxmail
- Griama
- Grissa
- Grissilai
- Haila
- Haina
- Harxias
- Huzi
- Inai
- Inalai
- Issalai
- Klez
- Kras
- Krezkps
- Kzap
- Lamai
- Lamaissa
- Lexpek
- Liabra
- Lilin
- Linassa
- Maissa
- Malina
- Mila
- Milbra
- Nildlasi
- Oxpel
- Poniazal
- Psal
- Psen
- Pzakp
- Riaa
- Sall
- Sassalia
- Saxiala
- Saxririaa
- Sek
- Skal
- Skepz
- Sla
- Snelia
- Srak
- Sral
- Szak
- Trixzed
- Vilaila
- Vissalai
- Vlanissa
- Xabrak
- Xamalia
- Xina
- Xinasia
- Xnamas
- Xopkne
- Zalsp
- Zlek
- Zpsek
- Zsekp

12
sample/lorem-ipsum.kfg Normal file
View File

@ -0,0 +1,12 @@
order: 2
atomMin: 7
atomMax: 20
#rebranching: 3
sourceSplitter: <regex> /\. */
#sampleSplitter: / +|(?=,)/
sampleSplitter: <regex> /(?=,| )/
sampleAppend: .
samples: @@lorem-ipsum.txt

1
sample/lorem-ipsum.txt Normal file
View File

@ -0,0 +1 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac commodo odio. Mauris elit sem, ornare vel porttitor non, volutpat eget lacus. Nam interdum gravida tortor vitae pulvinar. Fusce accumsan eleifend tellus, id viverra erat eleifend vitae. Morbi auctor mi vel nisi semper consequat. Nunc pretium elit vel dolor aliquam placerat. Etiam ac sem vitae nisl sodales varius vel id lorem. Maecenas et cursus nulla, aliquet volutpat nulla. Cras ultricies aliquet euismod. Nullam mollis justo vitae metus pulvinar accumsan. Etiam sodales orci vel odio feugiat lacinia. Etiam est massa, euismod a eros ac, sodales imperdiet libero. Proin vel dignissim est, eu hendrerit elit. Donec eget ipsum id velit aliquam volutpat. Phasellus vitae lorem non lorem pulvinar imperdiet eget id massa. Donec massa arcu, ultrices nec scelerisque vehicula, dapibus eget dui. Pellentesque tristique lorem sed varius tristique. Nam volutpat interdum massa, sit amet lobortis ex. Sed sed egestas diam, eget tristique sem. Nullam et nisi quis urna interdum convallis. Cras dictum purus id elit aliquam mattis. Nulla sed porta urna, vitae fringilla tortor. Proin et odio tristique, sagittis tellus id, vestibulum enim. Aliquam erat volutpat. Quisque varius eros ac sollicitudin sodales. Mauris porttitor nisl id quam dignissim tempor. Nulla a sollicitudin orci. Nullam eu eleifend orci. Duis eleifend felis vel tortor finibus, ut bibendum sapien rhoncus. Morbi ante nisi, eleifend a risus at, dapibus tincidunt magna. Vestibulum sit amet neque ut urna scelerisque ornare. Donec scelerisque fringilla sollicitudin. Morbi a mollis justo. Cras gravida tristique gravida. Nam felis sapien, imperdiet id porta a, auctor sed metus. Donec eu lorem nisl. Sed sit amet semper nibh. Sed sollicitudin eleifend malesuada. Proin vestibulum odio at neque consequat, nec consequat augue ornare. Phasellus consectetur et eros sed fringilla. Sed consectetur ultricies tortor, sit amet blandit mi commodo vitae. Mauris finibus sem vitae mauris luctus, non facilisis tortor aliquam. Nullam semper ipsum non mollis venenatis. Nunc sem dui, tincidunt eu sem vulputate, accumsan condimentum neque. Ut fringilla risus vitae diam commodo, id tincidunt odio tincidunt. Curabitur in blandit risus, eu malesuada nisi. Donec sed nisi metus. Suspendisse dolor leo, vulputate egestas aliquam vel, dictum et dolor. Nullam gravida orci risus, a auctor elit volutpat id. Aenean ultricies mauris sit amet laoreet maximus. In imperdiet fermentum imperdiet. Sed quam justo, finibus quis tempus posuere, feugiat id turpis. Pellentesque sit amet erat at diam condimentum ullamcorper a eget ante. Sed volutpat velit nec sollicitudin ornare. Pellentesque elementum quis odio non auctor. Etiam mollis urna in ligula pharetra, vel pellentesque metus consectetur. Aenean condimentum enim nec arcu molestie imperdiet. Sed egestas, orci nec blandit iaculis, leo elit varius tortor, eget rutrum libero dolor at quam. Nulla vel lacinia massa. Proin placerat ipsum non fringilla interdum. Fusce eu eros turpis. Mauris iaculis massa ac metus suscipit porttitor. Suspendisse maximus est sed lacus vulputate luctus. Praesent eleifend ac arcu eget scelerisque. Integer rutrum erat consectetur ornare ultrices. Donec consequat diam id nulla volutpat efficitur. Donec aliquet ex at quam ultrices gravida. Phasellus tempus, odio sit amet varius eleifend, tellus ex ultrices magna, eget ornare nisi nisl id ex. Vestibulum non justo varius, facilisis libero vitae, blandit arcu.

89
sample/markov.cli.php Executable file

File diff suppressed because one or more lines are too long

72
sample/tests.js Executable file
View File

@ -0,0 +1,72 @@
#!/usr/bin/env node
/*
The Cedric's Swiss Knife (CSK) - Nomi no Jutsu
Copyright (c) 2015 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Load modules
var spp = require( 'smart-preprocessor' ) ;
var args = require( 'minimist' )( process.argv.slice( 2 ) ) ;
if ( args._.length < 1 )
{
console.log( 'Usage is ./tests.js <markov order> [count]' ) ;
process.exit() ;
}
var order = parseInt( args._[ 0 ] , 10 ) ;
var count = parseInt( args._[ 1 ] , 10 ) || 1 ;
delete args._ ;
var Nomi = spp.require( __dirname + '/../lib/Nomi.js' , args ) ;
var names =
"ab,ac,bd" ;
// "abcde,cdx,cdz,acd" ;
var nomi = Nomi.create( {
order: order ,
sourceSplitter: ','
} ) ;
nomi.addSamples( names ) ;
while ( count > 0 )
{
console.log( nomi.generate() ) ;
count -- ;
}

409
sample/webapp.kfg Normal file
View File

@ -0,0 +1,409 @@
order: 3
atomMin: 5
atomMax: 12
rebranching: 3
samples:
- team
- synchronisation
- corporate
- product
- project
- management
- community
- apps
- application
- web
- internet
- share
- social
- together
- link
- network
- module
- mobile
- visibility
- open
- work
- member
- efficient
- synergize
- easy
- action
- items
- applications
- architectures
- bandwidth
- channels
- communities
- content
- convergence
- deliverables
- business
- commerce
- markets
- services
- tailers
- experiences
- eyeballs
- functionalities
- infomediaries
- infrastructures
- initiatives
- interfaces
- markets
- methodologies
- metrics
- mindshare
- models
- networks
- niches
- paradigms
- partnerships
- platforms
- portals
- relationships
- schemas
- solutions
- supply
- chains
- synergies
- systems
- technologies
- users
- vortals
- webservices
- web
- readiness
- back
- end
- best
- of
- breed
- bleeding
- edge
- bricks
- and
- clicks
- clicks
- and
- mortar
- collaborative
- compelling
- cross
- media
- cross
- platform
- customized
- cutting
- edge
- distributed
- dot
- com
- dynamic
- business
- efficient
- end
- to
- end
- enterprise
- extensible
- frictionless
- front
- end
- global
- granular
- holistic
- impactful
- innovative
- integrated
- interactive
- intuitive
- killer
- leading
- edge
- magnetic
- mission
- critical
- multiplatform
- next
- generation
- one
- to
- one
- open
- source
- out
- of
- the
- box
- plug
- and
- play
- proactive
- real
- time
- revolutionary
- rich
- robust
- scalable
- seamless
- sexy
- sticky
- strategic
- synergistic
- transparent
- turn
- key
- ubiquitous
- user
- centric
- value
- added
- vertical
- viral
- virtual
- visionary
- web
- enabled
- wireless
- world
- class
- aggregate
- architect
- benchmark
- brand
- cultivate
- deliver
- deploy
- disintermediate
- drive
- enable
- embrace
- empower
- enable
- engage
- engineer
- enhance
- envisioneer
- evolve
- expedite
- exploit
- extend
- facilitate
- generate
- grow
- harness
- implement
- incentivize
- incubate
- innovate
- integrate
- iterate
- leverage
- matrix
- maximize
- mesh
- monetize
- morph
- optimize
- orchestrate
- productize
- recontextualize
- redefine
- reintermediate
- reinvent
- repurpose
- revolutionize
- scale
- seize
- strategize
- streamline
- syndicate
- synergize
- synthesize
- target
- transform
- transition
- unleash
- utilize
- visualize
- whiteboard
- blast
- kick
- kickass
- roundhousekick
- sidekick
- uppercut
- punch
- punchline
- dragon
- dragonpunch
- cutkiller
- awesome
- slash
- dash
- clash
- great
- greatly
- might
- mighty
- allmighty
- hot
- fire
- five
- stone
- flintstone
- gold
- silver
- moon
- sun
- black
- white
- red
- blue
- indigo
- green
- yellow
- rage
- fierce
- strong
- bold
- fast
- speed
- blazing
- blazingly
- light
- lightning
- storm
- stormbringer
- lightbringer
- shot
- gun
- shotgun
- blow
- blowgun
- whisper
- cast
- dreamcast
- spellcast
- edge
- blade
- sword
- wild
- west
- fireflies
- gunblade
- bullet
- story
- ring
- rock
- knight
- show
- showdown
- tower
- team
- syn
- synchro
- synchronisation
- product
- project
- manage
- management
- community
- apps
- app
- application
- web
- internet
- net
- network
- share
- social
- together
- gather
- link
- mobile
- visibility
- open
- work
- synergy
- synergize
- easy
- smart
- cloud
- communicate
- spread
- word
- world
- startup
- build
- great
- software
- service
- online
- do
- todo
- list
- todolist
- task
- forum
- blog
- weblog
- board
- activities
- comment
- public
- organize
- event
- impact
- homepage
- wiki
- wide
- netlink
- awesome
- energy
- light
- lightning
- node
- nodejs
- notepad
- enterprise
- vanguard
- star
- lean
- lead
- leader
- leadership
# Existing names
- basecamp
- aceproject
- anyplan
- asana
- assembla
- binfire
- collabtive
- sharepoint
- droptask
- dynaroad
- fasttrack
- fusionforge
- hyperoffice
- instep
- launchpad
- liquidplanner
- omniplan
- groupware
- pivotaltracker
- planbox
- planisware
- redmine
- teamcenter
- teamlab
- trac
- trello
- ubidesk
- workplan
- zoho

89
sample/wesnoth-names.js Executable file

File diff suppressed because one or more lines are too long

64
sample/wose.kfg Normal file
View File

@ -0,0 +1,64 @@
order: 3
atomMin: 8
atomMax: 25
samples:
- Bludebalmen
- Boladrumbadrum
- Bolwuldelman
- Bombempomgontor
- Bomtanbomkenton
- Bomtanbomtonum
- Bregalad
- Bremdebubde
- Brenbasnudnem
- Brendumadoak
- Brommantendronnor
- Brumbendublun
- Brumennarunom
- Brummdlebroak
- Bumbadadabum
- Buomdumdenlol
- Carnimirië
- Dabumdabumtam
- Dammantongonnur
- Danmonlulbam
- Debundbemun
- Delmduelmdelom
- Diblembumnde
- Dolmannumbil
- Drongnoblemdu
- Dulmandarook
- Dulwulmendom
- Dumdumdumatum
- Elmaroomadrum
- Grelmadrumbumadum
- Gulladroamadoak
- Gumabeladrelm
- Laffalialomdium
- Landunwonbam
- Lassemista
- Lefnublemdde
- Libleddnumm
- Lolmandindel
- Monlamwimdan
- Muldondindal
- Mundionalafla
- Mundumblemdum
- Munnamdulbon
- Nanmildaldum
- Nunmaldildun
- Orofarnië
- Pambedrumne
- Pomtamkomtrobum
- Rithramcamhan
- Tantondernintan
- Temtundembenn
- Temtunnongetem
- Tondenkontenkon
- Troombadoom
- Tumtentantarun
- Tumtonnongatum
- Tumtumgamtomtom
- Wonrunmaldin
- Wudadoonopl

71
test/NinjaStyle-test.js Normal file
View File

@ -0,0 +1,71 @@
/*
The Cedric's Swiss Knife (CSK) - Nomi no Jutsu
Copyright (c) 2015 - 2016 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* jshint unused:false */
/* global describe, it, before, after */
var string = require( 'string-kit' ) ;
var expect = require( 'expect.js' ) ;
//var Nomi = require( '../lib/Nomi.js' ) ;
var NinjaStyle = require( '../lib/NinjaStyle.js' ) ;
function deb( v )
{
console.log( string.inspect( { depth: Infinity , style: 'color' } , v ) ) ;
}
describe( "Ninja Style" , function() {
it( "simple test" , function() {
var ninjaStyle = NinjaStyle.create() ;
//ninjaStyle.learnJutsu( 'genin' ) ;
//ninjaStyle.learnJutsu( 'taijutsu' ) ;
//ninjaStyle.learnJutsu( 'iaido-no-jutsu' ) ;
//ninjaStyle.learnJutsu( 'monkey-style' ) ;
//ninjaStyle.learnJutsu( 'suiton-no-jutsu' ) ;
//ninjaStyle.learnJutsu( 'genjutsu' ) ;
//ninjaStyle.learnJutsu( 'kinjutsu' ) ;
//ninjaStyle.learnJutsu( 'kendo' ) ;
//ninjaStyle.learnJutsu( 'drunken-master' ) ;
ninjaStyle.learnJutsu( 'kuchiyose-no-jutsu' ) ;
//console.log( ninjaStyle.jutsuList ) ;
console.log( ninjaStyle.performJutsu( 'Hellow world, this is the ancient art of ninja!' ) ) ;
console.log( ninjaStyle.performJutsu( 'éàùïÖ' ) ) ;
} ) ;
} ) ;

203
test/Nomi-test.js Normal file
View File

@ -0,0 +1,203 @@
/*
The Cedric's Swiss Knife (CSK) - Nomi no Jutsu
Copyright (c) 2015 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* jshint unused:false */
/* global describe, it, before, after */
var string = require( 'string-kit' ) ;
var expect = require( 'expect.js' ) ;
var Nomi = require( '../lib/Nomi.js' ) ;
function deb( v )
{
console.log( string.inspect( { depth: Infinity , style: 'color' } , v ) ) ;
}
describe( "Graph creation" , function() {
it( "Markov order 1" , function() {
var nomi = Nomi.create( { order: 1 } ) ;
nomi.addSamples( [
'abc' , 'aei' , 'xyz'
] ) ;
//console.log( nomi.graph ) ;
expect( nomi.graph ).to.eql( {
'': { sum: 3, nexts: { a: 2, x: 1 } },
a: { sum: 2, nexts: { b: 1, e: 1 } },
b: { sum: 1, nexts: { c: 1 } },
c: { sum: 1, nexts: { '': 1 } },
e: { sum: 1, nexts: { i: 1 } },
i: { sum: 1, nexts: { '': 1 } },
x: { sum: 1, nexts: { y: 1 } },
y: { sum: 1, nexts: { z: 1 } },
z: { sum: 1, nexts: { '': 1 } }
} ) ;
} ) ;
it( "Markov order 2" , function() {
var nomi = Nomi.create( { order: 2 } ) ;
nomi.addSamples( [
'abc' , 'aei' , 'xyz'
] ) ;
//console.log( string.inspect( { depth: 4 , style: 'color' } , nomi.graph ) ) ;
var expected = {
'': {
'': { sum: 3, nexts: { a: 2, x: 1 } }
},
a: {
'': { sum: 2, nexts: { b: 1, e: 1 } }
},
b: {
a: { sum: 1, nexts: { c: 1 } }
},
c: {
b: { sum: 1, nexts: { '': 1 } }
},
e: {
a: { sum: 1, nexts: { i: 1 } }
},
i: {
e: { sum: 1, nexts: { '': 1 } }
},
x: {
'': { sum: 1, nexts: { y: 1 } }
},
y: {
x: { sum: 1, nexts: { z: 1 } }
},
z: {
y: { sum: 1, nexts: { '': 1 } }
}
} ;
expect( nomi.graph ).to.eql( expected ) ;
} ) ;
it( "Atoms" , function() {
var nomi , expected ;
nomi = Nomi.create( { order: 1 , atomList: [ 'th' ] } ) ;
nomi.addSamples( [
'the' , 'that' , 'both' , 'what' , 'whether'
] ) ;
//console.log( nomi.graph ) ;
expected = {
'': { sum: 5, nexts: { th: 2, b: 1, w: 2 } },
th: { sum: 4, nexts: { e: 2, a: 1, '': 1 } },
e: { sum: 3, nexts: { '': 1, th: 1, r: 1 } },
a: { sum: 2, nexts: { t: 2 } },
t: { sum: 2, nexts: { '': 2 } },
b: { sum: 1, nexts: { o: 1 } },
o: { sum: 1, nexts: { th: 1 } },
w: { sum: 2, nexts: { h: 2 } },
h: { sum: 2, nexts: { a: 1, e: 1 } },
r: { sum: 1, nexts: { '': 1 } }
} ;
expect( nomi.graph ).to.eql( expected ) ;
nomi = Nomi.create( { order: 1 , atomList: [ 'th' , 'wh' ] } ) ;
nomi.addSamples( [
'the' , 'that' , 'both' , 'what' , 'whether'
] ) ;
//console.log( nomi.graph ) ;
expected = {
'': { sum: 5, nexts: { th: 2, b: 1, wh: 2 } },
th: { sum: 4, nexts: { e: 2, a: 1, '': 1 } },
e: { sum: 3, nexts: { '': 1, th: 1, r: 1 } },
a: { sum: 2, nexts: { t: 2 } },
t: { sum: 2, nexts: { '': 2 } },
b: { sum: 1, nexts: { o: 1 } },
o: { sum: 1, nexts: { th: 1 } },
wh: { sum: 2, nexts: { a: 1, e: 1 } },
r: { sum: 1, nexts: { '': 1 } }
} ;
expect( nomi.graph ).to.eql( expected ) ;
} ) ;
} ) ;
describe( ".generate()" , function() {
it( "Markov order 2" , function() {
var i , max = 1000 , name , names = {} ;
var nomi = Nomi.create( { order: 2 } ) ;
nomi.addSamples( [
'sally' , 'sells' , 'seashells' , 'seashore'
] ) ;
var expected = [
'sally' , 'sells' , 'seashells' , 'seashore' ,
'salls' , 'selly' , 'seashelly'
] ;
for ( i = 0 ; i < max ; i ++ )
{
name = nomi.generate() ;
// expect.js is really slow, so we call it only on when it fails
if ( expected.indexOf( name ) < 0 ) { expect().fail() ; }
if ( names[ name ] ) { names[ name ] ++ ; }
else { names[ name ] = 1 ; }
}
//console.log( names ) ;
//console.log( 'diff: ' , names.seashore - ( names.seashells + names.seashelly ) ) ;
} ) ;
} ) ;