random-words 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb7dd16845d6ce75d9f10a8e5005636cf13e4060965273bf305ce34980975d95
4
- data.tar.gz: ff992ec57cc8cddcad1fa016a25929ecbc5c4d124601e6873f9f5e634c503be3
3
+ metadata.gz: d01d64360e59eadf8e0578b1ef16d48d40a2eac57184071c45383e3133387f0e
4
+ data.tar.gz: 33b2fa7b4351254109916d6b5fb313d9e269a891481c172c417b0e333bd7db34
5
5
  SHA512:
6
- metadata.gz: ac1670432a510e98b3b91bca1fdcc0eb7aefa58a9d0b98b50e28a8e0d4848e93866fcc9b2f9e7c6347a66ef4bb579904db3bc71424be9baf47fcda64c4375543
7
- data.tar.gz: 61b5b0d50ca33fe03da311c69e63f318fb0585c35cb6b3a39185a3c4c149b63f2c92d5ccaecd83db86b669cb7ac3693d50e0fd596ff09fbd095ad5e526857059
6
+ metadata.gz: 0b707d9517be318b909f9106d14e22bda99789c08918ddaa0a14214a4dded82719285e15b37c413c71d28bec4ea3cff3650f227abe6bd2c5f1110b3afc3bb4bd
7
+ data.tar.gz: 00cdb6e05557682584a0ec4e5b8ed31b9b527fe8f905fbd481b2b137622c8f3a3651d2628f8ea0bbc799f8aa98ce0dc37e635bb544df9847ae9d3feeb8cbb614
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 1.0.18
2
+
3
+ 2025-05-28 07:16
4
+
5
+ #### IMPROVED
6
+
7
+ - More templates for sentence structure variety
8
+
9
+ #### FIXED
10
+
11
+ - Just remove a/an from articles to avoid article disagreement
12
+ - Remove m-dash from separators as it was causing a double-space bug
13
+
1
14
  ### 1.0.17
2
15
 
3
16
  2025-05-24 10:47
@@ -39,6 +39,58 @@ module RandomWords
39
39
  # These parts will be used to generate random sentences and character strings
40
40
  SENTENCE_PARTS = %w[random_article random_adjective random_noun random_adverb random_verb random_adjective
41
41
  random_verb random_adverb random_phrase].freeze
42
+ TEMPLATES = [
43
+ # Simple declarative
44
+ %i[random_article random_adjective random_noun random_verb],
45
+ %i[random_plural_article random_adjective random_plural_noun random_plural_verb],
46
+
47
+ # With adverb
48
+ %i[random_article random_adjective random_noun random_adverb random_verb],
49
+ %i[random_name random_adverb random_verb],
50
+
51
+ # Passive voice
52
+ %i[random_article random_noun random_passive_verb random_preposition random_article random_noun],
53
+
54
+ # With prepositional phrase
55
+ %i[random_article random_adjective random_noun random_verb random_preposition random_article random_noun],
56
+
57
+ # Compound sentence
58
+ %i[random_article random_noun random_verb random_coordinating_conjunction random_article random_noun random_verb],
59
+
60
+ # Subordinate clause
61
+ %i[random_clause random_article random_noun random_verb],
62
+
63
+ # With phrase
64
+ %i[random_phrase],
65
+
66
+ # Name as subject
67
+ %i[random_name random_verb random_article random_noun],
68
+
69
+ # Plural with adverb and preposition
70
+ %i[random_plural_article random_plural_noun random_adverb random_plural_verb random_preposition random_article random_noun],
71
+
72
+ # Coordinating conjunction joining two clauses
73
+ %i[random_article random_noun random_verb random_coordinating_conjunction random_plural_article random_plural_noun random_plural_verb
74
+ random_phrase],
75
+
76
+ # Subordinate conjunction
77
+ %i[random_subordinate_conjunction random_article random_noun random_verb random_article random_noun random_verb],
78
+
79
+ # With random_adjective and random_adverb in various places
80
+ %i[random_adverb random_article random_adjective random_noun random_verb],
81
+ %i[random_article random_noun random_verb random_adverb],
82
+
83
+ # Name with phrase
84
+ %i[random_name random_verb random_phrase],
85
+
86
+ # Plural passive
87
+ %i[random_plural_article random_plural_noun random_passive_verb random_preposition random_article random_noun],
88
+
89
+ # Name with subordinate clause
90
+ %i[random_name random_verb random_subordinate_conjunction random_article random_noun random_verb]
91
+ ].freeze
92
+
93
+ OPTIONAL_PARTS = %i[adjectives adverbs].freeze
42
94
 
43
95
  # Initialize the generator with a source and options
44
96
  # @param source [Symbol] The source of the words (e.g., :english)
@@ -649,13 +701,14 @@ module RandomWords
649
701
 
650
702
  # Generate a random set of separators
651
703
  def random_separators
652
- [',', ',', ',', ';', ':', ' —']
704
+ [',', ',', ',', ';', ':']
653
705
  end
654
706
 
655
707
  # Generate a random separator
656
708
  # @return [String] A randomly selected separator
657
709
  def random_separator
658
- "#{dbg('SEP')}#{random_separators.sample}"
710
+ sep = random_separators.sample
711
+ "#{dbg('SEP')}#{sep}"
659
712
  end
660
713
 
661
714
  # Generate a random subordinate conjunction
@@ -726,18 +779,16 @@ module RandomWords
726
779
  "#{random_number_with_plural} #{random_adverb} #{random_plural_verb}"
727
780
  when 4..5
728
781
  random_name
729
- when 6..7
730
- noun = random_noun
731
- "#{random_adverb}, #{random_article_for_word(noun)} #{noun} #{random_verb}"
782
+ when 6
783
+ "#{random_adverb}, #{random_article_for_word(random_noun)} #{random_noun} #{random_verb}"
732
784
  else
733
- noun = random_noun
734
- adjective = random_adjective
735
- "#{random_article_for_word(adjective)} #{adjective} #{noun} #{random_adverb} #{random_verb}"
785
+ TEMPLATES.sample.map { |part| send(part.to_sym) }.join(' ')
736
786
  end
737
787
  tail = roll(50) ? " #{random_prepositional_phrase}" : ''
738
788
  separator = random_separator
789
+
739
790
  tail += roll(10) ? "#{separator} #{random_clause}" : ''
740
- "#{beginning.strip.sub(/[#{Regexp.escape(separator)}]*$/, separator)}#{tail}"
791
+ "#{beginning.strip.sub(/([#{Regexp.escape(separator)}]|#{Regexp.escape(separator)})*$/, separator)}#{tail}"
741
792
  end
742
793
 
743
794
  # Simplified generate_additional_clauses
@@ -1,4 +1,4 @@
1
1
  module RandomWords
2
2
  # The version of the RandomWords gem.
3
- VERSION = '1.0.17'
3
+ VERSION = '1.0.18'
4
4
  end
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
@@ -1,5 +1,3 @@
1
- a
2
- an
3
1
  the
4
2
  each
5
3
  every
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: random-words
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra