latinverb_stem_deriver 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 39ca242559aee049ca48f1c1dff614fb41dc2fe3
4
+ data.tar.gz: 214fb34fc45ece2d70484baf5a2b7c243afc761a
5
+ SHA512:
6
+ metadata.gz: 8ca4e83d4bb8edece11d914989140aab5083a98b37ef9f8db33a0b6c26bfead0d1746f87fddc83c1ee72d495c6401faf97bc87088f63d699a76601c9558ea48b
7
+ data.tar.gz: 7afd1eae5b91f2bc6345d100a7d1027494231f5deeb2de025ecda08bdca512959e2c748d592fbcb2b98ad8177602f4b7b979c2c2b4c515af555470c44f26319b
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in latinverb_stem_deriver.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Steven G. Harms
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # LatinverbStemDeriver
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'latinverb_stem_deriver'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install latinverb_stem_deriver
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/latinverb_stem_deriver/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task :default => :test
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.ruby_opts = [ '-rminitest/autorun', '-rminitest/pride', '-rlatinverb_stem_deriver' ]
8
+ t.test_files = FileList['test/**/*test*.rb']
9
+ t.verbose = true
10
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'latinverb_stem_deriver/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "latinverb_stem_deriver"
8
+ spec.version = LatinverbStemDeriver::VERSION
9
+ spec.authors = ["Steven G. Harms"]
10
+ spec.email = ["sgharms@stevengharms.com"]
11
+ spec.summary = %q{Extracts a "stem" from a LatinVerb}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "latinverb_deponent_string_deriver"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "byebug"
25
+ end
@@ -0,0 +1,3 @@
1
+ module LatinverbStemDeriver
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,75 @@
1
+ require "latinverb_deponent_string_deriver"
2
+ require "latinverb_stem_deriver/version"
3
+
4
+ module Linguistics
5
+ module Latin
6
+ module Verb
7
+ class LatinVerb
8
+ class StemDeriver
9
+ FIRST_CONJUGATION_IDENTIFYING_SUFFIX = /(.*ā)re$/
10
+ SECOND_CONJUGATION_IDENTIFYING_SUFFIX = /(.*ē)re$/
11
+ THIRD_CONJUGATION_IDENTIFYING_SUFFIX = /(.*)ere$/
12
+ THIRDIO_CONJUGATION_IDENTIFYING_SUFFIX_ACTIVE_INDICATIVE_PRESENT_FIRST_SINGULAR = /iō/
13
+ THIRD_STEM_PARTICLE = "e"
14
+ THIRDIO_STEM_PARTICLE = "iē"
15
+ FOURTH_CONJUGATION_IDENTIFYING_SUFFIX = /(.*)īre$/
16
+
17
+ def initialize(verb, opts = {})
18
+ @verb = verb
19
+ @opts = opts
20
+ end
21
+
22
+ def stem
23
+ return calculate_deponent_proxy_stem unless verb_is_regular?
24
+ return $1 if present_active_infinitive =~ FIRST_CONJUGATION_IDENTIFYING_SUFFIX
25
+ return $1 if present_active_infinitive =~ SECOND_CONJUGATION_IDENTIFYING_SUFFIX
26
+ return $1 if present_active_infinitive =~ THIRD_CONJUGATION_IDENTIFYING_SUFFIX
27
+ return $1 if present_active_infinitive =~ FOURTH_CONJUGATION_IDENTIFYING_SUFFIX
28
+ end
29
+
30
+ def participial_stem
31
+ return $1 if present_active_infinitive.to_s =~ FIRST_CONJUGATION_IDENTIFYING_SUFFIX
32
+ return $1 if present_active_infinitive.to_s =~ SECOND_CONJUGATION_IDENTIFYING_SUFFIX
33
+ return $1 + calculate_particle($1) if present_active_infinitive.to_s =~ THIRD_CONJUGATION_IDENTIFYING_SUFFIX
34
+ return $1 + THIRDIO_STEM_PARTICLE if present_active_infinitive.to_s =~ FOURTH_CONJUGATION_IDENTIFYING_SUFFIX
35
+ end
36
+
37
+ private
38
+
39
+ def verb_is_regular?
40
+ @verb.regular?
41
+ end
42
+
43
+ def calculate_deponent_proxy_stem
44
+ proxy_string.split(/\s+/)[1]
45
+ end
46
+
47
+ def proxy_string
48
+ klass = (@opts[:proxy_string_deriver] || Linguistics::Latin::Verb::LatinVerb::DeponentStringDeriver)
49
+ klass.new(original_string).proxy_string
50
+ end
51
+
52
+ def original_string
53
+ @verb.original_string
54
+ end
55
+
56
+ def present_active_infinitive
57
+ @verb.present_active_infinitive
58
+ end
59
+
60
+ def first_person_singular
61
+ @verb.first_person_singular
62
+ end
63
+
64
+ def deponent_or_impersonal?
65
+ @verb.deponent? || @verb.semideponent? || @verb.impersonal?
66
+ end
67
+
68
+ def calculate_particle(portion)
69
+ first_person_singular =~ THIRDIO_CONJUGATION_IDENTIFYING_SUFFIX_ACTIVE_INDICATIVE_PRESENT_FIRST_SINGULAR ? THIRDIO_STEM_PARTICLE : THIRD_STEM_PARTICLE
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
data/stem_deriver.rb ADDED
@@ -0,0 +1,82 @@
1
+ #encoding: UTF-8
2
+ module Linguistics
3
+ module Latin
4
+ module Verb
5
+ class LatinVerb
6
+ class StemDeriver
7
+ def initialize(verb)
8
+ @verb = verb
9
+ end
10
+
11
+ def stem
12
+ verb_is_regular? ? calculate_stem : calculate_deponent_proxy_stem
13
+ end
14
+
15
+ def participial_stem
16
+ if present_active_infinitive.to_s =~ /(.*ā)re$/
17
+ return $1
18
+ end
19
+
20
+ if present_active_infinitive.to_s =~ /(.*ē)re$/
21
+ return $1
22
+ end
23
+
24
+ if present_active_infinitive.to_s =~ /(.*)ere$/
25
+ match=$1
26
+ if first_person_singular =~ /iō/
27
+ return match + "iē"
28
+ else
29
+ return match + "e"
30
+ end
31
+ end
32
+
33
+ if present_active_infinitive.to_s =~ /(.*)īre$/
34
+ return $1 + "iē"
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def calculate_deponent_proxy_stem
41
+ DeponentStringDeriver.new(@verb.original_string).proxy_string.split(/\s+/)[1]
42
+ end
43
+
44
+ def verb_is_regular?
45
+ @verb.regular?
46
+ end
47
+
48
+ def present_active_infinitive
49
+ @verb.present_active_infinitive
50
+ end
51
+
52
+ def first_person_singular
53
+ @verb.first_person_singular
54
+ end
55
+
56
+ def deponent_or_impersonal?
57
+ @verb.deponent? || @verb.semideponent? || @verb.impersonal?
58
+ end
59
+
60
+ def calculate_stem
61
+ if present_active_infinitive =~ /āre$/
62
+ return present_active_infinitive.gsub(/(.*)āre$/,'\\1ā')
63
+ end
64
+ if present_active_infinitive =~ /ēre$/
65
+ return present_active_infinitive.gsub(/(.*)ēre$/,'\\1ē')
66
+ end
67
+ if present_active_infinitive =~ /ere$/
68
+ if first_person_singular =~ /iō$/
69
+ return present_active_infinitive.gsub(/(.*)ere$/,'\\1')
70
+ else
71
+ return present_active_infinitive.gsub(/(.*)ere$/,'\\1')
72
+ end
73
+ end
74
+ if present_active_infinitive =~ /īre$/
75
+ return present_active_infinitive.gsub(/(.*)īre$/,'\\1')
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,6 @@
1
+ class StemDeriverTest < Minitest::Test
2
+ def test_bar
3
+ assert true
4
+ end
5
+ end
6
+
@@ -0,0 +1,31 @@
1
+ class StemDeriverTest < Minitest::Test
2
+ def test_first
3
+ stub = OpenStruct.new(present_active_infinitive: "laudāre", regular?: true )
4
+ assert_equal Linguistics::Latin::Verb::LatinVerb::StemDeriver.new(stub).stem, "laudā"
5
+ end
6
+
7
+ def test_second
8
+ stub = OpenStruct.new(present_active_infinitive: "monēre", regular?: true )
9
+ assert_equal Linguistics::Latin::Verb::LatinVerb::StemDeriver.new(stub).stem, "monē"
10
+ end
11
+
12
+ def test_third
13
+ stub = OpenStruct.new(present_active_infinitive: "agere", regular?: true, first_person_singular: "agō" )
14
+ assert_equal Linguistics::Latin::Verb::LatinVerb::StemDeriver.new(stub).stem, "ag"
15
+ end
16
+
17
+ def test_thirdio
18
+ stub = OpenStruct.new(present_active_infinitive: "capere", regular?: true, first_person_singular: "capiō" )
19
+ assert_equal Linguistics::Latin::Verb::LatinVerb::StemDeriver.new(stub).stem, "cap"
20
+ end
21
+
22
+ def test_fourth
23
+ stub = OpenStruct.new(present_active_infinitive: "audīre", regular?: true )
24
+ assert_equal Linguistics::Latin::Verb::LatinVerb::StemDeriver.new(stub).stem, "aud"
25
+ end
26
+
27
+ def test_deponent
28
+ stub = OpenStruct.new(regular?: false, original_string: "hi didldy do neighbor")
29
+ assert_equal Linguistics::Latin::Verb::LatinVerb::StemDeriver.new(stub).stem, "didldyre"
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: latinverb_stem_deriver
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Steven G. Harms
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: latinverb_deponent_string_deriver
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: byebug
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
+ description:
70
+ email:
71
+ - sgharms@stevengharms.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - latinverb_stem_deriver.gemspec
82
+ - lib/latinverb_stem_deriver.rb
83
+ - lib/latinverb_stem_deriver/version.rb
84
+ - stem_deriver.rb
85
+ - test/participial_stem_deriver_test.rb
86
+ - test/stem_deriver_test.rb
87
+ homepage: ''
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.2.2
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Extracts a "stem" from a LatinVerb
111
+ test_files:
112
+ - test/participial_stem_deriver_test.rb
113
+ - test/stem_deriver_test.rb