git @ Cat's Eye Technologies NaNoGenLab / eb712d2
Add a list of containers that can be loaded for infix-neologisms. Chris Pressey 10 years ago
3 changed file(s) with 60 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
0 amphora
1 ampoule
2 bag
3 barrel
4 basket
5 bin
6 bottle
7 bowl
8 box
9 bucket
10 can
11 carboy
12 carton
13 cask
14 chest
15 chub
16 coffer
17 container
18 crate
19 cup
20 demijohn
21 drum
22 envelope
23 flagon
24 glass
25 gourd
26 jar
27 jug
28 keg
29 mug
30 net
31 package
32 pail
33 pot
34 pouch
35 sack
36 sachet
37 trunk
38 vessel
39 vial
1414 the middle.
1515 * Possibly repeat step #2.
1616 * Output the word and repeat from step #1.
17
18 Sample Output
19 -------------
20
21 Running it on `../generic-corpora/containers.txt` which I just threw together
22 after a few internet searches, you might get
23
24 > pancupetil flacupgon bocrpailatewl chnetest poenvecuplopeuch barvialrel demiflaflagongonjohn contflavialgonainer jcarbasketboyar bucampampoulehoraket contpackchubageainer nbopackagexet bcontainerox gobasketurd envebasampouleketlope chcacoffernest nbotbagtleet bchejugstox bamphjugoraox bucbucnetketket
11
22 import random
33 import sys
4
5
6 # TODO: read from file
7 WORDS = [
8 'giraffe',
9 'confusion',
10 'cake',
11 'smile',
12 'horror',
13 'pizza',
14 ]
154
165
176 def splitword(word):
209
2110
2211 def main(argv):
23 for g in xrange(0, 100):
24 word = random.choice(WORDS)
12 words = set()
13 for filename in argv[1:]:
14 with open(filename) as f:
15 for line in f:
16 words.add(line.strip())
17
18 words = list(words) # because random.choice doesn't work on sets
19 for g in xrange(0, 20):
20 word = random.choice(words)
2521 parts = splitword(word)
26 word = parts[0] + random.choice(WORDS) + parts[1]
22 word = parts[0] + random.choice(words) + parts[1]
2723 if random.randint(0, 1) == 0:
2824 parts = splitword(word)
29 word = parts[0] + random.choice(WORDS) + parts[1]
25 word = parts[0] + random.choice(words) + parts[1]
3026 sys.stdout.write(word + ' ')
27 sys.stdout.write("\n")
3128
3229
3330 if __name__ == '__main__':