poetize 0.0.1
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.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/README.md +55 -0
- data/Rakefile +1 -0
- data/analyzer/analyzer.rb +44 -0
- data/analyzer/strophe_analyzer.rb +84 -0
- data/bin/poetize +37 -0
- data/lib/file_handler.rb +16 -0
- data/lib/hyphenator.rb +78 -0
- data/lib/poetize.rb +5 -0
- data/lib/poetize/version.rb +3 -0
- data/lib/text_handler.rb +69 -0
- data/model/poem.rb +25 -0
- data/model/strophe.rb +20 -0
- data/poetize.gemspec +24 -0
- data/resources/syllables_dict.txt +156176 -0
- data/test/file_handler_spec.rb +18 -0
- data/test/hyphenator_spec.rb +25 -0
- data/test/poem_spec.rb +22 -0
- data/test/samples/01.txt +34 -0
- data/test/samples/02_ballad.txt +26 -0
- data/test/samples/02_doubled.txt +62 -0
- data/test/samples/02_full.txt +32 -0
- data/test/samples/02_original.txt +30 -0
- data/test/spec_helper.rb +28 -0
- data/test/strophe_analyzer_spec.rb +33 -0
- data/test/strophe_spec.rb +17 -0
- data/test/text_handler_spec.rb +20 -0
- metadata +103 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
$app_path = File.dirname(__FILE__) + '/../'
|
2
|
+
require $app_path + 'test/spec_helper.rb'
|
3
|
+
|
4
|
+
describe FileHandler do
|
5
|
+
before :all do
|
6
|
+
@file_path = $app_path + 'test/samples/01.txt'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should raise an exception if no file is found" do
|
10
|
+
lambda {
|
11
|
+
FileHandler.get_file_contents("this_file_wont_exist.txt")
|
12
|
+
}.should raise_exception
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to read a existant file" do
|
16
|
+
FileHandler.get_file_contents(@file_path).should_not be_empty
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$app_path = File.dirname(__FILE__) + '/../'
|
3
|
+
require $app_path + 'test/spec_helper.rb'
|
4
|
+
|
5
|
+
describe Hyphenator do
|
6
|
+
it "should hyphenate words without accents" do
|
7
|
+
hyp = Hyphenator.new
|
8
|
+
hyp.hyphenate("teste").should == "tes-te"
|
9
|
+
hyp.hyphenate("computador").should == "com-pu-ta-dor"
|
10
|
+
hyp.hyphenate("assassino").should == "as-sas-si-no"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should hyphenate words with accents" do
|
14
|
+
hyp = Hyphenator.new
|
15
|
+
hyp.hyphenate("comunicação").should == "co-mu-ni-ca-ção"
|
16
|
+
hyp.hyphenate("coração").should == "co-ra-ção"
|
17
|
+
hyp.hyphenate("artéria").should == "ar-té-ria"
|
18
|
+
hyp.hyphenate("braçal").should == "bra-çal"
|
19
|
+
hyp.hyphenate("artesã").should == "ar-te-sã"
|
20
|
+
hyp.hyphenate("heróico").should == "he-rói-co"
|
21
|
+
hyp.hyphenate("sã").should == "sã"
|
22
|
+
hyp.hyphenate("árvore").should == "ár-vo-re"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
data/test/poem_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$app_path = File.dirname(__FILE__) + '/../'
|
2
|
+
require $app_path + 'test/spec_helper.rb'
|
3
|
+
|
4
|
+
describe Poem do
|
5
|
+
it "should count the number of strophes" do
|
6
|
+
@simple_poem.number_of_strophes.should == 2
|
7
|
+
@poem.number_of_strophes.should == 6
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should count the number of verses" do
|
11
|
+
@simple_poem.number_of_verses.should == 6
|
12
|
+
@poem.number_of_verses.should == 24
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should print plain text beautifully" do
|
16
|
+
@simple_poem.to_s.should == "#{@meta_plain}\n\n#{@body_plain}"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should print html text beautifully" do
|
20
|
+
@simple_poem.to_html.should == "#{@meta_plain}\n\n#{@body_plain}".gsub("\n", "<br />")
|
21
|
+
end
|
22
|
+
end
|
data/test/samples/01.txt
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Quantas coisas, nesta vida,
|
2
|
+
você sonhou fazer.
|
3
|
+
Forças belas, pela arte,
|
4
|
+
sentiu vibrar no ser.
|
5
|
+
|
6
|
+
Outras vidas, mesmos planos,
|
7
|
+
também traziam luz.
|
8
|
+
Elos puros, firmes, tantos,
|
9
|
+
unídos por Jesus.
|
10
|
+
|
11
|
+
Quando logo, feito vento,
|
12
|
+
soprou estradas só,
|
13
|
+
Longe foi-se, quase lento
|
14
|
+
tecendo poucos nós.
|
15
|
+
|
16
|
+
Sol brilhante, belo e forte,
|
17
|
+
você tentou provar.
|
18
|
+
Tinha nisso o certo norte,
|
19
|
+
o rumo para o lar.
|
20
|
+
|
21
|
+
Hoje todo, tão distante,
|
22
|
+
não larga o osso seu.
|
23
|
+
Quer estar ali, latente,
|
24
|
+
mostrar que se ergueu.
|
25
|
+
|
26
|
+
Venha livre nestes braços
|
27
|
+
que ontem foram paz
|
28
|
+
Grupo e arte nasce em laços
|
29
|
+
pra quem na vida faz
|
30
|
+
|
31
|
+
Sinta o nosso bom carinho,
|
32
|
+
irmão amado assim.
|
33
|
+
Faça arte sempre e rindo,
|
34
|
+
florindo seu jardim.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Bom Humor
|
2
|
+
Mauricio Keller 10-06-11
|
3
|
+
|
4
|
+
Fomos nesta vida
|
5
|
+
criados pra culpar.
|
6
|
+
Flecha mais ardida,
|
7
|
+
nem fogo faz queimar.
|
8
|
+
|
9
|
+
Busque na bondade
|
10
|
+
a paz que tanto quer.
|
11
|
+
|
12
|
+
Somos, em essência,
|
13
|
+
Divinos, pura luz.
|
14
|
+
Soltos na fragância,
|
15
|
+
no vento que a conduz.
|
16
|
+
|
17
|
+
O ego se alimenta
|
18
|
+
da dor que nasce assim:
|
19
|
+
|
20
|
+
Vá com toda calma
|
21
|
+
carinho e bom humor
|
22
|
+
Sinta a sua alma
|
23
|
+
serena, sem rumor.
|
24
|
+
|
25
|
+
Somos, em essência,
|
26
|
+
Divinos, pura luz.
|
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
Fomos nesta vida
|
5
|
+
|
6
|
+
criados pra culpar.
|
7
|
+
|
8
|
+
Flecha mais ardida,
|
9
|
+
|
10
|
+
nem fogo faz queimar.
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
Busque na bondade
|
15
|
+
|
16
|
+
a paz que tanto quer.
|
17
|
+
|
18
|
+
Tal felicidade
|
19
|
+
|
20
|
+
não é prazer qualquer.
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
Somos, em essência,
|
25
|
+
|
26
|
+
Divinos, pura luz.
|
27
|
+
|
28
|
+
Soltos na fragância,
|
29
|
+
|
30
|
+
no vento que a conduz.
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
O ego se alimenta
|
35
|
+
|
36
|
+
da dor que nasce assim:
|
37
|
+
|
38
|
+
Tudo que se enfrenta
|
39
|
+
|
40
|
+
recalca em estopim.
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
Vá com toda calma
|
45
|
+
|
46
|
+
carinho e bom humor
|
47
|
+
|
48
|
+
Sinta a sua alma
|
49
|
+
|
50
|
+
serena, sem rumor.
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
Somos, em essência,
|
55
|
+
|
56
|
+
Divinos, pura luz.
|
57
|
+
|
58
|
+
Soltos na fragância,
|
59
|
+
|
60
|
+
no vento que a conduz.
|
61
|
+
|
62
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Bom Humor
|
2
|
+
Mauricio Keller 10-06-11
|
3
|
+
|
4
|
+
Fomos nesta vida
|
5
|
+
criados pra culpar.
|
6
|
+
Flecha mais ardida,
|
7
|
+
nem fogo faz queimar.
|
8
|
+
|
9
|
+
Busque na bondade
|
10
|
+
a paz que tanto quer.
|
11
|
+
Tal felicidade
|
12
|
+
não é prazer qualquer.
|
13
|
+
|
14
|
+
Somos, em essência,
|
15
|
+
Divinos, pura luz.
|
16
|
+
Soltos na fragância,
|
17
|
+
no vento que a conduz.
|
18
|
+
|
19
|
+
O ego se alimenta
|
20
|
+
da dor que nasce assim:
|
21
|
+
Tudo que se enfrenta
|
22
|
+
recalca em estopim.
|
23
|
+
|
24
|
+
Vá com toda calma
|
25
|
+
carinho e bom humor
|
26
|
+
Sinta a sua alma
|
27
|
+
serena, sem rumor.
|
28
|
+
|
29
|
+
Somos, em essência,
|
30
|
+
Divinos, pura luz.
|
31
|
+
Soltos na fragância,
|
32
|
+
no vento que a conduz.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
Fomos nesta vida
|
3
|
+
criados pra culpar.
|
4
|
+
Flecha mais ardida,
|
5
|
+
nem fogo faz queimar.
|
6
|
+
|
7
|
+
Busque na bondade
|
8
|
+
a paz que tanto quer.
|
9
|
+
Tal felicidade
|
10
|
+
não é prazer qualquer.
|
11
|
+
|
12
|
+
Somos, em essência,
|
13
|
+
Divinos, pura luz.
|
14
|
+
Soltos na fragância,
|
15
|
+
no vento que a conduz.
|
16
|
+
|
17
|
+
O ego se alimenta
|
18
|
+
da dor que nasce assim:
|
19
|
+
Tudo que se enfrenta
|
20
|
+
recalca em estopim.
|
21
|
+
|
22
|
+
Vá com toda calma
|
23
|
+
carinho e bom humor
|
24
|
+
Sinta a sua alma
|
25
|
+
serena, sem rumor.
|
26
|
+
|
27
|
+
Somos, em essência,
|
28
|
+
Divinos, pura luz.
|
29
|
+
Soltos na fragância,
|
30
|
+
no vento que a conduz.
|
data/test/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$app_path = File.dirname(__FILE__) + '/../'
|
2
|
+
require $app_path + 'lib/text_handler'
|
3
|
+
require $app_path + 'lib/file_handler'
|
4
|
+
require $app_path + 'lib/hyphenator'
|
5
|
+
require $app_path + 'analyzer/strophe_analyzer'
|
6
|
+
require $app_path + 'model/poem'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.before(:all) do
|
10
|
+
@body_plain = "One verse\nTwo verse\nThree Verse\n\nFour\nFive\nSix"
|
11
|
+
@meta_plain = "Title\nAuthor"
|
12
|
+
@body = TextHandler.normalize_text @body_plain
|
13
|
+
@meta = TextHandler.normalize_text @meta_plain
|
14
|
+
@simple_poem = Poem.new(@meta, @body)
|
15
|
+
|
16
|
+
file = $app_path + 'test/samples/02_original.txt'
|
17
|
+
file_doubled = $app_path + 'test/samples/02_doubled.txt'
|
18
|
+
file_ballad = $app_path + 'test/samples/02_ballad.txt'
|
19
|
+
|
20
|
+
@text = FileHandler.get_file_contents(file)
|
21
|
+
@text_doubled = FileHandler.get_file_contents(file_doubled)
|
22
|
+
text_ballad = FileHandler.get_file_contents(file_ballad).drop(2)
|
23
|
+
|
24
|
+
@poem = Poem.new(@meta_plain, TextHandler.normalize_text(@text))
|
25
|
+
@poem_ballad = Poem.new(@meta_plain, TextHandler.normalize_text(text_ballad))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$app_path = File.dirname(__FILE__) + '/../'
|
2
|
+
require $app_path + 'test/spec_helper.rb'
|
3
|
+
|
4
|
+
describe StropheAnalyzer do
|
5
|
+
before :all do
|
6
|
+
@analyzer = StropheAnalyzer.new @poem_ballad
|
7
|
+
@analyzer.analyze
|
8
|
+
@simple_analyzer = StropheAnalyzer.new @simple_poem
|
9
|
+
@simple_analyzer.analyze
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should count the number of strophes" do
|
13
|
+
@simple_analyzer.number_of_strophes.should == 2
|
14
|
+
@analyzer.number_of_strophes.should == 6
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should count the number of verses" do
|
18
|
+
@simple_analyzer.number_of_verses.should == 6
|
19
|
+
@analyzer.number_of_verses.should == 18
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should identify a ballad" do
|
23
|
+
@analyzer.fixed_form_ballad?.should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should identify a italian sonet" do
|
27
|
+
pending("Gotta be able to identify rhymes first")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should identify an english sonet" do
|
31
|
+
pending("Gotta be able to identify rhymes first")
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$app_path = File.dirname(__FILE__) + '/../'
|
3
|
+
require $app_path + 'test/spec_helper.rb'
|
4
|
+
|
5
|
+
describe Strophe do
|
6
|
+
it "should count the number of verses" do
|
7
|
+
@simple_poem.strophes[0].number_of_verses.should == 3
|
8
|
+
@poem.strophes[0].number_of_verses.should == 4
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should name the strophe right" do
|
12
|
+
@simple_poem.strophes[0].name.should == "Terceto"
|
13
|
+
@poem.strophes[0].name.should == "Quadra"
|
14
|
+
more_than_10 = Strophe.new((1..15).map{|n|n})
|
15
|
+
more_than_10.name.should == "Livre ou Polimérica"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$app_path = File.dirname(__FILE__) + '/../'
|
2
|
+
require $app_path + 'test/spec_helper.rb'
|
3
|
+
|
4
|
+
describe TextHandler do
|
5
|
+
it "should remove extra white spaces in a line" do
|
6
|
+
TextHandler.normalize_line(" aaa bbb ccc ").should == "aaa bbb ccc"
|
7
|
+
TextHandler.normalize_line("\t dd ee ff \t \r").should == "dd ee ff"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should preserve a blank (altough not empty) line" do
|
11
|
+
TextHandler.normalize_line(" ").should == ""
|
12
|
+
TextHandler.normalize_line("\t \n \r ").should == ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should remove extra line breaks" do
|
16
|
+
text_2x = TextHandler.normalize_text @text_doubled
|
17
|
+
text_original = TextHandler.normalize_text @text
|
18
|
+
text_2x.inspect.should == text_original.inspect
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: poetize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luiz Gonzaga dos Santos Filho
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-11-30 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: text-hyphen
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
description: "Poetize analyses your poem and gives you several statistics about it such as: verse rhythm, verse metrics, rhymes, gramatical and poetical hyphenization, etc"
|
38
|
+
email:
|
39
|
+
- lfilho@gmail.com
|
40
|
+
executables:
|
41
|
+
- poetize
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- analyzer/analyzer.rb
|
52
|
+
- analyzer/strophe_analyzer.rb
|
53
|
+
- bin/poetize
|
54
|
+
- lib/file_handler.rb
|
55
|
+
- lib/hyphenator.rb
|
56
|
+
- lib/poetize.rb
|
57
|
+
- lib/poetize/version.rb
|
58
|
+
- lib/text_handler.rb
|
59
|
+
- model/poem.rb
|
60
|
+
- model/strophe.rb
|
61
|
+
- poetize.gemspec
|
62
|
+
- resources/syllables_dict.txt
|
63
|
+
- test/file_handler_spec.rb
|
64
|
+
- test/hyphenator_spec.rb
|
65
|
+
- test/poem_spec.rb
|
66
|
+
- test/samples/01.txt
|
67
|
+
- test/samples/02_ballad.txt
|
68
|
+
- test/samples/02_doubled.txt
|
69
|
+
- test/samples/02_full.txt
|
70
|
+
- test/samples/02_original.txt
|
71
|
+
- test/spec_helper.rb
|
72
|
+
- test/strophe_analyzer_spec.rb
|
73
|
+
- test/strophe_spec.rb
|
74
|
+
- test/text_handler_spec.rb
|
75
|
+
homepage: https://github.com/lfilho/poetize
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project: poetize
|
98
|
+
rubygems_version: 1.8.11
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Poem analyzer for Portuguese language
|
102
|
+
test_files: []
|
103
|
+
|