Skip to content

Instantly share code, notes, and snippets.

@soldni
Created October 21, 2015 20:12
Show Gist options
  • Select an option

  • Save soldni/a3f2aa9ce806404156c6 to your computer and use it in GitHub Desktop.

Select an option

Save soldni/a3f2aa9ce806404156c6 to your computer and use it in GitHub Desktop.
Create Names staring with L and S for computer hardware.
from random import randint
from nltk.corpus import wordnet as wn
from time import time
print("Loading NLTK... be patient.")
start = time()
adj_candidates = list(
set(
e.name().split('.')[0] for e in wn.all_synsets('a')
if (
e.name().startswith('l') and
e.name().find('_') < 0 and
e.name().find('-') < 0
)
)
)
noun_candidates = list(
set(
e.name().split('.')[0] for e in wn.all_synsets('n')
if (
e.name().startswith('n') and
e.name().find('_') < 0 and
e.name().find('-') < 0
)
)
)
print("Done in {:.2f} seconds. Suggestions coming...".format(time() - start))
while len(adj_candidates) > 0 and len(noun_candidates) > 0:
adj_index = randint(0, len(adj_candidates) - 1)
noun_index = randint(0, len(noun_candidates) - 1)
adj = adj_candidates.pop(adj_index)
noun = noun_candidates.pop(noun_index)
try:
raw_input('>>>\t"{} {}"'.format(adj.capitalize(), noun.capitalize()))
except KeyboardInterrupt:
print('\nbye.')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment