-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
120 lines (110 loc) · 6.43 KB
/
main.go
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package main
import (
"fmt"
"log"
"math/rand"
"time"
fn "github.com/s0rg/fantasyname"
)
const (
MIDDLE_EARTH = "(bil|bal|ban|hil|ham|hal|hol|hob|wil|me|or|ol|od|gor|for|fos|tol|ar|fin|ere|leo|vi|bi|bren|thor)" +
"(|go|orbis|apol|adur|mos|ri|i|na|ole|n)" +
"(|tur|axia|and|bo|gil|bin|bras|las|mac|grim|wise|l|lo|fo|co|ra|via|" +
"da|ne|ta|y|wen|thiel|phin|dir|dor|tor|rod|on|rdo|dis)"
JAPANESE_NAMES_CONSTRAINED = "(aka|aki|bashi|gawa|kawa|furu|fuku|fuji|hana|hara|haru|hashi|hira|hon|hoshi|" +
"ichi|iwa|kami|kawa|ki|kita|kuchi|kuro|marui|matsu|miya|mori|moto|mura|nabe|naka|nishi|no|da|ta|o|oo|oka|" +
"saka|saki|sawa|shita|shima|i|suzu|taka|take|to|toku|toyo|ue|wa|wara|wata|yama|yoshi|kei|ko|zawa|zen|sen|" +
"ao|gin|kin|ken|shiro|zaki|yuki|asa)(||||||||||bashi|gawa|kawa|furu|fuku|fuji|hana|hara|haru|hashi|hira|" +
"hon|hoshi|chi|wa|ka|kami|kawa|ki|kita|kuchi|kuro|marui|matsu|miya|mori|moto|mura|nabe|naka|nishi|no|da|" +
"ta|o|oo|oka|saka|saki|sawa|shita|shima|suzu|taka|take|to|toku|toyo|ue|wa|wara|wata|yama|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ai|a)" +
"(lo|la|sri|da|dai|the|sty|lae|due|li|lly|ri|na|ral|sur|rith)(|(su|nu|sti|llo|ria|))" +
"(|(n|ra|p|m|lis|cal|deu|dil|suir|phos|ru|dru|rin|raap|rgue))"
FANTASY_S_A = "(cham|chan|jisk|lis|frich|isk|lass|mind|sond|sund|ass|chad|lirt|und|mar|lis|il|<BVC>)" +
"(jask|ast|ista|adar|irra|im|ossa|assa|osia|ilsa|<vCv>)(|(an|ya|la|sta|sda|sya|st|nya))"
FANTASY_H_L = "(ch|ch't|sh|cal|val|ell|har|shar|shal|rel|laen|ral|jh't|alr|ch|ch't|av)" +
"(|(is|al|ow|ish|ul|el|ar|iel))" +
"(aren|aeish|aith|even|adur|ulash|alith|atar|aia|erin|aera|ael|ira|iel|ahur|ishul)"
FANTASY_N_L = "(ethr|qil|mal|er|eal|far|fil|fir|ing|ind|il|lam|quel|quar|quan|qar|pal|mal|yar|um|ard|enn|ey)" +
"(|(<vc>|on|us|un|ar|as|en|ir|ur|at|ol|al|an))" +
"(uard|wen|arn|on|il|ie|on|iel|rion|rian|an|ista|rion|rian|cil|mol|yon)"
FANTASY_K_N = "(taith|kach|chak|kank|kjar|rak|kan|kaj|tach|rskal|kjol|jok|jor|jad|kot|kon|" +
"knir|kror|kol|tul|rhaok|rhak|krol|jan|kag|ryr)(<vc>|in|or|an|ar|och|un|mar|yk|ja|arn|ir|ros|ror)" +
"(|(mund|ard|arn|karr|chim|kos|rir|arl|kni|var|an|in|ir|a|i|as))"
FANTASY_J_G_Z = "(aj|ch|etz|etzl|tz|kal|gahn|kab|aj|izl|ts|jaj|lan|kach|chaj|qaq|jol|ix|az|biq|nam)" +
"(|(<vc>|aw|al|yes|il|ay|en|tom||oj|im|ol|aj|an|as))" +
"(aj|am|al|aqa|ende|elja|ich|ak|ix|in|ak|al|il|ek|ij|os|al|im)"
FANTASY_K_J_Y = "(yi|shu|a|be|na|chi|cha|cho|ksa|yi|shu)" +
"(th|dd|jj|sh|rr|mk|n|rk|y|jj|th)" +
"(us|ash|eni|akra|nai|ral|ect|are|el|urru|aja|al|uz|ict|arja|ichi|ural|iru|aki|esh)"
FANTASY_S_E = "(syth|sith|srr|sen|yth|ssen|then|fen|ssth|kel|syn|est|bess|inth|nen|tin|cor|" +
"sv|iss|ith|sen|slar|ssil|sthen|svis|s|ss|s|ss)" +
"(|(tys|eus|yn|of|es|en|ath|elth|al|ell|ka|ith|yrrl|is|isl|yr|ast|iy))" +
"(us|yn|en|ens|ra|rg|le|en|ith|ast|zon|in|yn|ys)"
)
type template struct {
Name string
Tmpl string
}
var templates = []template{
{Name: "Middle Earth", Tmpl: MIDDLE_EARTH},
{Name: "Japanese Names (Constrained)", Tmpl: JAPANESE_NAMES_CONSTRAINED},
{Name: "Japanese Names (Diverse)", Tmpl: JAPANESE_NAMES_DIVERSE},
{Name: "Chinese Names", Tmpl: CHINESE_NAMES},
{Name: "Greek Names", Tmpl: GREEK_NAMES},
{Name: "Hawaiian Names (1)", Tmpl: HAWAIIAN_NAMES_1},
{Name: "Hawaiian Names (2)", Tmpl: HAWAIIAN_NAMES_2},
{Name: "Old Latin Place Names", Tmpl: OLD_LATIN_PLACE_NAMES},
{Name: "Dragons (Pern)", Tmpl: DRAGONS_PERN},
{Name: "Dragon Riders", Tmpl: DRAGON_RIDERS},
{Name: "Pokemon", Tmpl: POKEMON},
{Name: "Fantasy (Vowels, R, etc.)", Tmpl: FANTASY_VOWELS_R},
{Name: "Fantasy (S, A, etc.)", Tmpl: FANTASY_S_A},
{Name: "Fantasy (H, L, etc.)", Tmpl: FANTASY_H_L},
{Name: "Fantasy (N, L, etc.)", Tmpl: FANTASY_N_L},
{Name: "Fantasy (K, N, etc.)", Tmpl: FANTASY_K_N},
{Name: "Fantasy (J, G, Z, etc.)", Tmpl: FANTASY_J_G_Z},
{Name: "Fantasy (K, J, Y, etc.)", Tmpl: FANTASY_K_J_Y},
{Name: "Fantasy (S, E, etc.)", Tmpl: FANTASY_S_E},
{Name: "Funny", Tmpl: "sdD i-i"},
}
func main() {
rand.Seed(time.Now().UnixNano())
for i := 0; i < len(templates); i++ {
t := &templates[i]
gen, err := fn.Compile(t.Tmpl, fn.Collapse(true))
if err != nil {
log.Fatal(t.Name, err)
}
fmt.Println(t.Name)
for i := 0; i < 10; i++ {
fmt.Println("\t" + gen.String())
}
}
}