def genUserName(): r = RandomWords() lGen1 = r.get_random_words(hasDictionaryDef='True', includePartOfSpeech='noun') lGen1.extend( r.get_random_words(hasDictionaryDef='True', includePartOfSpeech='noun')) lGen1.extend( r.get_random_words(hasDictionaryDef='True', includePartOfSpeech='noun')) lUniq1 = [] for count in range(len(lGen1)): s = lGen1[count].lower() s = "".join(s.split()) if s not in lUniq1: lUniq1.append(s) def replacer(resultantName, randChoice): inds = [ i for i, _ in enumerate(resultantName) if not resultantName.isspace() ] choiceRand_Max = 3 if len(resultantName) / 3 > 2 else int( len(resultantName) / 3) sam = random.sample(inds, random.randint(0, choiceRand_Max)) lst = list(resultantName) for ind in sam: lst[ind] = random.choice(randChoice) resultantName = "".join(lst) return resultantName #print(len(lGen1), len(lUniq1)) lGenName1 = [] for count in range(len(lUniq1)): ranOption = random.randint(0, 3) resultantName = lUniq1[count] if ranOption == 1: #Append Numbers resultantName = resultantName + str(random.choice(string.digits)) elif ranOption == 2: #Change some parts of a string to numbers resultantName = replacer(resultantName, string.digits) elif ranOption == 3: #Change some parts of a string to punct allowedPunct = [ '!', '@', '#', '$', '%', '^', '&', '*', '_', '+', '=', '-', '~' ] resultantName = replacer(resultantName, allowedPunct) else: #Do no change continue lGenName1.append(resultantName[:16]) return lGenName1
def gen_word(): r = RandomWords() random_words = r.get_random_words() gen_random_number = random.randint(1, len(random_words)) #print(random_words[gen_random_number]) random_word = random_words[gen_random_number] return random_word
def __random_password_gen__(self): r = RandomWords() randomWords = r.get_random_words() print(randomWords) password = randomWords[0] + "-" + randomWords[1] + "-" + randomWords[ 2] + "-" + randomWords[3] return password
def get_word_to_guess(): try: r = RandomWords() words_list = r.get_random_words() word_to_guess = words_list[random.randint(0, len(words_list) - 1)].lower() except TypeError as e: print( "-----------------------------------------------------------------------------------------" ) print( "'random_word' module did not succesfully return a list of words. Picking one from the default list." ) print( "-----------------------------------------------------------------------------------------" ) default_words = [ "noiseless", "day", "boring", "holiday", "grieving", "subtract", "love", "whine", "bustling", "craven", "guttural", "muscle", "choke", "oatmeal", "shrill", "shade", "can", "hilarious", "discreet", "big" ] word_to_guess = default_words[random.randint(0, len(default_words) - 1)].lower() return word_to_guess
def create_repositories(driver, n): r = RandomWords() words = list() for i in range(n): print('Creating repository number %d...' % (i+1)) words = r.get_random_words(maxLength=15, limit=2) print('Random words generated in iteration %d: %r' % (i, words)) composed_repository_name = 'orarepo' for item in words: composed_repository_name = composed_repository_name + '-' + item print('Composed repository name: ' + composed_repository_name) # Convert to lowercasxe composed_repository_name = composed_repository_name.lower() driver.get('https://github.com/new') # Now, in github.com/new repository_name = driver.find_element_by_name('repository[name]') repository_description = driver.find_element_by_name('repository[description]') repository_readme_init = driver.find_element_by_id('repository_auto_init') repository_private = driver.find_element_by_id('repository_visibility_private') repository_name.send_keys(composed_repository_name) repository_description.send_keys('%s, generated using Selenium automation by jasperan: https://github.com/jasperan/orarepo-creator' % composed_repository_name) repository_readme_init.click() repository_private.click() time.sleep(.5) repository_create = driver.find_element_by_xpath('//*[@id="new_repository"]/div[3]/button') repository_create.click() print('Successfully created repository number %d.' % (i+1))
def main(): r = RandomWords() words = list() words = r.get_random_words(maxLength=15, limit=2) print('Random words: ', words) composed_repository_name = 'orarepo' for item in words: composed_repository_name = composed_repository_name + '-' + item print('Composed repository name: ' + composed_repository_name) # Convert to lowercasxe composed_repository_name = composed_repository_name.lower() # Now, we will initialize the repository in Github using os.system #location = input('Please introduce the pwd where you want to create the repositories:') #os.system('cd ' + location) os.system('mkdir /home/jasper/git/%s' % composed_repository_name) os.system('cd /home/jasper/git/%s' % composed_repository_name) os.system('git init /home/jasper/git/%s' % composed_repository_name) os.system('touch /home/jasper/git/%s/README.md' % composed_repository_name) os.system('echo %s >> /home/jasper/git/%s/README.md' % (composed_repository_name, composed_repository_name)) os.system('git add -A') os.system('git commit') os.system('git push --set-upstream origin master') #os.system('git remote add origin [email protected]/jasperan/%s' % composed_repository_name) os.system('git push')
def _name(self, name) -> str: if name: return name # If name is not provided, return a random name else: r = RandomWords() words = r.get_random_words(minLength=8, limit=3) random_package_name = "_".join(words).lower() return random_package_name
def generate_word_list(): # return ['Stjoepits', 'Kefloepits'] # return ['Kefloepitst', 'Kefloepitst'] # return ['the', 'and'] r = RandomWords() words = r.get_random_words( hasDictionaryDef="true", minCorpusCount=3, minLength=3, maxLength=10, limit=30) return words
def main(): r = RandomWords() l = r.get_random_words( minLength=4, maxLength=4, ) f = open("brutewords.txt", "a") for w in l: f.write(w + "\n") f.close()
def generate_produit(nombreProduits): r = RandomWords() produits = [] nomProduits = r.get_random_words(limit=500) for i in range(0, nombreProduits): id = i nomProduit = nomProduits[random.randint(0, 499)] prix = random.randint(1, 500) produit = Produit(id, nomProduit, prix) produits.append(produit) return produits
def contextual_differences(candidate_1, candidate_2) -> list: """ This function should calculate different wordpairs :rtype: list or tuple """ r = RandomWords() words = [x.lower() for x in r.get_random_words(limit=2)] return words
def generate_random_words(num_words: int): """ generates num_words random words TODO: replace this with code that generates only common words params num_words: number of words to generate returns a list of random words """ r = RandomWords() all_words = [] batches = num_words//100 for _ in range(int(batches)): all_words += r.get_random_words(includePartOfSpeech = "noun,verb", limit=100) remaining_words = num_words - len(all_words) if remaining_words != 0: all_words += r.get_random_words(includePartOfSpeech = "noun,verb", limit = remaining_words) return all_words
def new_cards(): try: # First lets try to draw new words from online r = RandomWords() words = r.get_random_words(hasDictionaryDef="true", includePartOfSpeech="noun") client.incr('new_cards.lookup') except Exception as e : # opps something went wrong, lets use backup words # Use statsd counter here to monitor error_rate statsd.increment('new_cards.errors') words = default_words pass # Shuffle the words random.shuffle(words) return words[0:7]
def genRandomWords(): """generate 10000 random words, save them to file - each word used in a uid increases uniqueness by factor of 10000 3 words in a uid corresponds to 1 in 1 trillion chance of collision seems good """ words = set() service = RandomWords() while len(words) < N_WORDS: new_words = service.get_random_words() if new_words is None: continue words.update(new_words) outData = {"words": tuple(sorted(words)), "date": str(datetime.now())} with outputPath.open("w") as f: json.dump(outData, f)
def create_session(request): username=request.POST.get('username',None) user_check = User.objects.filter(username__iexact=username) if len(user_check)==0: user = User.objects.create_user(username=username, password=username) else: user=user_check[0] # create new session starttime=timezone.now() rw=RandomWords() token=rw.get_random_words(hasDictionaryDef="true", minCorpusCount=20, minLength=5, minDictionaryCount=1, maxLength=5, sortBy="alpha", limit=4) session=Session(user=user, starttime=starttime,endtime=starttime, status=False, token=token) session.save() sessionurl='/session/'+str(session.pk) login(request,user) return HttpResponse(session.pk)
def create_new_match(request): game_type = request.GET['gameType'] if game_type != "tictactoe": return JsonResponse({ 'status': 'false', 'message': "unknown game type" }, status=500) r = RandomWords() words = r.get_random_words(includePartOfSpeech="noun", minCorpusCount=400, maxLength=10, limit=3) print(words) # TODO: fix and finish this method return JsonResponse({"gameid": "fakeid"})
def generate_wordlist(): r = RandomWords() words = r.get_random_words(hasDictionaryDef="true", includePartOfSpeech="noun,verb", minDictionaryCount=1, maxDictionaryCount=10, minLength=5, maxLength=10, sortBy="alpha", sortOrder="asc", limit=40) f = open("words.txt", "w+") for i in range(len(words)): f.write("{}\n".format(words[i])) f.close()
def __generatePrimaryTrades(TenorVsBond, numOfInvestors, numOfTradesEach, writer: Writer): randomWords = RandomWords() words = randomWords.get_random_words() for n in range(numOfInvestors): investorName = words[n % len(words)] tenorWeight = { 15: random.random(), 10: random.random(), 5: random.random() } primaryInvestorBot = PrimaryInvestorRobot(investorName, TenorVsBond, tenorWeight, 10000000, 10000000) for t in range(numOfTradesEach): trade = primaryInvestorBot.generateTrade() #print(trade) writer.write(trade)
def init(): if os.path.isfile('.SecureSync'): click.echo('This directory is already linked to a SecureSync instance!') return serverip = input('Please enter the server IP: ') generator = RandomWords() keys = generator.get_random_words(hasDictionaryDef="true", limit=5) keystring = "secure" for key in keys: keystring += "-" + key config = { "server": serverip, "dir": os.getcwd() + '/', "key": keystring } configfile = open(".SecureSync", "w+") configfile.write(json.dumps(config)) configfile.close() pid = subprocess.Popen(["SecureSyncReceive"]) click.echo("Successfully initialized!") click.echo("When connecting use the following key: " + keystring)
from random_word import RandomWords r = RandomWords() # Return a single random word r.get_random_word() # Return list of Random words r.get_random_words() # Return Word of the day r.word_of_the_day() # print(r.get_random_word(hasDictionaryDef="True", includePartOfSpeech="noun,verb", minCorpusCount=1, maxCorpusCount=10, minDictionaryCount=1, maxDictionaryCount=10, minLength=5, maxLength=10)) print(r.get_random_word(hasDictionaryDef='True', includePartOfSpeech="verb"))
import random from random_word import RandomWords rw = RandomWords() # Creating a random word object rw.get_random_words(hasDictionaryDef = "true", maxLength = 10, limit = 4) def randomFill(wordSearch): Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for row in range(0,12): for col in range(0,12): if wordSearch[row][col]=="-": randomLetter = random.choice(Letters) wordSearch[row][col] = randomLetter def displayWordSearch(wordSearch): print(" _________________________") print("| |") for row in range(0,12): line="| " for col in range(0,12): line = line + wordSearch[row][col] + " " line = line + "|" print(line) print("|_________________________|") #def addWord(rw, wordSearch): # row = random.randint(0,11) # col = 0
def transform_mc(df, col, random=2, synonym=1, antonym=1, mc_length=5): tmp_lst = list(df[col].values) def deEmojify(inputString): return inputString.encode('ascii', 'ignore').decode('ascii') clean_lst = [deEmojify(str(i)) for i in tmp_lst] processed_lst = [] split_line_list = [] for i in clean_lst: synonyms = [] antonyms = [] last_word = i.split()[-1] split_line = i.rsplit(' ', 1)[0] split_line_list.append(split_line) last_word = re.sub(r'[^\w\s]', '', last_word) print("Original sentence: " + i) print("Last Word: " + last_word) #print(split_line) for syn in wordnet.synsets(last_word): for l in syn.lemmas(): synonyms.append(l.name()) if l.antonyms(): antonyms.append(l.antonyms()[0].name()) #print(list(set(synonyms))) #print(set(antonyms)) syn_pool = list(set(synonyms))[0:synonym] ant_pool = list(set(antonyms))[0:antonym] r = RandomWords() total_pool = syn_pool + ant_pool + [last_word] remaining_length = mc_length - len(total_pool) if remaining_length > 0: time.sleep(3) try: tmp_lst = r.get_random_words(limit=remaining_length) except: tmp_lst = ["hello" for i in range(remaining_length)] #print(tmp_lst) total_pool = syn_pool + ant_pool + tmp_lst + [last_word] processed_lst.append(total_pool) print("new word choices: {}".format(total_pool)) print("\n") d1 = {"Body": processed_lst} df2 = pd.DataFrame(d1) df3 = df2[['body1', 'body2', 'body3', 'body4', 'body5']] = pd.DataFrame(df2.Body.values.tolist(), index=df2.index) #df3[col] = df[col] #df["WordChoice1"] = #random_pool = [r.get_random_word() for i in range(random)] #print(df3) for i in range(mc_length): df["Word_{}".format(i + 1)] = df3[i] df["correct_last_word"] = df["Word_{}".format(mc_length)] df["processed_sentence"] = split_line_list print(df)
def hangman(): print("Welcome to Hangman!") a = '---> word length =' difficulty = { '1': (f'easy {a} 5 or 6', random.randint(5, 6)), '2': (f'normal {a} 7, 8 or 9', random.randint(7, 9)), '3': (f'hard {a} 10 or more', None), '4': ( f'random {a} between 5 and 10', random.randint(5, 10), ) } print('\nDifficulty levels: ') for key, value in sorted(difficulty.items()): print(f'{key}: {value[0]}') # input filter while True: chosen_difficulty = input("Choose difficulty: ") if chosen_difficulty not in difficulty.keys(): print(f'\nChoose {", ".join(difficulty.keys())} only!') else: break # hint at final guess with 30% chance hint_active = False if random.randint(1, 10) in {1, 2}: hint_active = True # words selection word_generator = RandomWords() number_of_words = 10 word_length = difficulty.get(chosen_difficulty, random.randint(5, 10))[1] limit = 10 active = True while active: # gather random words i = 1 random_words = [] while True: clear_console() print( "\nGathering words... (If this takes too long, check your internet connection.)" ) try: if word_length is not None: random_words = word_generator.get_random_words( limit=number_of_words, minLength=word_length, maxLength=word_length) else: random_words = word_generator.get_random_words( limit=number_of_words, minLength=10) if random_words: break except: print(f'{i}/{limit} Retrying...') if i == limit: final_decision = input( f'{i} seconds have passed. Would you like to try again or go back to menu?\n' f'(t: try again, x: quit)?: ').strip().lower() if final_decision in ('t', 'try', 'try again'): i = 0 else: clear_console() active = False break i += 1 time.sleep(1) if not active: break random_words = [word.lower() for word in random_words] # filter any word which contains non-alphabetical out for word in random_words: remove = False for alphabet in word: if not 'a' <= alphabet <= 'z': remove = True if remove: random_words.remove(word) print( f'The word is one of these: \n\n\t{", ".join(random_words[:len(random_words)//2])}\n' f'\t{", ".join(random_words[len(random_words)//2:])}\n') decision = input("Random a new word set ---> Enter 'x'\n" " To start ---> Press Enter!\n" "(x, Enter)? : ") if decision != 'x': break clear_console() if active: full_body = { 'hanger': '_________________\n' ' |\n' ' |', 'head': ' (T_T)', 'neck': ' |', 'arms': ' \ | / \n' ' \|/ ', 'body': ' |\n' ' |', 'legs': ' / \ \n' ' / \ ', 'feet': ' __ __' } hang_order = ('hanger', 'head', 'neck', 'arms', 'body', 'legs', 'feet') mysterious_word = random_words[random.randint(0, len(random_words) - 1)] mysterious_word_to_report = mysterious_word[:] mysterious_word = list(mysterious_word) length = len(mysterious_word) blank = '_' blank_spaces = list(blank * length) guess_limit = len(full_body.keys()) alphabets = "a b c d e f g h i j k l m n o p q r s t u v w x y z".split( ) you_have_guessed = [] body = [] # inform word's info print( f'\nThe mysterious word is among these: \n\n\t{", ".join(random_words[:len(random_words)//2])}\n' f'\t{", ".join(random_words[len(random_words)//2:])}\n') print_enter_to_continue() # main game sequence hang_order_index = 0 while True: clear_console() if guess_limit != 1: print(f"{guess_limit} guesses left.") else: print("DECISIVE GUESS...") if hint_active: print( f'HINT!!! (20% chance)\nThe word is one of these: \n\n\t{", ".join(random_words)}\n' ) hint_active = False print(f"You haven't guessed: {' '.join(alphabets)}") if you_have_guessed: print(f"You have guessed: {' '.join(you_have_guessed)}") print(f'\n\t\t\t\t{" ".join(blank_spaces)}') # body printing for body_part in body: print(body_part) # check whether win or lose if set(mysterious_word) == {''}: print( f"\nCongratulations! YOU WIN!!!.\nThe mysterious word is indeed '{mysterious_word_to_report}'.\n" ) else: if guess_limit == 0: print( f"\nYOU LOSE!!!\nThe mysterious word is {mysterious_word_to_report}.\n" ) if set(mysterious_word) == {''} or guess_limit == 0: while True: see_translation = input( f"Do you want to see translation in Thai for '{mysterious_word_to_report}'?\n" "(y, n)?: ").strip().lower() if see_translation not in 'yn': print("Enter y or n.\n") else: print() break if see_translation == 'y': web.open( f'https://translate.google.com/#view=home&op=translate&sl=en&tl=th&text={mysterious_word_to_report}' ) break # guess check while True: guess = input("Your guess: ").strip().lower() if not 'a' <= guess <= 'z': print('You can guess an alphabet only!') else: if len(guess) > 1: print('One character only!') else: if guess in you_have_guessed: print(f'You have already guessed "{guess}"') else: break # game mechanism you_have_guessed.append(guess) if guess in mysterious_word: # reform mysterious_word and black_spaces new_mysterious_word = [] new_black_spaces = blank_spaces.copy() for index, char in enumerate(mysterious_word): if guess == char: new_mysterious_word.append("") new_black_spaces[index] = guess else: new_mysterious_word.append(char) if guess not in you_have_guessed: new_black_spaces[index] = blank mysterious_word = new_mysterious_word blank_spaces = new_black_spaces alphabets.remove(guess) else: alphabets.remove(guess) guess_limit -= 1 body.append(full_body[hang_order[hang_order_index]]) hang_order_index += 1
import random from random_word import RandomWords r = RandomWords() lista_cuvinte = r.get_random_words(hasDictionaryDef='true', minCorpusCount=1, maxCorpusCount=5, minLength=5, maxLength=12, sortBy="alpha", sortOrder="asc", limit=15) print(lista_cuvinte) cuvant_ales = random.choice(lista_cuvinte) print(cuvant_ales) cuvant_curent = list(['_'] * len(cuvant_ales)) alegeri_gresite = [] numar_incercari = 8 print("Cuvantul este {}".format(" ".join(cuvant_curent))) while "".join(cuvant_curent) != cuvant_ales and numar_incercari: urmatoarea_litera = input("Introduceti urmatoarea litera: ").lower() if len(urmatoarea_litera) != 1: print("Introduceti o singura litera") elif not urmatoarea_litera.isalpha(): print("Caracterul introdus nu este o litera") elif urmatoarea_litera in alegeri_gresite:
print(doc) val = random.uniform(0, 1) if val < 0.094: cc = 'IR' elif val < 0.094 + 0.145: cc = europe_countries[random.randint(0, len(europe_countries) - 1)] elif val < 0.094 + 0.145 + 0.315: cc = 'BR' else: cc = 'TR' res = requests.get('%s?nat=%s' % (random_user_api, cc.lower())) user = json.loads(res.text)['results'][0] user['location']['country'] = country_lut[cc]['name'] skills = r.get_random_words(limit=random.randint(1, 10)) skills = [{ 'name': skill, 'proficiency': ['beginner', 'intermediate', 'advanced'][random.randint(0, 2)] } for skill in skills] user2 = { 'firstName': user['name']['first'], 'lastName': user['name']['last'], 'phoneNumber': user['phone'], 'email': user['email'], 'ethnicity': ethnicity_map[cc], 'country': user['location']['country'], 'skills': skills
FILE = "words.js" DICT_SIZE = 1500 MIN_CORPUS_COUNT = 300000 MAX_CORPUS_COUNT = None WORD_TYPES = ["noun", "verb", "adjective", "adverb"] word_generator = RandomWords() inventory = {} for pos in WORD_TYPES: if MAX_CORPUS_COUNT is None: inventory[pos] = word_generator.get_random_words( includePartOfSpeech=pos, limit=DICT_SIZE, minCorpusCount=MIN_CORPUS_COUNT) else: inventory[pos] = word_generator.get_random_words( includePartOfSpeech=pos, limit=DICT_SIZE, minCorpusCount=MIN_CORPUS_COUNT, maxCorpusCount=MAX_CORPUS_COUNT) jsons = json.dumps(inventory) f = open(FILE, "w") f.write(jsons) f.close() #print(jsons)
import requests from random_word import RandomWords print("Wait while the script is loading...") r = RandomWords() words = r.get_random_words(includePartOfSpeech="adjective", limit=5) name = input( 'Enter your name (Make sure you include space between first and last name):' ) print('') parts = name.split(' ') usernames = [] def combinations(): if (len(parts) == 1): usernames.append(parts[0]) usernames.append(parts[0][::-1]) usernames.append(parts[0][::2]) usernames.append(parts[0] + parts[0][::-1]) for word in words: usernames.append(parts[0] + word) if (len(parts) == 2): usernames.append(parts[0]) usernames.append(parts[1]) usernames.append(parts[0] + parts[1]) usernames.append(parts[0] + '-' + parts[1]) usernames.append(parts[1][0] + parts[0]) usernames.append(parts[1][0] + '-' + parts[0])
from random_word import RandomWords r = RandomWords() ans = r.get_random_words() #Print a large arrray from numpy import random arr =[] list1 = {'first','last','change','LTP','EPS'} yam2 = dict.fromkeys(list1, 0) dic= {} for p in range(7): arr.append(yam2) for i in range(5): arr.append() for i in range(7): for p in list1: arr[i][p] = random.randint(low=44,high=99) arr[i]['first'] = random.choice(['yain','ansu','benteke','shakiri','lena','lambo']) arr[i]['last'] = random.choice(['zuker','madden','ragge','bloom','finzu','fati']) print(arr)
from threading import Thread from random_word import RandomWords from tkinter import * import pprint # Generate a list of random words rw = RandomWords() try: rw_list = rw.get_random_words(minCorpusCount=5000, limit=500, maxLength=7) except: rw_list = [ 'bicycle', 'sanity', 'giving', 'Ambien', 'blest', 'began', 'lighten', 'ordeal', 'detach', 'slowest', 'elect', 'shampoo', 'lasting', 'jackass', 'steal', 'rabble', 'Jamaica', 'season', 'highs', 'begged', 'cliff', 'Ernie', 'Rector', 'Caesar', 'ungodly', 'torment', 'shots', 'rubric', 'juggle', 'shakier', 'custard', 'buffs', 'sedate', 'ruffian', 'decorum', 'Saxon', 'Manual', 'under', 'knell', 'Rivera', 'matured', 'Roxanne' ] finally: print(len(rw_list)) rw_list_string = ' '.join(rw_list) # Initialize Fonts & Constants MINUTE = 60000 HEAD_FONT = ("Helvetica", 36, "bold") BODY_FONT = ("Helvetica", 15)
from tkinter import * from tkinter import messagebox import time import random # import package to generate random words from random_word import RandomWords FONT = "Helvetica" BG_COLOR = "#a2d0c1" cpm = 0 missed = 0 counter = 60 rw = RandomWords() words = rw.get_random_words(minLength=3, maxLength=7, limit=200) word = words[random.randint(0, 199)] def generate_word(): word = words[random.randint(0, 199)] word_label.config(text=word) def start_timer(): global counter, cpm timer_label.config(text=counter) if counter > 0: counter -= 1 timer = window.after(1000, start_timer) else: timer_label.config(text="00")