Add a list of containers that can be loaded for infix-neologisms.
Chris Pressey
10 years ago
14 | 14 |
the middle.
|
15 | 15 |
* Possibly repeat step #2.
|
16 | 16 |
* 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
|
1 | 1 |
|
2 | 2 |
import random
|
3 | 3 |
import sys
|
4 | |
|
5 | |
|
6 | |
# TODO: read from file
|
7 | |
WORDS = [
|
8 | |
'giraffe',
|
9 | |
'confusion',
|
10 | |
'cake',
|
11 | |
'smile',
|
12 | |
'horror',
|
13 | |
'pizza',
|
14 | |
]
|
15 | 4 |
|
16 | 5 |
|
17 | 6 |
def splitword(word):
|
|
20 | 9 |
|
21 | 10 |
|
22 | 11 |
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)
|
25 | 21 |
parts = splitword(word)
|
26 | |
word = parts[0] + random.choice(WORDS) + parts[1]
|
|
22 |
word = parts[0] + random.choice(words) + parts[1]
|
27 | 23 |
if random.randint(0, 1) == 0:
|
28 | 24 |
parts = splitword(word)
|
29 | |
word = parts[0] + random.choice(WORDS) + parts[1]
|
|
25 |
word = parts[0] + random.choice(words) + parts[1]
|
30 | 26 |
sys.stdout.write(word + ' ')
|
|
27 |
sys.stdout.write("\n")
|
31 | 28 |
|
32 | 29 |
|
33 | 30 |
if __name__ == '__main__':
|