haiku_gadget 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fbd4d2aaaffe3975b32a24c2707796a2d132041
4
- data.tar.gz: 33595d2c37a1d24495da76748c4603fe55bb81a2
3
+ metadata.gz: d05f52bfbecf2baf340b02b932f87d13236f94df
4
+ data.tar.gz: 4bf036ef8ae225d28c420ad2a76c8ac8139a7197
5
5
  SHA512:
6
- metadata.gz: 5929709a535cfbf15f7cb9b7c610fd14e5a04faf966b13f564c02820e54a50336b011e234bb01b54a1599e58ba42297ca6f2b06707f55affc34a242c65b80380
7
- data.tar.gz: de899c3b07091d805dca64b28c39f644aa2da96df710cd4998ba22ca2704a367e3bf6c42faad8fbca541a6132b6b5c113a8b406f5bf904feaf1faf3e76873289
6
+ metadata.gz: 714629fe039ca244c0103cbf034836aba4603803d30cac62e4682a7060ee8e3437e36a29d1be5ecea4ab18234cf43c48ddb548187c1391db99130246881a9ddc
7
+ data.tar.gz: 81cc9491489bfa34a9821db150d8284c9eaf956ca1451193ccb667b8e4dd4f9b040447549e6073f1f4e5eac7d2e401ead1bfd47b70c6c0e7d22101d3de623854
@@ -5,6 +5,10 @@ module HaikuGadget
5
5
 
6
6
  class LineTemplate
7
7
 
8
+ # the relative likelyhood that a word with existing syllables is going to be
9
+ # chosen over one that has no syllables (for example, 3 means 3 times as likely)
10
+ EXISTING_SYLLABLES_PRIORITY = 3
11
+
8
12
  attr_reader :word_templates
9
13
 
10
14
  def initialize(*word_templates)
@@ -19,46 +23,6 @@ module HaikuGadget
19
23
  @word_templates.map { |w| w.syllables }.inject(:+)
20
24
  end
21
25
 
22
- def get_valid_word_indices
23
- out = []
24
- @word_templates.each_index do |i|
25
- out << i unless @word_templates[i].word_type.base_symbol == :custom
26
- end
27
- out
28
- end
29
-
30
- def increase_row_syllable
31
- valid_word_indices = get_valid_word_indices
32
-
33
- increase_syllable_index = nil
34
- loop do
35
- increase_syllable_index = increased_row_syllable_index valid_word_indices
36
- break if increase_syllable_index || valid_word_indices.length == 0
37
- end
38
- if increase_syllable_index
39
- @word_templates[increase_syllable_index].syllables += 1
40
- increase_syllable_index
41
- else
42
- nil
43
- end
44
- end
45
-
46
- def increased_row_syllable_index(valid_word_indices)
47
- if valid_word_indices.length > 0
48
- word_index = valid_word_indices.sample
49
- if @word_templates[word_index].word_type.words?(
50
- @word_templates[word_index].syllables + 1,
51
- @word_templates[word_index].plurality
52
- )
53
- word_index
54
- else
55
- # dictionary has no words of this type, remove this index so it isn't checked in the future
56
- valid_word_indices.delete word_index
57
- nil
58
- end
59
- end
60
- end
61
-
62
26
  def complete_syllables(required_syllables)
63
27
  while current_syllables < required_syllables
64
28
  increased_syllable_index = increase_row_syllable
@@ -100,15 +64,83 @@ module HaikuGadget
100
64
  words
101
65
  end
102
66
 
103
- # where necessary, convert 'a' to 'an'
104
- def self.convert_a_to_an(words)
105
- words.each_index do |i|
106
- if words[i] == 'a' && (i < (words.length - 1)) && %w(a e i o u).include?(words[i + 1].slice(0))
107
- # current word is 'a', there are more words after this one, and the next one starts with a, e, i, o or u
108
- words[i] = 'an'
67
+ private
68
+
69
+ def get_valid_word_indices
70
+ out = []
71
+ @word_templates.each_index do |i|
72
+ out << i unless @word_templates[i].word_type.base_symbol == :custom
73
+ end
74
+ out
75
+ end
76
+
77
+
78
+ def increase_row_syllable
79
+ valid_word_indices = get_valid_word_indices
80
+
81
+ increase_syllable_index = nil
82
+ loop do
83
+ increase_syllable_index = increased_row_syllable_index valid_word_indices
84
+ break if increase_syllable_index || valid_word_indices.length == 0
85
+ end
86
+ if increase_syllable_index
87
+ @word_templates[increase_syllable_index].syllables += 1
88
+ increase_syllable_index
89
+ else
90
+ nil
91
+ end
92
+ end
93
+
94
+ def increased_row_syllable_index(valid_word_indices)
95
+ if valid_word_indices.length > 0
96
+ word_index = weighted_sample_index valid_word_indices
97
+ if @word_templates[word_index].word_type.words?(
98
+ @word_templates[word_index].syllables + 1,
99
+ @word_templates[word_index].plurality
100
+ )
101
+ word_index
102
+ else
103
+ # dictionary has no words of this type, remove this index so it isn't checked in the future
104
+ valid_word_indices.delete word_index
105
+ nil
106
+ end
107
+ end
108
+ end
109
+
110
+ # where necessary, convert 'a' to 'an'
111
+ def self.convert_a_to_an(words)
112
+ words.each_index do |i|
113
+ if words[i] == 'a' && (i < (words.length - 1)) && %w(a e i o u).include?(words[i + 1].slice(0))
114
+ # current word is 'a', there are more words after this one, and the next one starts with a, e, i, o or u
115
+ words[i] = 'an'
116
+ end
109
117
  end
110
118
  end
111
- end
119
+
120
+ # give more weight to words that have >0 syllables already,
121
+ # which reduces the number of words per line slightly
122
+ def weighted_sample_index(valid_word_indices)
123
+
124
+ weighted_word_indices(valid_word_indices).sample
125
+
126
+ end
127
+
128
+ def weighted_word_indices(valid_word_indices)
129
+
130
+ out = []
131
+ valid_word_indices.each do |valid_word_index|
132
+ if @word_templates[valid_word_index].syllables > 0
133
+ # weight this word more heavily
134
+ EXISTING_SYLLABLES_PRIORITY.times do
135
+ out << valid_word_index
136
+ end
137
+ else
138
+ out << valid_word_index
139
+ end
140
+ end
141
+ out
142
+
143
+ end
112
144
 
113
145
  end
114
146
 
@@ -25,8 +25,8 @@ module HaikuGadget
25
25
  WordTemplate.new(:noun, 1, :plural)
26
26
  ),
27
27
 
28
+ # mass/abstract noun is adj
28
29
  LineTemplate.new(
29
- # mass/abstract noun is adj
30
30
  WordTemplate.new(:mass_noun_determiner),
31
31
  WordTemplate.new(:adjective, 0, :common),
32
32
  WordTemplate.new(:mass_noun, 1),
@@ -34,8 +34,8 @@ module HaikuGadget
34
34
  WordTemplate.new(:adjective, 1, :any)
35
35
  ),
36
36
 
37
+ # noun(s) of mass/abstract noun acts
37
38
  LineTemplate.new(
38
- # noun(s) of mass/abstract noun acts
39
39
  WordTemplate.new(:determiner, 0, :any, 1),
40
40
  WordTemplate.new(:adjective, 0, :any, 1),
41
41
  WordTemplate.new(:noun, 1, :any, 1),
@@ -44,8 +44,8 @@ module HaikuGadget
44
44
  WordTemplate.new(:verb_self, 1, :any, 1)
45
45
  ),
46
46
 
47
+ # adj noun is adj
47
48
  LineTemplate.new(
48
- # adj noun is adj
49
49
  WordTemplate.new(:adjective, 0, :any, 1),
50
50
  WordTemplate.new(:noun, 1, :any, 1),
51
51
  WordTemplate.new(:to_be, 1, :any, 1),
@@ -1,5 +1,5 @@
1
1
  module HaikuGadget
2
2
 
3
- VERSION = '1.0.6'
3
+ VERSION = '1.0.7'
4
4
 
5
5
  end
@@ -25,10 +25,10 @@
25
25
  ]
26
26
 
27
27
  :adjective_common: [
28
- [red, fresh, weird, burnt, white, flat, round, weak, old, new, young, swell, sweet, dazed, vague, warmed, cool, strong, blue, clear, soft, hard, black, big, small, tight, loose, long, short, wry, young, green, bold, good, bad, kind, mean, wet, dry, free, light, dark, dim, wise, grim, huge, worn, numb, wild, tall, short, hot, cold, sad, gray, green, gold, raw, rich, poor, bored, dull, calm, smart, dumb, grand, keen, bright, bent, foul, close, chrome, low, last, first, next, fun, high, late, quaint, top, lost, cute, real, strict, fast, slow, rough, damp, smooth, clean, great, [north, west, south, east]],
29
- [orange, mental, tired, gloomy, murky, salty, doomed, ecstatic, balanced, frayed, frosted, confused, opened, tasty, frozen, boiling, slimy, failed, crazed, oblong, broken, silver, faulty, limestone, opaque, silly, spinning, busted, lazy, flying, awesome, folded, rhythmic, floating, smoking, twisted, wispy, uncooked, complex, bubbly, immobile, bankrupt, moving, crispy, laundered, rounded, ample, dirty, catered, constrained, cosmic, choking, ballistic, red-faced, bizarre, sanded, roasted, inverted, spastic, dapper, swanky, able, fabled, stable, leaning, correct, staggered, wrong, curved, open, evil, closed, edgy, pricey, costly, fancy, stranded, meager, modest, humble, slimy, simple, unkind, unwound, teenage, heavy, standard, hollow, eager, rotten, unwise, grounded, boring, crazy, major, minor, naive, valid, random, happy, endless, human, splendid, certain, somber, livid, lonely, jealous, dreary, lovely, cheerful, secure, renowned, spicy, drunken, bulky, breaded, better, shorter, smaller, larger, smarter, faster, longer, distant, wealthy, dismayed, vital, colored, abstract, vivid, ancient, bitter, sour, airy, timely, sunny, current, funky, skinny, bloody, girly, boyish, roomy, royal, marine, varied, fuzzy, helpful, crafty, silky, plastic, laser, upper, lower, cloudy, stronger, weaker, bigger, taller, greater, [northern, western, southern, eastern]],
30
- [redundant, respected, uncovered, populous, required, unstable, communist, communal, religious, circular, feminine, masculine, incorrect, underwater, embarrassed, misshapen, glorious, hovering, uncaring, expanded, insulted, discovered, commissioned, considered, opulent, casual, ultimate, imminent, exacting, creative, furious, destructive, modulated, digital, analog, essential, albino, nuclear, atomic, chocolate, overweight, invalid, possible, advertised, natural, terrific, pot-bellied, amazing, confident, exacting, finished, primary, lunatic, satisfied, impressive, lunatic, noteworthy, suitable, musical, eternal, skydiving, expected, parallel],
31
- [undulating, incredible, unforgiving, acceptable, elaborate, necessary, stimulated, measurable, recommended, mandatory, honorable, identical, overstated, altruistic, generated, extraneous, aluminum, obfuscated, appropriate, symbiotic, calculated, mysterious, unknowable, beautiful, contemplative, incapable, overbearing, high quality, low quality, microbial, questionable, knowledgeable, elemental, hilarious, inferior, meticulous]
28
+ [red, fresh, weird, burnt, white, flat, round, weak, old, new, young, swell, sweet, dazed, vague, warmed, cool, strong, blue, clear, soft, hard, black, big, small, tight, loose, long, short, wry, young, green, bold, good, bad, kind, mean, wet, dry, free, light, dark, dim, wise, grim, huge, worn, numb, wild, tall, short, hot, cold, sad, gray, green, gold, raw, rich, poor, bored, dull, calm, smart, dumb, grand, keen, bright, bent, foul, close, chrome, low, last, first, next, fun, high, late, quaint, top, lost, cute, real, strict, fast, slow, rough, damp, smooth, clean, great, quick, swift, slick, nice, fat, punk, right, wrong, curved, doomed, frayed, crazed, closed, [north, west, south, east]],
29
+ [orange, mental, tired, gloomy, murky, salty, balanced, frosted, confused, opened, tasty, frozen, boiling, slimy, failed, oblong, broken, silver, faulty, limestone, opaque, silly, spinning, busted, lazy, flying, awesome, folded, rhythmic, floating, smoking, twisted, wispy, uncooked, complex, bubbly, bankrupt, moving, crispy, laundered, rounded, ample, dirty, catered, constrained, cosmic, choking, bizarre, sanded, roasted, spastic, dapper, swanky, able, fabled, stable, leaning, correct, staggered, open, evil, edgy, pricey, costly, fancy, stranded, meager, modest, humble, slimy, simple, unkind, unwound, teenage, heavy, standard, hollow, eager, rotten, unwise, grounded, boring, crazy, major, minor, naive, valid, random, happy, endless, human, splendid, certain, somber, livid, lonely, jealous, dreary, lovely, cheerful, secure, renowned, spicy, drunken, bulky, breaded, better, shorter, smaller, larger, smarter, faster, longer, distant, wealthy, dismayed, vital, colored, abstract, vivid, ancient, bitter, sour, airy, timely, sunny, current, funky, skinny, bloody, girly, boyish, roomy, royal, marine, varied, fuzzy, helpful, crafty, silky, plastic, laser, upper, lower, cloudy, stronger, weaker, bigger, taller, greater, guilty, finished, [northern, western, southern, eastern]],
30
+ [redundant, ecstatic, respected, uncovered, populous, required, unstable, communist, communal, religious, circular, feminine, masculine, incorrect, embarrassed, misshapen, glorious, hovering, uncaring, expanded, insulted, discovered, commissioned, considered, opulent, casual, ultimate, imminent, exacting, creative, furious, destructive, digital, analog, essential, albino, nuclear, atomic, chocolate, overweight, invalid, possible, advertised, natural, terrific, amazing, confident, exacting, primary, lunatic, satisfied, impressive, noteworthy, suitable, musical, eternal, skydiving, expected, parallel, factual, immobile, ballistic, innocent, inverted, beautiful],
31
+ [undulating, incredible, unforgiving, acceptable, elaborate, necessary, stimulated, simulated, measurable, recommended, mandatory, honorable, identical, overstated, altruistic, generated, extraneous, aluminum, obfuscated, appropriate, symbiotic, calculated, mysterious, unknowable, contemplative, incapable, overbearing, high quality, low quality, microbial, questionable, knowledgeable, elemental, hilarious, inferior, meticulous, underwater, modulated]
32
32
  ]
33
33
  :adjective_singular: [
34
34
  [one]
@@ -40,21 +40,21 @@
40
40
  ]
41
41
 
42
42
  :noun_common: [
43
- [thing, bug, head, toe, eye, phone, web, ball, hand, ear, sheet, bed, car, truck, plane, brain, day, sun, square, bike, lake, creek, stone, moon, shoe, yacht, field, thought, sword, wig, boy, girl, kid, pet, fig, moth, dog, bun, cat, bat, oar, lip, grain, soul, ape, duck, ray, beam, leg, rat, bear, boar, boat, door, goon, gob, plank, brick, stake, cube, ant, cord, bowl, chord, crate, wire, wreath, spear, isle, tree, wheel, hut, hat, gnat, spot, pond, cork, star, tribe, wine, beer, drink, film, bum, cup, rock, hook, path, king, queen, jack, mob, skill, job, cow, chair, disk, pit, hole, card, hill, mound, knob, zoo, light, fool, pill, quark, cloud, glove, sock, boot, slave, shrub, cook, pie, bird, snake, worm, tank, pen, weed, flute, nest, pot, bee, pan, gem, mom, dad, son, jeep, train, nun, pal, month, year, week, shark, yak, joke, owl, skunk, worm, egg, cake, pea, grape, bean, spore, seed, fruit, wing, fire, world, heart, rod, board, nail, end, ring, sea, key, god, word, night, knight, bone, room, toy, side, top, book, name, game, ship, test, park, time, bag, school, clone, shop, store, war, whale, frog, trail, mind, task],
44
- [zombie, ninja, pirate, monkey, robot, hot dog, space ship, rain drop, circle, tv, flower, typhoon, garden, cookie, taco, gyro, mountain, painting, river, meadow, island, morsel, marble, mitten, trombone, nugget, chicken, donkey, llama, hamster, raisin, nation, rocket, bottle, anvil, sunset, muskrat, treasure, coastline, building, concept, forest, python, dinner, hammer, robber, jacket, singer, puppet, valley, comet, scooter, joker, pebble, kayak, airplane, table, atom, movie, poster, fountain, missile, pimple, player, shovel, window, rooster, biscuit, raven, eagle, question, vampire, peon, otter, camel, suburb, towel, turkey, pencil, planet, viking, squirrel, snowboard, dweller, lemon, photo, item, skillet, mother, father, brother, sister, elder, aardvark, apple, object, pickle, staple, wizard, raccoon, tadpole, spigot, daughter, mantra, pizza, calzone, vision, haiku, pixel, onion, glacier, penguin, cobra, dolphin, spider, trumpet, donut, ion, aura, geezer, freedom, attempt, pigeon, teacher, battle, laser, poem, [sunday, monday, tuesday, wednesday, thursday, friday, saturday]],
45
- [spatula, tornado, hurricane, restaurant, computer, radio, stereo, commuter, newspaper, hairdryer, photograph, sombrero, burrito, telephone, animal, bicycle, dinosaur, iguana, kangaroo, umbrella, hiking boot, dishwasher, asteroid, meteor, cruise liner, oil tanker, apple pie, gorilla, tricycle, artichoke, musician, visitor, disaster, piano, canteloupe, pyramid, article, location, banana],
43
+ [thing, bug, head, toe, eye, phone, web, ball, hand, ear, sheet, bed, car, truck, plane, brain, day, sun, square, bike, lake, creek, stone, moon, shoe, yacht, field, thought, sword, wig, boy, girl, kid, pet, fig, moth, dog, bun, cat, bat, oar, lip, grain, soul, ape, duck, ray, beam, leg, rat, bear, boar, boat, door, goon, gob, plank, brick, stake, cube, ant, cord, bowl, chord, crate, wire, wreath, spear, isle, tree, wheel, hut, hat, gnat, spot, pond, cork, star, tribe, wine, beer, drink, film, bum, cup, rock, hook, path, king, queen, jack, mob, skill, job, cow, chair, disk, pit, hole, card, hill, mound, knob, zoo, light, fool, pill, quark, cloud, glove, sock, boot, slave, shrub, cook, pie, bird, snake, worm, tank, pen, weed, flute, nest, pot, bee, pan, gem, mom, dad, son, jeep, train, nun, pal, month, year, week, shark, yak, joke, owl, skunk, worm, egg, cake, pea, grape, bean, spore, seed, fruit, wing, fire, world, heart, rod, board, nail, end, ring, sea, key, god, word, night, knight, bone, room, toy, side, top, book, name, game, ship, test, park, time, bag, school, clone, shop, store, war, whale, frog, trail, mind, task, hour, smile, mile, punk, pawn, sound, flame, way, state, sphere, globe, group, part, case, point, home, fact],
44
+ [zombie, ninja, pirate, monkey, robot, hot dog, space ship, rain drop, circle, tv, flower, typhoon, garden, cookie, taco, gyro, mountain, painting, river, meadow, island, morsel, marble, mitten, trombone, nugget, chicken, donkey, llama, hamster, raisin, nation, rocket, bottle, anvil, sunset, muskrat, treasure, coastline, building, concept, forest, python, dinner, hammer, robber, jacket, singer, puppet, valley, comet, scooter, joker, pebble, kayak, airplane, table, atom, movie, poster, fountain, missile, pimple, player, shovel, window, rooster, biscuit, raven, eagle, question, vampire, peon, otter, camel, suburb, towel, turkey, pencil, planet, viking, squirrel, snowboard, dweller, lemon, photo, item, skillet, mother, father, brother, sister, elder, aardvark, apple, object, pickle, staple, wizard, raccoon, tadpole, spigot, daughter, mantra, pizza, calzone, vision, haiku, pixel, onion, glacier, penguin, cobra, dolphin, spider, trumpet, donut, ion, aura, geezer, freedom, attempt, pigeon, teacher, battle, laser, poem, minute, temple, jackpot, issue, statement, student, problem, system, program, number, dollar, orbit, [sunday, monday, tuesday, wednesday, thursday, friday, saturday]],
45
+ [spatula, tornado, hurricane, restaurant, computer, radio, stereo, commuter, newspaper, hairdryer, photograph, sombrero, burrito, telephone, animal, bicycle, dinosaur, iguana, kangaroo, umbrella, hiking boot, dishwasher, asteroid, meteor, cruise liner, oil tanker, apple pie, gorilla, tricycle, artichoke, musician, visitor, disaster, piano, canteloupe, pyramid, article, location, banana, hemisphere, area],
46
46
  [fortune cookie, ecosystem, obligation, generator, generation, ambassador, elevator, watermelon, convertible, calculator, harmonica, operation, invitation, kindergarten, helicopter, alligator, caterpillar, constellation, germination, politician, corporation, advertisement, declaration, astronomer, variation, perimeter, population, semicircle, operator, aquarium, disappointment, kaleidoscope, television, orangutan, washing machine, environment]
47
47
  ]
48
48
  :noun_singular: [
49
- [fish, man, child, box, sky, beach, sheep, church, mouse, fox, goose, wish, life, foot, face, prince, house],
50
- [hobby, woman, baby, country, princess, person, hero, werewolf, message, lighthouse],
51
- [enemy, remedy, nebula, library, factory, mosquito, buffalo, potato, samurai, universe],
49
+ [fish, man, child, box, sky, beach, sheep, church, mouse, fox, goose, wish, life, foot, face, prince, house, torch, place],
50
+ [hobby, woman, baby, country, princess, person, hero, werewolf, message, lighthouse, party],
51
+ [enemy, remedy, nebula, library, factory, mosquito, buffalo, potato, samurai, universe, family, company],
52
52
  [bacteria, reality, discovery, super hero, territory, deficiency, activity, calamity, emergency]
53
53
  ]
54
54
  :noun_plural: [
55
55
  [fish, men, skies, sheep, mice, geese, lives, feet],
56
- [women, children, babies, countries, cities, boxes, cattle, people, grizzlies, heroes, foxes, beaches, churches, wishes, werewolves, faces, princes, houses],
57
- [enemies, hobbies, remedies, libraries, factories, potatoes, mosquitoes, buffaloes, princesses, messages, lighthouses, samurai],
56
+ [women, children, babies, countries, cities, boxes, cattle, people, grizzlies, heroes, foxes, beaches, churches, wishes, werewolves, faces, princes, houses, torches, parties, places],
57
+ [enemies, hobbies, remedies, libraries, factories, potatoes, mosquitoes, buffaloes, princesses, messages, lighthouses, samurai, families, companies],
58
58
  [bacteria, realities, discoveries, super heroes, territories, activities, calamities, emergencies, universes]
59
59
  ]
60
60
 
@@ -63,46 +63,46 @@
63
63
  ]
64
64
 
65
65
  :mass_noun: [
66
- [fun, love, snow, funk, earth, space, home, dust, pain, life, health, death, loss, thought, beer, wine, dirt, fire, flame, style, lore, wind, force, fog, haze, time, war, peace, doom, food, art, gloom, hope, ice, oil, gold, light, cheese, grass, breath, steel, iron, stone, zen, stuff, hair, soup, sense, air, gas, ground, foam, glass, wealth, slime, cloth, tea, juice, fruit, jazz, heat, speed, glue, noise, wood, milk, cake, rice, work, grief, fish, lust, sleep, heart, night, skin, blood, sand, math, rain, youth, lore, grace, corn, bread, glee, mist, jive, help, trash, cream, silk],
66
+ [fun, love, snow, funk, earth, space, dust, pain, life, health, death, loss, thought, beer, wine, dirt, fire, flame, style, lore, wind, force, fog, haze, time, war, peace, doom, food, art, gloom, hope, ice, oil, gold, light, cheese, grass, breath, steel, iron, stone, zen, stuff, hair, soup, sense, air, gas, ground, foam, glass, wealth, slime, cloth, tea, juice, fruit, jazz, heat, speed, glue, noise, wood, milk, cake, rice, work, grief, fish, lust, sleep, heart, night, skin, blood, sand, math, rain, youth, lore, grace, corn, bread, glee, mist, jive, help, trash, cream, silk, land, guilt],
67
67
  [metal, essence, power, magic, evil, peril, disease, vapor, butter, sugar, darkness, fortune, soda, success, failure, water, passion, wonder, beauty, reason, fabric, lava, jello, ketchup, coffee, jelly, ice cream, sadness, goodness, physics, money, ethics, traffic, plastic, dancing, anger, danger, softness, friendship, trouble, culture, virtue, fuel, music, freedom, cornbread, lightning, sorrow, mustard, fluid, liquid, knowledge, silver, plasma],
68
68
  [happiness, gravity, desire, misfortune, pestilence, certainty, mystery, energy, chocolate, honesty, poverty, laziness, chemistry, furniture, equipment, violence, liberty, jealousy, gelato, intention, religion, cookie dough, atmosphere],
69
69
  [society, community, contemplation, inconvenience, humanity, morality, information, intelligence, stupidity, geometry]
70
70
  ]
71
71
 
72
72
  :verb_common: [
73
- [bloom, drain, pat, climb, bend, give, take, pour, yank, clip, spread, build, shape, hate, throw, find, hear, see, smell, taste, eat, like, wake, tempt, smack, fold, farm, sip, lure, rip, rock, poke, warm, pull, grab, shove, pet, cut, get, bang, bust, bet, trick, lick, steal, boil, toast, dunk, gulp, meet, dig, form, roll, bathe, trap, treat, feed, hack, kick, heal, blast, lift, draw, cook, shake, bring, see, want, need, feel, love, hug, break, make, shock, paint, gain, kill, fund, hire, read, bake, own, rob, herd, rent, move, pay, jab, stop, start, turn, tear, fire, eye, scare, ask, win, make, ship, test, ride, clone, train, drive, know, buy, store, save, help, clean],
74
- [consume, destroy, attack, nurture, explore, open, construct, befriend, explain, target, retain, prevent, protest, direct, procure, locate, staple, strangle, topple, avoid, reveal, survey, maintain, fasten, harden, straighten, offer, transform, tickle, question, deceive, mislead, support, become, revive, connect, iron, annoy, forget, handle, answer, inspect, behold, design, acquire, obtain, believe, dazzle, honor, master, gather, savor, adjust, expect, create, instruct, afford, succeed, battle],
75
- [imagine, examine, interrupt, activate, agitate, animate, apprehend, calibrate, captivate, celebrate, complicate, decimate, decipher, dishonor, dominate, enliven, generate, jettison, isolate, medicate, nominate, orient, overwhelm, recycle, terminate, violate, discover, calculate]
73
+ [get, drain, pat, climb, bend, give, take, pour, yank, clip, spread, build, shape, hate, throw, find, hear, see, smell, taste, eat, like, wake, tempt, smack, fold, farm, sip, lure, rip, rock, poke, warm, pull, grab, shove, pet, cut, get, bang, bust, bet, trick, lick, steal, boil, toast, dunk, gulp, meet, dig, form, roll, bathe, trap, treat, feed, hack, kick, heal, blast, lift, draw, cook, shake, bring, see, want, need, feel, love, hug, break, make, shock, paint, gain, kill, fund, hire, read, bake, own, rob, herd, rent, move, pay, jab, stop, start, turn, tear, fire, eye, scare, ask, win, make, ship, test, ride, clone, train, drive, know, buy, store, save, help, clean, spin, keep, thank, tell, call, leave, lead, spend, serve, send, sell, hit],
74
+ [consume, destroy, attack, nurture, explore, open, construct, befriend, explain, target, retain, prevent, protest, direct, procure, locate, staple, strangle, topple, avoid, reveal, survey, maintain, fasten, harden, straighten, offer, transform, tickle, question, deceive, mislead, support, become, revive, connect, iron, annoy, forget, handle, answer, inspect, behold, design, acquire, obtain, believe, dazzle, honor, master, gather, savor, adjust, expect, create, instruct, afford, succeed, battle, launder, include, exclude, follow, return, receive, cover, program, orbit],
75
+ [imagine, examine, interrupt, activate, agitate, animate, apprehend, calibrate, captivate, celebrate, complicate, decimate, decipher, dishonor, dominate, enliven, generate, jettison, isolate, medicate, nominate, orient, overwhelm, recycle, terminate, violate, discover, calculate, estimate, understand, remember, consider, develop, simulate]
76
76
  ]
77
77
  :verb_singular: [
78
- [soothes],
79
- [eases, nudges, uses, raises, slices, falls on, dreams of, jumps over, looks at, looks for, studies, tosses, touches, coaxes, pushes, reaches, punches, cares for, ties up, sticks to, goes to, swarms on, flails at, cooks for, kisses, smooches, speaks to, quests for, raves about, sits on, waves to, shines on, mixes, watches, copies, marries, senses, closes, sings to, smiles at, asks for, hopes for, toys with, plays with, floats on, lives on, lives with, steps on, jives with, hops on, washes, sounds like],
80
- [amazes, cares about, notifies, objects to, condenses, beautifies, glorifies, liquefies, nullifies, occupies, purifies, satisfies, stupefies, wishes for, thinks about, writes about]
78
+ [has, soothes],
79
+ [eases, nudges, uses, raises, slices, falls on, dreams of, jumps over, looks at, looks for, studies, tosses, touches, coaxes, pushes, reaches, punches, cares for, ties up, sticks to, goes to, swarms on, flails at, cooks for, kisses, smooches, speaks to, quests for, raves about, sits on, waves to, shines on, mixes, watches, copies, marries, senses, closes, sings to, smiles at, asks for, hopes for, toys with, plays with, floats on, lives on, lives with, steps on, jives with, hops on, washes, sounds like, catches, dwells on, puts on, changes, walks to, walks with, passes, carries, chooses, works on, works for],
80
+ [amazes, cares about, notifies, objects to, condenses, beautifies, glorifies, liquefies, nullifies, occupies, purifies, satisfies, stupefies, wishes for, thinks about, writes about, challenges, agrees with, produces, replaces]
81
81
  ]
82
82
  :verb_plural: [
83
- [ease, nudge, use, raise, slice, study, toss, touch, coax, push, reach, punch, kiss, smooch, mix, watch, sense, soothe, close, wash],
84
- [copy, amaze, fall on, dream of, jump over, look at, look for, finish, care for, approach, tie up, stick to, go to, swarm on, flail at, cook for, dance with, dance for, speak to, quest for, rave about, sit on, wave to, shine on, condense, marry, advise, sing to, smile at, ask for, hope for, wish for, toy with, play with, think about, float on, live on, live with, step on, jive with, hop on, sound like],
85
- [care about, notify, object to, beautify, glorify, liquefy, nullify, occupy, purify, satisfy, stupefy, vandalize, vaporize, minimize, maximize, encourage, equalize, pulverize, write about]
83
+ [have, ease, nudge, use, raise, slice, study, toss, touch, coax, push, reach, punch, kiss, smooch, mix, watch, sense, soothe, close, wash, catch, change, pass, choose],
84
+ [copy, amaze, fall on, dream of, jump over, look at, look for, finish, care for, approach, tie up, stick to, go to, swarm on, flail at, cook for, dance with, dance for, speak to, quest for, rave about, sit on, wave to, shine on, condense, marry, advise, sing to, smile at, ask for, hope for, wish for, toy with, play with, think about, float on, live on, live with, step on, jive with, hop on, sound like, challenge, dwell on, put on, walk to, walk with, carry, produce, replace, work on, work for],
85
+ [care about, notify, object to, beautify, glorify, liquefy, nullify, occupy, purify, satisfy, stupefy, vandalize, vaporize, minimize, maximize, encourage, equalize, pulverize, write about, agree with]
86
86
  ]
87
87
 
88
88
  :verb_self_common: [
89
- [wake, jump, speed, climb, live, hope, fail, float, fall, slow, creep, sleep, groan, moan, coast, suck, walk, run, wait, think, land, scream, crawl, play, smile, glow, wave, dream, yell, work, feel, nap, quake, whine, trek, learn, weep, sob, speak, hide, pose, laugh, bathe, burn, grow, shrink, feast, warn, stray, peek, creak, flow, come, feed, cope, heal, race, read, dig, dwell, move, pray, gawk, breed, sag, spit, stand, stop, swerve, eat, lust, shine, end, bleed, drop, open, shake, start, fart, tear, turn, sail, sing, ask, sin, point, ail, flail, fold, die, smell, groove, shout, lie, dine, win, write, train, drive, know, jive, hop, shop, paint, drink, bend, spread, sulk, wail, tire, clean],
90
- [survive, ponder, wonder, travel, transform, falter, wallow, improve, believe, boogie, crumble, giggle, complain, forget, persist, explore, exist, arrive, await, agree, connect, engage, haggle, return, rotate, resist, dabble, murmur, mature, protest, gossip, growl, begin, approve, clamber, attack, perform, abide, achieve, succeed, explode, constrict, topple, dazzle, question],
91
- [concentrate, speculate, hesitate, meditate, calculate, celebrate, co-exist, consider, continue, deviate, disagree, disbelieve, disconnect, elevate, imagine, meander, navigate, overact, postulate, propagate, radiate, recover, replicate, duplicate, surrender, terminate, understand, undulate, hibernate, self-destruct]
89
+ [wake, jump, speed, climb, live, hope, fail, float, fall, slow, creep, sleep, groan, moan, coast, suck, walk, run, wait, think, land, scream, crawl, play, smile, glow, wave, dream, yell, work, feel, nap, quake, whine, trek, learn, weep, sob, speak, hide, pose, laugh, bathe, burn, grow, shrink, feast, warn, stray, peek, creak, flow, come, feed, cope, heal, race, read, dig, dwell, move, pray, gawk, breed, sag, spit, stand, stop, swerve, eat, lust, shine, end, bleed, drop, open, shake, start, fart, tear, turn, sail, sing, ask, sin, point, ail, flail, fold, die, smell, groove, shout, lie, dine, win, write, train, drive, know, jive, hop, shop, paint, drink, bend, spread, sulk, wail, tire, clean, bloom, sweep, spin, trek, leave, hear, sit, leave, serve, stay, break, draw, zoom],
90
+ [survive, ponder, wonder, travel, transform, falter, wallow, improve, believe, boogie, crumble, giggle, complain, forget, persist, explore, exist, arrive, await, agree, connect, engage, haggle, return, rotate, resist, dabble, murmur, mature, protest, gossip, growl, begin, approve, clamber, attack, perform, abide, achieve, succeed, explode, constrict, topple, dazzle, question, struggle, evolve, happen, appear, decide, explain, program, orbit],
91
+ [concentrate, speculate, hesitate, meditate, calculate, celebrate, co-exist, consider, continue, deviate, disagree, disbelieve, disconnect, elevate, imagine, meander, navigate, overact, postulate, propagate, radiate, recover, replicate, duplicate, surrender, terminate, understand, undulate, hibernate, self-destruct, oscillate, remember, develop]
92
92
  ]
93
93
  :verb_self_singular: [
94
- [goes, flies, cries],
95
- [sits down, lies down, wakes up, freezes, bounces, replies, responds, gazes, loses, rises, rushes, marches, pauses, crashes, watches, dances, rages, rushes, breaks up, thrashes],
96
- [simplifies, testifies, relaxes, approaches, emerges]
94
+ [goes, flies, cries, tries],
95
+ [sits down, lies down, wakes up, freezes, bounces, replies, responds, gazes, loses, rises, rushes, marches, pauses, crashes, watches, dances, rages, rushes, breaks up, thrashes, changes, reaches, gets up, get down],
96
+ [simplifies, testifies, relaxes, approaches, emerges, raises up]
97
97
  ]
98
98
  :verb_self_plural: [
99
- [go, fly, cry, freeze, gaze, lose, rise, rush, march, pause, crash, watch, dance, rage, rush, thrash],
100
- [sit down, lie down, wake up, approach, reply, respond, relax, collapse, break up, emerge],
99
+ [go, fly, cry, try, freeze, gaze, lose, rise, rush, march, pause, crash, watch, dance, rage, rush, thrash, change, reach],
100
+ [sit down, lie down, wake up, approach, reply, respond, relax, collapse, break up, emerge, raise up, get up, get down],
101
101
  [simplify, stabilize, testify]
102
102
  ]
103
103
 
104
104
  :adverb: [
105
- [great, well, good, bad, fast, slow, up, down, soon, now, nice, left, right, wrong, some, near, far, hard, soft],
105
+ [so, well, good, bad, fast, slow, up, down, soon, now, nice, left, right, wrong, some, near, far, hard, soft],
106
106
  [always, badly, blindly, boldly, bravely, brightly, clearly, deftly, kindly, loosely, madly, never, oddly, often, only, poorly, sadly, promptly, quickly, rarely, really, rudely, safely, seldom, slowly, sometimes, warmly, yearly],
107
107
  [angrily, anxiously, awkwardly, boastfully, cheerfully, crazily, doubtfully, eagerly, evenly, exactly, finally, foolishly, frantically, frequently, gleefully, gracefully, happily, hastily, honestly, hourly, hungrily, jealously, lazily, perfectly, politely, rapidly, tenderly, totally, weekly, wildly, royally]
108
108
  ]
@@ -69,6 +69,66 @@ module HaikuGadget
69
69
 
70
70
  end
71
71
 
72
+ describe 'with basic line template' do
73
+
74
+ line_template = LineTemplate.new(
75
+ WordTemplate.new(:adjective, 0, :any, 1),
76
+ WordTemplate.new(:noun, 1, :any, 1),
77
+ WordTemplate.new(:verb_self, 1, :any, 1)
78
+ )
79
+
80
+ expected_dist_length = LineTemplate::EXISTING_SYLLABLES_PRIORITY * 2 + 1
81
+
82
+ it 'should give the correct weighted word index distribution' do
83
+
84
+ # word templates that start with 0 syllables are less likely to be
85
+ # selected for adding syllables (prefer fewer words per line)
86
+ weighted_word_indices = line_template.clone.send :weighted_word_indices, [0, 1, 2]
87
+
88
+ expect(weighted_word_indices.length).to be expected_dist_length
89
+
90
+ # index 0 should be in there once
91
+ expect(weighted_word_indices.select { |n| n == 0 }.length).to eq 1
92
+ # and indeices 1 and 2 should each be in there LineTemplate::EXISTING_SYLLABLES_PRIORITY times
93
+ expect(weighted_word_indices.select { |n| n == 1 }.length).to eq LineTemplate::EXISTING_SYLLABLES_PRIORITY
94
+ expect(weighted_word_indices.select { |n| n == 2 }.length).to eq LineTemplate::EXISTING_SYLLABLES_PRIORITY
95
+
96
+ end
97
+
98
+ it 'should statistically favor existing syllable words' do
99
+ # test the actual results of the resulting weighted indexes
100
+ word_indices = []
101
+ 10000.times do
102
+ curr_line_template = line_template.clone
103
+ word_indices << curr_line_template.send(:weighted_sample_index, [0, 1, 2])
104
+ end
105
+
106
+ word_index_counts = []
107
+ 3.times do |i|
108
+ word_index_counts[i] = word_indices.select { |n| n == i }.length
109
+ end
110
+
111
+ expected_percs = []
112
+ expected_percs[0] = (1 / expected_dist_length.to_f) * 100
113
+ expected_percs[1] = (LineTemplate::EXISTING_SYLLABLES_PRIORITY / expected_dist_length.to_f) * 100
114
+ expected_percs[2] = (LineTemplate::EXISTING_SYLLABLES_PRIORITY / expected_dist_length.to_f) * 100
115
+
116
+ threshold_perc = 3
117
+
118
+ 3.times do |i|
119
+ actual_perc = (word_index_counts[i] / word_indices.length.to_f) * 100
120
+ puts "stats for word index #{i} -- expected: #{expected_percs[i]}%, actual: #{actual_perc}%"
121
+
122
+ low_perc = expected_percs[i] - threshold_perc
123
+ high_perc = expected_percs[i] + threshold_perc
124
+ allowed_range = (low_perc...high_perc)
125
+ expect(allowed_range).to include actual_perc
126
+ end
127
+
128
+ end
129
+
130
+ end
131
+
72
132
  describe 'with single possibility test dictionary' do
73
133
  # these tests use a yaml file in which the randomness is removed because
74
134
  # there is only one word of each type in the dictionary
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haiku_gadget
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Balay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-01 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,6 @@ files:
66
66
  - README.md
67
67
  - Rakefile
68
68
  - haiku_gadget.gemspec
69
- - lib/assets/.keep
70
69
  - lib/haiku_gadget.rb
71
70
  - lib/haiku_gadget/dictionary.rb
72
71
  - lib/haiku_gadget/haiku_gadget.rb
@@ -76,7 +75,6 @@ files:
76
75
  - lib/haiku_gadget/version.rb
77
76
  - lib/haiku_gadget/word_template.rb
78
77
  - lib/haiku_gadget/word_type.rb
79
- - lib/tasks/.keep
80
78
  - lib/words.yml
81
79
  - spec/haiku_gadget/haiku_gadget_spec.rb
82
80
  - spec/rails_helper.rb
File without changes
File without changes