Skip to content

Instantly share code, notes, and snippets.

@mbarkhau
Last active February 4, 2018 17:45
Show Gist options
  • Save mbarkhau/251db022342b346e59e92b9f6a15c7d1 to your computer and use it in GitHub Desktop.
Save mbarkhau/251db022342b346e59e92b9f6a15c7d1 to your computer and use it in GitHub Desktop.
brainkey_sentences.py
"""This is an experiment to generate phrases
which might be more easy to remember than random words.
Of course this is just one part of the equation, next
the sentences would need to be parsed.
One consideration against using this is that people
might be inclined to ignore some of the more nonsensical
sentences, or pick out ones that they find easier to
remember, and thereby reducing the entropy.
Sample Output:
periods 55
names 200
places 59
verbs 39
persons 127
names2 100
objects 83
enropy: 26680325100000 combinations = 44.60084147941729 bits
Three days ago, Jeremy from Africa promised an igloo to Benjamin the florist.
On Tuesday, Eric from Europe spoke about the console of Cheryl the bookmaker.
Three days ago, Roger from Nigeria wrote about the plate of Terry the operator.
Thirteen weeks ago, Terry from America bought a book for his employee Eric.
Last March, Robert from Bangladesh worked with the toaster of Ralph the economist.
Last August, Alan from Asia played with the pet spider of Emily the administrator.
Last June, Robert from Finland spoke about the table of his grandson Gregory.
Twelve weeks ago, Jane from Italy sung about the keychain of Bobby the sheriff.
Last year, Kathleen from Paris made a robot for Donald the economist.
Eight weeks ago, Judith from Dhaka sent a microwave to Dylan the diplomat.
Eight weeks ago, Sandra from Paris played with the broom of her friend Richard.
Nine days ago, Daniel from Iceland knew about the microwave of his grandchild Randy.
Seven weeks ago, Peter from Korea listened about the bucket of Alexis the curator.
Six days ago, Carl from North-America thought about the desk of Billy the designer.
Five days ago, Kathryn from Kyoto used the umbrella of Douglas the locksmith.
"""
import math
girl_names ="""
Mary Patricia Jennifer Elizabeth Linda
Barbara Susan Jessica Margaret Sarah
Karen Nancy Betty Lisa Dorothy
Sandra Ashley Kimberly Donna Carol
Michelle Emily Amanda Helen Melissa
Deborah Stephanie Laura Rebecca Sharon
Cynthia Kathleen Amy Shirley Anna
Angela Ruth Brenda Pamela Nicole
Katherine Virginia Catherine Christine Samantha
Debra Janet Rachel Carolyn Emma
Maria Heather Diane Julie Joyce
Evelyn Frances Joan Christina Kelly
Victoria Lauren Martha Judith Cheryl
Megan Andrea Ann Alice Jean
Doris Jacqueline Kathryn Hannah Olivia
Gloria Marie Teresa Sara Janice
Julia Grace Judy Theresa Rose
Beverly Denise Marilyn Amber Madison
Danielle Brittany Diana Abigail Jane
Natalie Lori Tiffany Alexis Kayla
"""
boy_names = """
James John Robert Michael William
David Richard Joseph Thomas Charles
Christopher Daniel Matthew Anthony Donald
Mark Paul Steven Andrew Kenneth
George Joshua Kevin Brian Edward
Ronald Timothy Jason Jeffrey Ryan
Gary Jacob Nicholas Eric Stephen
Jonathan Larry Justin Scott Frank
Brandon Raymond Gregory Benjamin Samuel
Patrick Alexander Jack Dennis Jerry
Tyler Aaron Henry Douglas Jose
Peter Adam Zachary Nathan Walter
Harold Kyle Carl Arthur Gerald
Roger Keith Jeremy Terry Lawrence
Sean Christian Albert Joe Ethan
Austin Jesse Willie Billy Bryan
Bruce Jordan Ralph Roy Noah
Dylan Eugene Wayne Alan Juan
Louis Russell Gabriel Randy Philip
Harry Vincent Bobby Johnny Logan
"""
places = """
Asia
Europe
America
Africa
North-America
South-America
Sweden
Iceland
Norway
Finland
Estonia
Equador
Brazil
Venezuela
Alberta
Virginia
Scotland
Ireland
Italy
the_USA
Russia
Daytona
Bohemia
Mexico Lagos
Nigeria
Cairo
Egypt
Karachi
Pakistan Dhaka
China Shanghai
Beijing
India Mumbai
Bangladesh
Israel
Pakistan
Dubai
Canada
Austrailia
France Paris
Spain Madrid Barcelona
Germany Berlin Frankfurt
Chicago
Britain London
Ireland Dublin
Japan Tokyo Kyoto
Korea Seoul
the_ghetto
"""
verbs = """
needed_the_{thing}_of_{friend}
found_the_{thing}_of_{friend}
used_the_{thing}_of_{friend}
wanted_the_{thing}_of_{friend}
accepted_the_{thing}_of_{friend}
saw_the_{thing}_of_{friend}
called_for_the_{thing}_of_{friend}
knew_about_the_{thing}_of_{friend}
spoke_about_the_{thing}_of_{friend}
wrote_about_the_{thing}_of_{friend}
threw_away_the_{thing}_of_{friend}
paid_for_the_{thing}_of_{friend}
played_with_the_{thing}_of_{friend}
worked_with_the_{thing}_of_{friend}
went_with_the_{thing}_of_{friend}
came_with_the_{thing}_of_{friend}
heared_about_the_{thing}_of_{friend}
listened_about_the_{thing}_of_{friend}
read_about_the_{thing}_of_{friend}
sung_about_the_{thing}_of_{friend}
thought_about_the_{thing}_of_{friend}
told_about_the_{thing}_of_{friend}
admired_the_{thing}_of_{friend}
asked_{friend}_for_{a}_{thing}
made_{a}_{thing}_for_{friend}
bought_{a}_{thing}_for_{friend}
got_{a}_{thing}_for_{friend}
left_{a}_{thing}_for_{friend}
took_{a}_{thing}_from_{friend}
refused_{a}_{thing}_from_{friend}
owed_{a}_{thing}_to_{friend}
gave_{a}_{thing}_to_{friend}
sent_{a}_{thing}_to_{friend}
passed_{a}_{thing}_to_{friend}
brought_{a}_{thing}_to_{friend}
showed_{a}_{thing}_to_{friend}
lent_{a}_{thing}_to_{friend}
promised_{a}_{thing}_to_{friend}
offered_{a}_{thing}_to_{friend}
"""
objects = """
book cup plate fork spoon knife table
computer laptop phone car chair lighter
razor bottle walkman tin-can toothbrush
pencil present ship snowman igloo
abacus avocado orange apple brick clock
stick asperin watch keychain teapot stool
coat sweater shirt belt blanket
backpack tree dog robot hammer screwdriver
spraycan bucket scissors snowboard
paintbrush erasor rocket brush guitar
boots shoes camera sneakers tractor
toaster microwave fridge TV desk
binder fish lamp dog cat pet_spider
pet_rat pet_lizzard magnet umbrella
glasses pumpkin potato trophy console
bicycle broom snow-plow envelope
"""
stuff = """
water cash sand cloths air oil
cereal oats alcohol chewing_gum
popcorn
"""
place_things = """
shop school world house room floor
"""
neuter_persons = """
{name}_the_artist
{name}_the_physicist
{name}_the_inspector
{name}_the_publisher
{name}_the_operator
{name}_the_moderator
{name}_the_producer
{name}_the_singer
{name}_the_oncologist
{name}_the_plumber
{name}_the_principal
{name}_the_beautician
{name}_the_florist
{name}_the_psychologist
{name}_the_psychiatrist
{name}_the_physiologist
{name}_the_therapist
{name}_the_minister
{name}_the_musician
{name}_the_planner
{name}_the_welder
{name}_the_worker
{name}_the_actor
{name}_the_clerk
{name}_the_officer
{name}_the_author
{name}_the_soldier
{name}_the_architect
{name}_the_technician
{name}_the_banker
{name}_the_lawyer
{name}_the_bookmaker
{name}_the_bookkeeper
{name}_the_cartographer
{name}_the_chemist
{name}_the_servant
{name}_the_manager
{name}_the_leader
{name}_the_dentist
{name}_the_doctor
{name}_the_surgeon
{name}_the_nurse
{name}_the_sailor
{name}_the_economist
{name}_the_electrician
{name}_the_instructor
{name}_the_consultant
{name}_the_expert
{name}_the_professor
{name}_the_professional
{name}_the_machinist
{name}_the_carpenter
{name}_the_blacksmith
{name}_the_programmer
{name}_the_zoologist
{name}_the_director
{name}_the_designer
{name}_the_broker
{name}_the_developer
{name}_the_guide
{name}_the_curator
{name}_the_goldsmith
{name}_the_gunsmith
{name}_the_greenkeeper
{name}_the_gynaecologist
{name}_the_dermatologist
{name}_the_historian
{name}_the_trainer
{name}_the_pilot
{name}_the_hairdresser
{name}_the_hydrologist
{name}_the_specialist
{name}_the_analyst
{name}_the_pharmacist
{name}_the_administrator
{name}_the_agent
{name}_the_advisor
{name}_the_journalist
{name}_the_jockey
{name}_the_judge
{name}_the_gardener
{name}_the_secretary
{name}_the_assistant
{name}_the_lifeguard
{name}_the_locksmith
{name}_the_driver
{name}_the_botanist
{name}_the_mechanic
{name}_the_farmer
{name}_the_editor
{name}_the_butcher
{name}_the_biologist
{name}_the_student
{name}_the_deputy
{name}_the_diplomat
{name}_the_citizen
{name}_the_teacher
{name}_the_sheriff
{pronoun}_employee_{name}
{pronoun}_boss_{name}
{pronoun}_child_{name}
{pronoun}_eldest_child_{name}
{pronoun}_youngest_child_{name}
{pronoun}_grandchild_{name}
{pronoun}_cousin_{name}
{pronoun}_friend_{name}
{pronoun}_partner_{name}
"""
female_persons = """
{pronoun}_wife_{name}
{pronoun}_mother_{name}
{pronoun}_sister_{name}
{pronoun}_eldest_sister_{name}
{pronoun}_youngest_sister_{name}
{pronoun}_step-mother_{name}
{pronoun}_step-sister_{name}
{pronoun}_grandmother_{name}
{pronoun}_granddaughter_{name}
{pronoun}_aunt_{name}
"""
male_persons = """
{pronoun}_husband_{name}
{pronoun}_father_{name}
{pronoun}_brother_{name}
{pronoun}_eldest_brother_{name}
{pronoun}_youngest_brother_{name}
{pronoun}_step-father_{name}
{pronoun}_step-brother_{name}
{pronoun}_grandfather_{name}
{pronoun}_grandson_{name}
{pronoun}_uncle_{name}
"""
abstract_things = """
part story
program number
right problem
job home country
fact family
money state
government
light place
point group
company business
case system
work word
question way
profit
"""
periods = """
Last_January
Last_February
Last_March
Last_April
Last_May
Last_June
Last_July
Last_August
Last_September
Last_October
Last_November
Last_December
On_Monday
On_Tuesday
On_Wednesday
On_Thursday
On_Friday
On_Saturday
On_Sunday
Yesterday
Two_days_ago
Three_days_ago
Four_days_ago
Five_days_ago
Six_days_ago
Seven_days_ago
Eight_days_ago
Nine_days_ago
Ten_days_ago
Eleven_days_ago
Twelve_days_ago
Thirteen_days_ago
One_week_ago
Two_weeks_ago
Three_weeks_ago
Two_weeks_ago
Three_weeks_ago
Four_weeks_ago
Five_weeks_ago
Six_weeks_ago
Seven_weeks_ago
Eight_weeks_ago
Nine_weeks_ago
Ten_weeks_ago
Eleven_weeks_ago
Twelve_weeks_ago
Thirteen_weeks_ago
One_month_ago
Last_night
Last_year
Last_evening
This_morning
Last_month
Last_week
After_a_minute
After_an_hour
Last_weekend
"""
import random
def split(text):
for line in text.splitlines():
for word in line.split():
yield word.strip()
boy_names = sorted(set(split(boy_names)))
girl_names = sorted(set(split(girl_names)))
names = boy_names + girl_names
places = sorted(set(split(places)))
verbs = sorted(set(split(verbs)))
objects = sorted(set(split(objects)))
neuter_persons = set(split(neuter_persons))
female_persons = set(split(female_persons))
male_persons = set(split(male_persons))
persons = sorted(neuter_persons | female_persons | male_persons)
periods = sorted(set(split(periods)))
assert len(set(v.split("_")[0] for v in verbs)) == len(verbs)
def make_sentance():
name = random.choice(names)
place = random.choice(places)
verb = random.choice(verbs)
object = random.choice(objects)
person = random.choice(persons)
period = random.choice(periods)
if person in female_persons:
person_name = random.choice(girl_names)
elif person in male_persons:
person_name = random.choice(boy_names)
else:
person_name = random.choice(names)
if name in girl_names:
pronoun = "her"
else:
pronoun = "his"
if "-" in object:
article, object = object.split("-")
elif any(object.startswith(char) for char in "aeiou"):
article = "an"
else:
article = "a"
context = "".join((
period,
", ",
name,
" from ",
place,
))
sentence = verb.format(
friend=person.format(pronoun=pronoun, name=person_name),
a=article,
thing=object,
)
return (context + " " + sentence + ".").replace("_", " ")
combos = (
len(periods) *
len(names) *
len(places) *
len(verbs) *
len(persons) * min(len(girl_names), len(boy_names)) *
len(objects)
)
print(
"\nperiods", len(periods),
"\nnames ", len(names),
"\nplaces ", len(places),
"\nverbs ", len(verbs),
"\npersons", len(persons),
"\nnames2 ", min(len(girl_names), len(boy_names)),
"\nobjects", len(objects),
)
print("enropy:", combos, "combinations =", math.log(combos) / math.log(2), "bits")
print()
for i in range(15):
print(make_sentance())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment