Skip to content

Commit 93fc05e

Browse files
committed
Add library code (copied from the demo/website repo https://github.com/Tw1ddle/MarkovNameGenerator)
0 parents  commit 93fc05e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+12372
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.zip
2+
*.db
3+
**/.DS_Store
4+
**/Thumbs.db
5+
**/ehthumbs.db
6+
**/*.lnk
7+
**/.Trash-*
8+
**/.directory
9+
*.hash
10+
*.map
11+
lib/dox/themes/samcodes/resources/samcodes-nav.min.css
12+
lib/dox/themes/samcodes/resources/styles.min.css

CHANGELOG.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## 1.0.0
2+
* Initial release.
3+
4+
## 1.0.1
5+
* Add a missed include.xml.
6+
7+
## 1.0.2
8+
* Fix directory structure so it actually works with haxelib.
9+
10+
## 1.0.3
11+
* Remove some unused methods and other minor code cleanup.
12+
13+
## 1.0.4
14+
* Wrote Haxe dox documentation and did some minor code cleanup, mostly removal of unused methods.
15+
16+
## 1.0.5
17+
* Added regex matching option for filtering generated names.
18+
19+
## 1.0.6
20+
* Added training data embedding helper macro to the library.
21+
22+
## 1.0.7
23+
* Added additional utility functions, code cleanup.
24+
25+
## 1.0.8
26+
* Bug fix for backoff functionality, code cleanup.
27+
28+
## 1.0.9
29+
* Bug fix to avoid endless loop when prior is greater than 0, code cleanup.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Sam Twidale (https://samcodes.co.uk/)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Markov Namegen
2+
3+
Markov Namegen is a Markov chain-based word generator library written in Haxe, made for procedural name generation. Run the demo [here](https://www.samcodes.co.uk/project/markov-namegen/).
4+
5+
## Features
6+
* Katz backoff using high order models - look up to "n" characters back.
7+
* Sort and filter generated strings by length, start, end, content and regex matching.
8+
* Damerau-Levenshtein distance similarity sorting option.
9+
* Dirichlet prior parameter.
10+
11+
## Usage
12+
13+
See the [demo code](https://github.com/Tw1ddle/MarkovNameGenerator) for a complete worked example. Also read the [documentation here](https://tw1ddle.github.io/MarkovNameGenerator/).
14+
15+
## Markov Namegen Ports
16+
17+
Some users have ported and extended the Markov Namegen library to different programming languages. See:
18+
19+
* Python - [pyMarkovNameGenerator](https://github.com/bicobus/pyMarkovNameGenerator) by [bicobus](https://github.com/bicobus).
20+
* C# - [ProceduralNameGenerator](https://github.com/MagicMau/ProceduralNameGenerator) by [MagicMau](https://github.com/MagicMau).
21+
22+
## Tips
23+
* The generator works by using Markov chains, and requires training data to build them. A hundred or more words within your chosen category is usually sufficient for good results.
24+
* Sort words by similarity to preferred "good words" using an edit distance metric, and pick the most similar and suitable results. There are a few edit distance measures provided in EditDistanceMetrics.hx.
25+
* To get best results the training dataset, model order and prior will need to be tweaked for the type of words you want to generate. If possible, keep the prior parameter low or zero. Filter words to suit: look at length, beginning, end, contents, edit distance limits and regex. Some of this done for you in NameGenerator.hx. If you prefer to do it your own way, subclass the Generator class.
26+
27+
## Notes
28+
* Many of the concepts used for the generator were suggested in [this article](http://www.roguebasin.com/index.php?title=Names_from_a_high_order_Markov_Process_and_a_simplified_Katz_back-off_scheme) by Jeffrey Lund.
29+
* The haxelib is written in plain Haxe and so supports every Haxe target.
30+
* If you have any questions or suggestions then [get in touch](https://twitter.com/Sam_Twidale) or open an issue.

dox/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
generated_docs
2+
types.xml

dox/Main.hx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This is solely for generating documentation for Markov Namegen using dox
2+
3+
import markov.namegen.Generator;
4+
import markov.namegen.Model;
5+
import markov.namegen.NameGenerator;
6+
import markov.util.ArraySet;
7+
import markov.util.EditDistanceMetrics;
8+
import markov.util.FileReader;
9+
import markov.util.IntExtensions;
10+
import markov.util.PrefixTrie;
11+
import markov.util.StringExtensions;
12+
import markov.util.TrainingDataBuilder;
13+
14+
class Main {}

dox/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Markov Namegen Dox
2+
3+
Documentation generation for [Markov Namegen](http://tw1ddle.github.io/MarkovNameGenerator/).
4+
5+
This project generates the Markov Namegen documentation using [dox](https://github.com/HaxeFoundation/dox), the Haxe documentation generator.
6+
7+
## Usage
8+
9+
Run ```generate_docs.sh``` and open ```index.html``` under the ```generated_docs``` folder to see the generated documentation.
10+
11+
## Notes
12+
When bumping the library version number, remember to update the ```--version``` parameter in ```generate_docs.bat``` to match.

dox/build.hxml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-xml types.xml
2+
-lib sure
3+
-cp ..
4+
Main
5+
--no-output

dox/generate_docs.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# This shell script generates the documentation for markov namegen.
4+
5+
# Clean the generated documentation folder, to remove any old documentation.
6+
rm -rf "generated_docs"
7+
8+
# Delete any existing generated XML-format type information.
9+
rm -f types.xml
10+
11+
# Build the XML-format type information.
12+
haxe build.hxml
13+
14+
# Generate the documentation.
15+
haxelib run dox -i types.xml -theme ./themes/samcodes --title "Markov Namegen API" -D version 1.0.9 --include "(markov)" -o generated_docs

dox/themes/samcodes/config.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Samcodes Theme",
3+
"author": "Sam Twidale"
4+
}

0 commit comments

Comments
 (0)