tracinho 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7eda141f70817d4d6b65a379300aeed6111b022a
4
+ data.tar.gz: 150a0710365d85a6a1e1d618075e88100a7f6ffb
5
+ SHA512:
6
+ metadata.gz: 41d70c0dff0edea402bb56afc199cdb75251e808d3013bf7dca8268170574084c4df1c6311dfbb23787c93cfd220c9272921ea26dc0915f58033f86e37b408ce
7
+ data.tar.gz: 820dbd16d1f1a9ec2a813d45f87fb9f741ea1e94e4007b6caa453324976f2389e6ff9934a5a1b7f36bf5a40d3e538bb6d72b5d986ea345a9896b94181e796833
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Metrics/LineLength:
2
+ Max: 100
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ tracinho
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.1.3
5
+ - 2.2.0
6
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tracinho.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tracinho (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.0.0)
10
+ astrolabe (1.3.0)
11
+ parser (>= 2.2.0.pre.3, < 3.0)
12
+ coderay (1.1.0)
13
+ diff-lcs (1.2.5)
14
+ docile (1.1.5)
15
+ method_source (0.8.2)
16
+ multi_json (1.10.1)
17
+ parser (2.2.0.pre.5)
18
+ ast (>= 1.1, < 3.0)
19
+ slop (~> 3.4, >= 3.4.5)
20
+ powerpack (0.0.9)
21
+ pry (0.10.1)
22
+ coderay (~> 1.1.0)
23
+ method_source (~> 0.8.1)
24
+ slop (~> 3.4)
25
+ rainbow (2.0.0)
26
+ rake (10.3.2)
27
+ rspec (3.1.0)
28
+ rspec-core (~> 3.1.0)
29
+ rspec-expectations (~> 3.1.0)
30
+ rspec-mocks (~> 3.1.0)
31
+ rspec-core (3.1.7)
32
+ rspec-support (~> 3.1.0)
33
+ rspec-expectations (3.1.2)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.1.0)
36
+ rspec-mocks (3.1.3)
37
+ rspec-support (~> 3.1.0)
38
+ rspec-support (3.1.2)
39
+ rubocop (0.26.1)
40
+ astrolabe (~> 1.3)
41
+ parser (>= 2.2.0.pre.4, < 3.0)
42
+ powerpack (~> 0.0.6)
43
+ rainbow (>= 1.99.1, < 3.0)
44
+ ruby-progressbar (~> 1.4)
45
+ ruby-progressbar (1.6.0)
46
+ simplecov (0.9.1)
47
+ docile (~> 1.1.0)
48
+ multi_json (~> 1.0)
49
+ simplecov-html (~> 0.8.0)
50
+ simplecov-html (0.8.0)
51
+ slop (3.6.0)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ bundler (~> 1.7)
58
+ pry
59
+ rake (~> 10.0)
60
+ rspec
61
+ rubocop
62
+ simplecov
63
+ tracinho!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Ricardo Otero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ [![Build Status](https://travis-ci.org/rikas/tracinho.svg)](https://travis-ci.org/rikas/tracinho) [![Dependency Status](https://gemnasium.com/rikas/tracinho.svg)](https://gemnasium.com/rikas/tracinho) [![Code Climate](https://codeclimate.com/github/rikas/tracinho/badges/gpa.svg)](https://codeclimate.com/github/rikas/tracinho)
2
+
3
+ tracinho
4
+ ========
5
+
6
+ tracinho.com library to convert words with dash in the version without dash and vice-versa and classify the word verb.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,38 @@
1
+ module Tracinho
2
+ # ComplementBuilder converts words with dash in the version without it and vice-versa.
3
+ class ComplementBuilder
4
+ def initialize(word)
5
+ @word = word
6
+ end
7
+
8
+ # Builds the complementary word.
9
+ #
10
+ # Examples:
11
+ #
12
+ # ComplementBuilder.new(Word.new('fizeste')).build
13
+ # # => #<Tracinho::Word:0x007f8a9b0ba928 @text="fize-te">
14
+ #
15
+ # ComplementBuilder.new(Word.new('passa-mos')).build
16
+ # # => #<Tracinho::Word:0x007f8a9b10f270 @text="passamos">
17
+ def build
18
+ text = @word.hyphenated? ? remove_dash(@word.text) : add_dash(@word.text)
19
+
20
+ Word.new(text)
21
+ end
22
+
23
+ private
24
+
25
+ def remove_dash(text)
26
+ text.match(/\-se$/) ? text.tr('-', 's') : text.delete('-')
27
+ end
28
+
29
+ def add_dash(text)
30
+ case text
31
+ when /os$/
32
+ text.insert(-4, '-')
33
+ else
34
+ text.insert(-3, '-').sub('s-', '-')
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ # This gem converts words with dash in the version without it and vice-versa. It also gets the verb
2
+ # name from a word and gives the full grammar classification of the verb.
3
+ module Tracinho
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,24 @@
1
+ module Tracinho
2
+ class Word
3
+ attr_accessor :text
4
+
5
+ def initialize(text)
6
+ self.text = text
7
+ end
8
+
9
+ def hyphenated?
10
+ text.include?('-')
11
+ end
12
+
13
+ def complement
14
+ ComplementBuilder.new(self).build
15
+ end
16
+
17
+ def grammar_class
18
+ end
19
+
20
+ def to_s
21
+ text
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,58 @@
1
+ module Tracinho
2
+ class WordClassifier
3
+ ENDINGS = /(?:(ste)|(sse)|[^-](mos)|(-(se|mos))|[^s](-te)|(s-te))$/
4
+
5
+ def initialize(word)
6
+ @word = word
7
+ end
8
+
9
+ def full_classification
10
+ case @word.text
11
+ when /ste$/
12
+ "Segunda pessoa do singular do #{full_verb}."
13
+ when /sse$/
14
+ "Primeira ou terceira pessoa do singular do #{full_verb}."
15
+ when /[^-]mos$/
16
+ "Primeira pessoa do plural do #{full_verb}."
17
+ when /(-te | -se)$/
18
+ "Conjugação pronominal reflexa da segunda pessoa do #{full_verb}."
19
+ when /-mos$/
20
+ "Conjugação pronominal da segunda pessoa do singular do #{full_verb}."
21
+ end
22
+ end
23
+
24
+ def verb
25
+ endings = @word.text.match(ENDINGS).captures.compact
26
+
27
+ verb = @word.text.sub(endings.first, 'r')
28
+ verb.sub!(/rr$/, 'r')
29
+ verb.sub!(/our$/, 'ar')
30
+
31
+ # Irregular verbs that got bad guesses
32
+ verb = verb.sub(/^var$/, 'ir').sub(/^sor$/, 'ser').sub(/^for$/, 'ser')
33
+
34
+ verb
35
+ end
36
+
37
+ def verb_tense
38
+ case @word.text
39
+ when /ste$/
40
+ 'pretérito perfeito do indicativo'
41
+ when /sse$/
42
+ 'pretérito imperfeito do conjuntivo'
43
+ when /[^-]mos$/
44
+ 'presente do indicativo ou pretérito perfeito do indicativo'
45
+ when /(-te | -se)$/
46
+ 'presente do indicativo'
47
+ when /-mos$/
48
+ 'imperativo'
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def full_verb
55
+ "#{verb_tense} do verbo #{verb}"
56
+ end
57
+ end
58
+ end
data/lib/tracinho.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'tracinho/version'
2
+ require 'tracinho/complement_builder'
3
+ require 'tracinho/word'
4
+ require 'tracinho/word_classifier'
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe ComplementBuilder do
4
+ end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_filter '/spec/'
5
+ end
6
+
7
+ require 'tracinho'
8
+ require 'rspec'
9
+
10
+ RSpec.configure do |config|
11
+ include Tracinho
12
+
13
+ config.order = 'random'
14
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe WordClassifier do
4
+ describe 'verb' do
5
+ let(:regular_words) do
6
+ %w(bebemos comesse mijaste cagou-se passa-mos cala-te matas-te conhecer-te morde-mos mata-te)
7
+ end
8
+
9
+ let(:regular_verbs) do
10
+ %w(beber comer mijar cagar passar calar matar conhecer morder matar)
11
+ end
12
+
13
+ let(:irregular_words) do
14
+ %w(vamos somos fomos)
15
+ end
16
+
17
+ let(:irregular_verbs) do
18
+ %w(ir ser ser)
19
+ end
20
+
21
+ context 'for regular verbs' do
22
+ it 'correctly returns the verb of the word' do
23
+ regular_words.each_with_index do |word, index|
24
+ classifier = described_class.new(Word.new(word))
25
+
26
+ expect(classifier.verb).to eq(regular_verbs[index])
27
+ end
28
+ end
29
+ end
30
+
31
+ context 'for irregular verbs' do
32
+ it 'correctly returns the verb of the word' do
33
+ irregular_words.each_with_index do |word, index|
34
+ puts word
35
+ classifier = described_class.new(Word.new(word))
36
+
37
+ expect(classifier.verb).to eq(irregular_verbs[index])
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ describe 'full_classification' do
44
+ let(:classifications) do
45
+ [
46
+ 'Segunda pessoa do singular do pretérito perfeito do indicativo do verbo mijar.',
47
+ 'Primeira ou terceira pessoa do singular do pretérito imperfeito do conjuntivo do ' \
48
+ 'verbo beber.',
49
+ 'Primeira pessoa do plural do presente do indicativo ou pretérito perfeito do ' \
50
+ 'indicativo do verbo conhecer.',
51
+ 'Conjugação pronominal da segunda pessoa do singular do imperativo do verbo buscar.'
52
+ ]
53
+ end
54
+
55
+ %w(mijaste bebesse conhecemos busca-mos).each_with_index do |word, index|
56
+ it "correctly returns the full classification of the word '#{word}'" do
57
+ classifier = described_class.new(Word.new(word))
58
+
59
+ expect(classifier.full_classification).to eq(classifications[index])
60
+ end
61
+ end
62
+ end
63
+ end
data/spec/word_spec.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Word do
4
+ let(:hyphenated) { %w(passa-mos cala-te matas-te conhecer-te morde-mos mata-te) }
5
+ let(:not_hyphenated) { %w(passamos calate mataste conhecerte mordemos matate) }
6
+
7
+ describe '#hyphenated?' do
8
+ it 'returns true if the word has a hyphen' do
9
+ hyphenated.each do |w|
10
+ expect(Word.new(w).hyphenated?).to be_truthy
11
+ end
12
+ end
13
+
14
+ it 'returns false if the word does not have a hyphen' do
15
+ not_hyphenated.each do |w|
16
+ expect(Word.new(w).hyphenated?).to be_falsey
17
+ end
18
+ end
19
+ end
20
+
21
+ describe '#complement' do
22
+ it 'returns the complement of a word' do
23
+ word = Word.new('fizes-te')
24
+
25
+ complement = word.complement
26
+
27
+ expect(complement.text).to eq('fizeste')
28
+ end
29
+ end
30
+
31
+ describe '#to_s' do
32
+ it 'returns the text attribute of the word' do
33
+ (hyphenated + not_hyphenated).each do |w|
34
+ expect(Word.new(w).to_s).to eq(w)
35
+ end
36
+ end
37
+ end
38
+ end
data/tracinho.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'tracinho/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'tracinho'
9
+ spec.version = Tracinho::VERSION
10
+ spec.authors = ['Ricardo Otero']
11
+ spec.email = ['oterosantos@gmail.com']
12
+ spec.summary = 'Tracinho.com gem.'
13
+ spec.description = 'This gem converts words with dash in the version without it and
14
+ vice-versa. It also gets the verb name from a word and gives the full grammar classification of
15
+ the verb.'
16
+ spec.homepage = 'https://github.com/rikas/tracinho'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.7'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'pry'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'rspec'
29
+ spec.add_development_dependency 'simplecov'
30
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tracinho
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ricardo Otero
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: |-
98
+ This gem converts words with dash in the version without it and
99
+ vice-versa. It also gets the verb name from a word and gives the full grammar classification of
100
+ the verb.
101
+ email:
102
+ - oterosantos@gmail.com
103
+ executables: []
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".rubocop.yml"
110
+ - ".ruby-gemset"
111
+ - ".ruby-version"
112
+ - ".travis.yml"
113
+ - Gemfile
114
+ - Gemfile.lock
115
+ - LICENSE
116
+ - README.md
117
+ - Rakefile
118
+ - lib/tracinho.rb
119
+ - lib/tracinho/complement_builder.rb
120
+ - lib/tracinho/version.rb
121
+ - lib/tracinho/word.rb
122
+ - lib/tracinho/word_classifier.rb
123
+ - spec/complement_builder_spec.rb
124
+ - spec/spec_helper.rb
125
+ - spec/word_classifier_spec.rb
126
+ - spec/word_spec.rb
127
+ - tracinho.gemspec
128
+ homepage: https://github.com/rikas/tracinho
129
+ licenses:
130
+ - MIT
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.4.5
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Tracinho.com gem.
152
+ test_files:
153
+ - spec/complement_builder_spec.rb
154
+ - spec/spec_helper.rb
155
+ - spec/word_classifier_spec.rb
156
+ - spec/word_spec.rb