ruby_rhymes 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -10
- data/doc/Phrase.html +641 -0
- data/doc/Phrase/Pronunciation.html +632 -0
- data/doc/Phrase/Pronunciations.html +559 -0
- data/doc/String.html +178 -0
- data/doc/_index.html +133 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +320 -0
- data/doc/file.README.html +150 -0
- data/doc/file_list.html +49 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +146 -20
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +150 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +182 -0
- data/doc/top-level-namespace.html +103 -0
- data/lib/ruby_rhymes.rb +14 -3
- metadata +21 -5
- data/README.rdoc +0 -1
data/lib/ruby_rhymes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# RubyRhymes is meant to facilitate the creation of automated poetry
|
2
|
-
# Authors:: Vlad Shulman (vshulman@github) and Thomas
|
2
|
+
# Authors:: Vlad Shulman (vshulman@github) and Thomas Kielbus (thomas-kielbus@github)
|
3
3
|
# License:: Distributes under the same terms as Ruby
|
4
4
|
|
5
5
|
# this class is the gateway to generating exciting poetry. Use it like this:
|
@@ -11,9 +11,11 @@
|
|
11
11
|
# => 6
|
12
12
|
|
13
13
|
class Phrase
|
14
|
+
attr_accessor :phrase
|
14
15
|
def initialize(phrase)
|
15
16
|
@phrase_tokens = Phrase.clean_and_tokenize(phrase)
|
16
|
-
|
17
|
+
raise "Not a valid phrase" if @phrase_tokens.empty?
|
18
|
+
@phrase = phrase
|
17
19
|
# [[p1a,p1b],[p2],p3]
|
18
20
|
@pronunciations = @phrase_tokens.map{|pt| Pronunciations.get_pronunciations(pt)} #pronunciation objects
|
19
21
|
@last_word_pronunciation = @pronunciations.last
|
@@ -50,6 +52,15 @@ class Phrase
|
|
50
52
|
rhymes.empty? ? [] : @rhymes.values.flatten
|
51
53
|
end
|
52
54
|
|
55
|
+
# returns the last word in the phrase (the one used for rhyming)
|
56
|
+
def last_word
|
57
|
+
@last_word_pronunciation.first.word.downcase
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_s
|
61
|
+
@phrase
|
62
|
+
end
|
63
|
+
|
53
64
|
private
|
54
65
|
|
55
66
|
# lazy loading action
|
@@ -65,7 +76,7 @@ class Phrase
|
|
65
76
|
|
66
77
|
# we upcase because our dictionary files are upcased
|
67
78
|
def self.clean_and_tokenize(phrase)
|
68
|
-
phrase.upcase.gsub(/[^A-Z ]/,"").split
|
79
|
+
phrase.upcase.gsub(/[^A-Z ']/,"").split
|
69
80
|
end
|
70
81
|
|
71
82
|
# Pronunciations does the heavy lifting, interfacing with the mythical text file of doom
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_rhymes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vlad Shulman
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-11-29 00:00:00 Z
|
20
20
|
dependencies: []
|
21
21
|
|
22
22
|
description: A gem for rhyming words and counting syllables on phrases
|
@@ -33,6 +33,8 @@ files:
|
|
33
33
|
- lib/ruby_rhymes.rb
|
34
34
|
- lib/syllable_arrays.rb
|
35
35
|
- lib/words.txt
|
36
|
+
- doc/_index.html
|
37
|
+
- doc/class_list.html
|
36
38
|
- doc/classes/Phrase/Pronunciation.html
|
37
39
|
- doc/classes/Phrase/Pronunciation.src/M000010.html
|
38
40
|
- doc/classes/Phrase/Pronunciation.src/M000011.html
|
@@ -51,15 +53,29 @@ files:
|
|
51
53
|
- doc/classes/String.html
|
52
54
|
- doc/classes/String.src/M000013.html
|
53
55
|
- doc/created.rid
|
56
|
+
- doc/css/common.css
|
57
|
+
- doc/css/full_list.css
|
58
|
+
- doc/css/style.css
|
59
|
+
- doc/file.README.html
|
60
|
+
- doc/file_list.html
|
54
61
|
- doc/files/lib/ruby_rhymes_rb.html
|
55
62
|
- doc/files/lib/syllable_arrays_rb.html
|
56
63
|
- doc/fr_class_index.html
|
57
64
|
- doc/fr_file_index.html
|
58
65
|
- doc/fr_method_index.html
|
66
|
+
- doc/frames.html
|
59
67
|
- doc/index.html
|
68
|
+
- doc/js/app.js
|
69
|
+
- doc/js/full_list.js
|
70
|
+
- doc/js/jquery.js
|
71
|
+
- doc/method_list.html
|
72
|
+
- doc/Phrase/Pronunciation.html
|
73
|
+
- doc/Phrase/Pronunciations.html
|
74
|
+
- doc/Phrase.html
|
60
75
|
- doc/rdoc-style.css
|
76
|
+
- doc/String.html
|
77
|
+
- doc/top-level-namespace.html
|
61
78
|
- README.md
|
62
|
-
- README.rdoc
|
63
79
|
homepage: https://github.com/vshulman/RubyRhymes
|
64
80
|
licenses: []
|
65
81
|
|
data/README.rdoc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
test
|