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 +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/random-words/generator.rb +60 -9
- data/lib/random-words/version.rb +1 -1
- data/lib/random-words/words/1984/articles-singular.txt +0 -2
- data/lib/random-words/words/alice/articles-singular.txt +0 -2
- data/lib/random-words/words/bacon/articles-singular.txt +0 -2
- data/lib/random-words/words/corporate/articles-singular.txt +0 -2
- data/lib/random-words/words/doctor/articles-singular.txt +0 -2
- data/lib/random-words/words/english/articles-singular.txt +0 -2
- data/lib/random-words/words/foulmouth/articles-singular.txt +0 -2
- data/lib/random-words/words/hipster/articles-singular.txt +0 -2
- data/lib/random-words/words/veggie/articles-singular.txt +0 -2
- data/lib/random-words/words/walken/articles-singular.txt +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d01d64360e59eadf8e0578b1ef16d48d40a2eac57184071c45383e3133387f0e
|
4
|
+
data.tar.gz: 33b2fa7b4351254109916d6b5fb313d9e269a891481c172c417b0e333bd7db34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
730
|
-
|
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
|
-
|
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
|
data/lib/random-words/version.rb
CHANGED