latinverb_classifier 1.0.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d39d204ede1b8c356bdb0f442c58cf83dbb87b0
4
+ data.tar.gz: 36ab7e3f43eccd01578f1bea45c4fe7e4da77143
5
+ SHA512:
6
+ metadata.gz: 6782532ce85dbcc91ff5b368aee264a710ebfd43b6afedf9d844ee088c2d62713ead66b8f23ff85663b849744e604af129dc4c97c87a1e907779cfba8f9ae381
7
+ data.tar.gz: d57cd0beea827888c4cee3e4d54a0dade2960e2cbea6e08c1d39524cc3479be5a74066518bd67723131462463340f89c83f0d1ba44021c9a9e772eb080c70d82
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_classifier.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,30 @@
1
+ # LatinverbClassifier
2
+
3
+ Utility class used to classify a LatinVerb
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'latinverb_classifier'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install latinverb_classifier
18
+
19
+ ## Usage
20
+
21
+ instance_of_latin_verb = Linguistics::Latin::Verb::LatinVerb 'string defining principal parts'
22
+ LatinVerbClassifier.new(instance_of_latin_verb)
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it ( https://github.com/[my-github-username]/latinverb_classifier/fork )
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 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_classifier' ]
8
+ t.test_files = FileList['test/**/*test*.rb']
9
+ t.verbose = true
10
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'latinverb_classifier/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "latinverb_classifier"
8
+ spec.version = LatinverbClassifier::VERSION
9
+ spec.authors = ["Steven G. Harms"]
10
+ spec.email = ["sgharms@stevengharms.com"]
11
+ spec.summary = %q{Library for classifying Latin verbs}
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("linguistics_latin", "~>0.0.2")
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,79 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ extend Forwardable
7
+ def initialize(verb, opts={})
8
+ @verb, @opts = verb, opts
9
+ end
10
+
11
+ def classification
12
+ @c ||= strategies.detect { |s| s.new(self).applicable? }.classification
13
+ end
14
+
15
+ def input
16
+ @input ||= @verb.original_string
17
+ end
18
+
19
+ def proxy_verb?
20
+ !!@verb.options[:proxy_verb]
21
+ end
22
+
23
+ def present_only?
24
+ classification == Linguistics::Latin::Verb::Classification::PresentOnly ||
25
+ extremely_irregular?
26
+ end
27
+
28
+ def deponent?
29
+ classification == Linguistics::Latin::Verb::Classification::Deponent
30
+ end
31
+
32
+ def semideponent?
33
+ classification == Linguistics::Latin::Verb::Classification::Semideponent
34
+ end
35
+
36
+ def impersonal?
37
+ classification == Linguistics::Latin::Verb::Classification::Impersonal
38
+ end
39
+
40
+ def irregular?
41
+ classification == Linguistics::Latin::Verb::Classification::Irregular
42
+ end
43
+
44
+ def regular?
45
+ classification == Linguistics::Latin::Verb::Classification::Regular
46
+ end
47
+
48
+ def short_class
49
+ classification.to_s.split('::').last
50
+ end
51
+
52
+ private
53
+
54
+ def strategies
55
+ @strategies ||= (@opts[:strategies] || default_strategies)
56
+ end
57
+
58
+ def default_strategies
59
+ [
60
+ DefectiveVerbClassificationStrategy,
61
+ IrregularVerbClassificationStrategy,
62
+ SemideponentVerbClassificationStrategy,
63
+ ImpersonalVerbClassificationStrategy,
64
+ VeryIrregularVerbClassificationStrategy,
65
+ PresentonlyVerbClassificationStrategy,
66
+ DeponentVerbClassificationStrategy,
67
+ RegularVerbClassificationStrategy
68
+ ]
69
+ end
70
+
71
+ def extremely_irregular?
72
+ classification == Linguistics::Latin::Verb::Classification::Irregular &&
73
+ VeryIrregularVerbClassificationStrategy.new(self).applicable?
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,32 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class PresentOnlyChecker
6
+ def initialize(original_string)
7
+ @original_string = original_string
8
+ end
9
+
10
+ def present_only?
11
+ listed_as_present_only?
12
+ end
13
+
14
+ private
15
+
16
+ def listed_as_present_only?
17
+ Linguistics::Latin::Verb::PRESENT_ONLY.member?( first_person_present_tense ) ||
18
+ Linguistics::Latin::Verb::PRESENT_ONLY.member?( present_active_infinitive )
19
+ end
20
+
21
+ def first_person_present_tense
22
+ @original_string.split(/\s+/)[0]
23
+ end
24
+
25
+ def present_active_infinitive
26
+ @original_string.split(/\s+/)[1]
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ class DefectiveVerbClassificationStrategy < VerbClassificationStrategy
7
+ def self.classification
8
+ Classification::Defective
9
+ end
10
+
11
+ def applicable?
12
+ Linguistics::Latin::Verb::DEFECTIVE_VERBS.member? first_pres
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ #encoding: UTF-8
2
+ module Linguistics
3
+ module Latin
4
+ module Verb
5
+ class LatinVerb
6
+ class Classifier
7
+ class DeponentVerbClassificationStrategy < VerbClassificationStrategy
8
+ def self.classification
9
+ return Classification::Deponent
10
+ end
11
+
12
+ def applicable?
13
+ infinitive =~ /ī$/ && first_pres =~ /r$/
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ class ImpersonalVerbClassificationStrategy < VerbClassificationStrategy
7
+ def self.classification
8
+ Classification::Impersonal
9
+ end
10
+
11
+ def applicable?
12
+ Linguistics::Latin::Verb::IMPERSONAL_VERBS.member?(input)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ class IrregularVerbClassificationStrategy < VerbClassificationStrategy
7
+ def self.classification
8
+ Classification::Irregular
9
+ end
10
+
11
+ def applicable?
12
+ Linguistics::Latin::Verb::IRREGULAR_VERBS.member? first_pres
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ class PresentonlyVerbClassificationStrategy < VerbClassificationStrategy
7
+ def self.classification
8
+ Classification::PresentOnly
9
+ end
10
+
11
+ def applicable?
12
+ PresentOnlyChecker.new(input).present_only?
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ class RegularVerbClassificationStrategy < VerbClassificationStrategy
7
+ def self.classification
8
+ Classification::Regular
9
+ end
10
+
11
+ def applicable?
12
+ true
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ class SemideponentVerbClassificationStrategy < VerbClassificationStrategy
7
+ extend Forwardable
8
+ def_delegators :@classifier, :is_not_a_proxy_verb?
9
+
10
+ def self.classification
11
+ Classification::Semideponent
12
+ end
13
+
14
+ def applicable?
15
+ first_pres_matches_semi_deponent_list? && !@classifier.proxy_verb?
16
+ end
17
+
18
+ private
19
+
20
+ def first_pres_matches_semi_deponent_list?
21
+ Linguistics::Latin::Verb::SEMI_DEPONENTS.keys.any? do |semi_dep_member|
22
+ first_pres=~/#{semi_dep_member}$/
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class Classifier
6
+ class VerbClassificationStrategy
7
+ def initialize(classifier)
8
+ @classifier = classifier
9
+ end
10
+
11
+ protected
12
+
13
+ def first_pres
14
+ return "" unless input
15
+ input.split(/\s+/)[0]
16
+ end
17
+
18
+ def infinitive
19
+ return "" unless input
20
+ input.split(/\s+/)[1]
21
+ end
22
+
23
+ def input
24
+ @classifier.input || ''
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ #encoding: UTF-8
2
+ module Linguistics
3
+ module Latin
4
+ module Verb
5
+ class LatinVerb
6
+ class Classifier
7
+ class VeryIrregularVerbClassificationStrategy < VerbClassificationStrategy
8
+ # Very irregular irregulars, A&G206, e/f
9
+ def self.classification
10
+ Classification::Irregular
11
+ end
12
+
13
+ def applicable?
14
+ input =~ %r'^(aiō|quaesō|ovāre)$'
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module LatinverbClassifier
2
+ VERSION = "1.0.0.pre.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ require "forwardable"
2
+
3
+ require 'linguistics_latin'
4
+
5
+ require 'latinverb_classifier/strategies/verb_classification_strategy'
6
+ require 'latinverb_classifier/strategies/defective_verb_classification_strategy'
7
+ require 'latinverb_classifier/strategies/irregular_verb_classification_strategy'
8
+ require 'latinverb_classifier/strategies/semideponent_verb_classification_strategy'
9
+ require 'latinverb_classifier/strategies/impersonal_verb_classification_strategy'
10
+ require 'latinverb_classifier/strategies/very_irregular_verb_classification_strategy'
11
+ require 'latinverb_classifier/strategies/deponent_verb_classification_strategy'
12
+ require 'latinverb_classifier/strategies/present_only_verb_classification_strategy'
13
+ require 'latinverb_classifier/strategies/regular_verb_classification_strategy'
14
+ require "latinverb_classifier/version"
15
+ require "latinverb_classifier/classifier"
16
+ require "latinverb_classifier/present_only_checker"
17
+
18
+ module Linguistics
19
+ module Latin
20
+ module Verb
21
+ class LatinVerb
22
+ class Classifier
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ class TestLatinverbClassifier < Minitest::Test
2
+ def test_regular_is_regular
3
+ stub_verb = OpenStruct.new original_string: 'fooby'
4
+ assert Linguistics::Latin::Verb::LatinVerb::Classifier.new(stub_verb).regular?, "stub_verb should be regular"
5
+ end
6
+
7
+ def test_to_love_is_regular
8
+ a_first_verb = OpenStruct.new original_string: 'amō amāre amāvī amatum'
9
+ assert Linguistics::Latin::Verb::LatinVerb::Classifier.new(a_first_verb).regular?, "stub_verb should be regular"
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: latinverb_classifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre.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: linguistics_latin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.2
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
+ description:
56
+ email:
57
+ - sgharms@stevengharms.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - latinverb_classifier.gemspec
68
+ - lib/latinverb_classifier.rb
69
+ - lib/latinverb_classifier/classifier.rb
70
+ - lib/latinverb_classifier/present_only_checker.rb
71
+ - lib/latinverb_classifier/strategies/defective_verb_classification_strategy.rb
72
+ - lib/latinverb_classifier/strategies/deponent_verb_classification_strategy.rb
73
+ - lib/latinverb_classifier/strategies/impersonal_verb_classification_strategy.rb
74
+ - lib/latinverb_classifier/strategies/irregular_verb_classification_strategy.rb
75
+ - lib/latinverb_classifier/strategies/present_only_verb_classification_strategy.rb
76
+ - lib/latinverb_classifier/strategies/regular_verb_classification_strategy.rb
77
+ - lib/latinverb_classifier/strategies/semideponent_verb_classification_strategy.rb
78
+ - lib/latinverb_classifier/strategies/verb_classification_strategy.rb
79
+ - lib/latinverb_classifier/strategies/very_irregular_verb_classification_strategy.rb
80
+ - lib/latinverb_classifier/version.rb
81
+ - test/latinverb_classifier_test.rb
82
+ homepage: ''
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">"
98
+ - !ruby/object:Gem::Version
99
+ version: 1.3.1
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.2.2
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Library for classifying Latin verbs
106
+ test_files:
107
+ - test/latinverb_classifier_test.rb