zenlish 0.2.03 → 0.2.04
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 +4 -4
- data/CHANGELOG.md +21 -3
- data/lib/zenlish/lang/dictionary.rb +1 -2
- data/lib/zenlish/lang/zenlish_grammar.rb +2 -1
- data/lib/zenlish/lex/empty_lexicon_factory.rb +1 -1
- data/lib/zenlish/lex/lexicon.rb +6 -5
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/all_word_classes.rb +1 -1
- data/lib/zenlish/wclasses/auxiliary.rb +3 -2
- data/lib/zenlish/wclasses/auxiliary_be.rb +33 -1
- data/lib/zenlish/wclasses/auxiliary_do.rb +30 -0
- data/lib/zenlish/wclasses/irregular_verb.rb +1 -8
- data/lib/zenlish/wclasses/irregular_verb_be.rb +0 -14
- data/lib/zenlish/wclasses/irregular_verb_can.rb +34 -0
- data/lib/zenlish/wclasses/irregular_verb_do.rb +4 -8
- data/lib/zenlish/wclasses/irregular_verb_have.rb +0 -4
- data/lib/zenlish/wclasses/modal_verb_can.rb +25 -0
- data/lib/zenlish/wclasses/regular_verb.rb +3 -9
- data/lib/zenlish/wclasses/verb.rb +17 -5
- data/spec/zenlish/lang/dictionary_spec.rb +16 -14
- data/spec/zenlish/support/var2word.rb +2 -2
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +50 -0
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +7 -0
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +50 -0
- data/spec/zenlish/wclasses/verb_spec.rb +9 -2
- metadata +7 -3
- data/lib/zenlish/wclasses/modal_verb_could.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f8eb416dfdcb38d3018bfb7f8e3e86de27e38cf98b20c38313da455bcc100d
|
4
|
+
data.tar.gz: c6b2d420e07336d2e5b56293d244859817aca51f460917acc7fa281ec1444af8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d35e61322d51d9251aa4c8a68b96fb9f274cefc51144744996f07fca21169a1bc000667255b8c5e970cd132485a38fa6694f33d2160a7ebea2383dd7fee1fc6e
|
7
|
+
data.tar.gz: eb4be7dcc83750107d0a9b76b50eaf82a2d22153f4f1d5056115cace60e94ddeb1b0b6141fa0be1f3f1d6890e9e6c3cb15b1ac616263de95dcfa0b51384cd944
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,29 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
## [0.2.04] - 2020-02-09
|
3
|
+
Zenlish can now inflect all the verbs in its lexicon.
|
4
|
+
|
5
|
+
### Added
|
6
|
+
- Module `WordClasses::IrregularVerbCan` for cases where `can` isn't used as a modal verb.
|
7
|
+
|
8
|
+
## Changed
|
9
|
+
- File `dictionary.rb`: .
|
10
|
+
- Class `Lex::Lexicon`: more explicit error message in case of ambiguous lexeme search.
|
11
|
+
- Class `WClass::AuxiliaryBe`: added specific inflection table.
|
12
|
+
- Class `WClass::AuxiliaryDo`: added specific inflection table.
|
13
|
+
- Class `WClass::ModalVerbCan`: added specific inflection table.
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- Class `WordClass::IrregularVerb` fixed rule for gerund spelling for verbs ending with 'oe' or 'ye'.
|
17
|
+
- Class `WordClass::RegularVerb` fixed rule for gerund spelling for verbs ending with 'oe' or 'ye'.
|
18
|
+
|
1
19
|
# CHANGELOG
|
2
20
|
## [0.2.03] - 2020-02-07
|
3
21
|
Zenlish can now inflect the irregular verbs `be`, `do`, and `have`.
|
4
22
|
|
5
23
|
## Changed
|
6
|
-
- Class `WClass::
|
7
|
-
- Class `WClass::
|
8
|
-
- Class `WClass::
|
24
|
+
- Class `WClass::IrregularVerbBe`: added specific inflection table.
|
25
|
+
- Class `WClass::IrregularVerbDo`: added specific inflection table.
|
26
|
+
- Class `WClass::IrregularVerbHave`: added specific inflection table.
|
9
27
|
|
10
28
|
## [0.2.02] - 2020-02-06
|
11
29
|
Extending the inflection model to irregular verbs. Zenlish can inflect all irregular verbs in its dictionary (except modals and be).
|
@@ -56,7 +56,7 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
56
56
|
add_entry('big', 'Adjective')
|
57
57
|
add_entry('body', 'CommonNoun')
|
58
58
|
add_entry('but', 'Coordinator')
|
59
|
-
add_entry('can', '
|
59
|
+
add_entry('can', 'IrregularVerbCan')
|
60
60
|
add_entry('can', 'ModalVerbCan')
|
61
61
|
add_entry('cause', 'RegularVerb')
|
62
62
|
add_entry('change', 'RegularVerb')
|
@@ -65,7 +65,6 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
65
65
|
end
|
66
66
|
add_entry('contain', 'RegularVerb')
|
67
67
|
add_entry('container', 'CommonNoun')
|
68
|
-
add_entry('could', 'ModalVerbCould')
|
69
68
|
add_entry('damage', 'RegularVerb')
|
70
69
|
add_entry('die', 'RegularVerb')
|
71
70
|
add_entry('difficult', 'Adjective')
|
@@ -137,7 +137,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
137
137
|
rule 'tense' => 'AuxiliaryBe'
|
138
138
|
rule 'tense' => 'AuxiliaryDo'
|
139
139
|
rule 'tense' => 'ModalVerbCan'
|
140
|
-
|
140
|
+
|
141
141
|
|
142
142
|
#############
|
143
143
|
# NOUN PHRASE
|
@@ -232,6 +232,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
232
232
|
rule 'lexical_verb' => 'IrregularVerb'
|
233
233
|
rule 'lexical_verb' => 'IrregularLinkingVerb'
|
234
234
|
rule 'lexical_verb' => 'IrregularVerbBe'
|
235
|
+
rule 'lexical_verb' => 'IrregularVerbCan'
|
235
236
|
rule 'lexical_verb' => 'IrregularVerbDo'
|
236
237
|
rule 'lexical_verb' => 'IrregularVerbHave'
|
237
238
|
rule 'lexical_verb' => 'IrregularVerbKnow'
|
@@ -41,6 +41,7 @@ module Zenlish
|
|
41
41
|
add_wclass(aLexicon, WClasses::IrregularLinkingVerb)
|
42
42
|
add_wclass(aLexicon, WClasses::IrregularVerb)
|
43
43
|
add_wclass(aLexicon, WClasses::IrregularVerbBe)
|
44
|
+
add_wclass(aLexicon, WClasses::IrregularVerbCan)
|
44
45
|
add_wclass(aLexicon, WClasses::IrregularVerbDo)
|
45
46
|
add_wclass(aLexicon, WClasses::IrregularVerbHave)
|
46
47
|
add_wclass(aLexicon, WClasses::IrregularVerbKnow)
|
@@ -48,7 +49,6 @@ module Zenlish
|
|
48
49
|
add_wclass(aLexicon, WClasses::IrregularVerbThink)
|
49
50
|
add_wclass(aLexicon, WClasses::LinkingAdverb)
|
50
51
|
add_wclass(aLexicon, WClasses::ModalVerbCan)
|
51
|
-
add_wclass(aLexicon, WClasses::ModalVerbCould)
|
52
52
|
add_wclass(aLexicon, WClasses::PersonalPronoun)
|
53
53
|
add_wclass(aLexicon, WClasses::PossessiveDeterminer)
|
54
54
|
add_wclass(aLexicon, WClasses::Preposition)
|
data/lib/zenlish/lex/lexicon.rb
CHANGED
@@ -45,11 +45,12 @@ module Zenlish
|
|
45
45
|
|
46
46
|
lexeme
|
47
47
|
else
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
entry = lemma2entry.fetch(aLemma)
|
49
|
+
if entry.kind_of?(Array)
|
50
|
+
err_msg = "Multiple lexemes for #{aLemma}"
|
51
|
+
raise StandardError, err_msg
|
52
|
+
else
|
53
|
+
entry.lexemes.first
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
data/lib/zenlish/version.rb
CHANGED
@@ -20,6 +20,7 @@ require_relative 'proper_noun'
|
|
20
20
|
require_relative 'irregular_linking_verb'
|
21
21
|
require_relative 'irregular_verb'
|
22
22
|
require_relative 'irregular_verb_be'
|
23
|
+
require_relative 'irregular_verb_can'
|
23
24
|
require_relative 'irregular_verb_do'
|
24
25
|
require_relative 'irregular_verb_have'
|
25
26
|
require_relative 'irregular_verb_know'
|
@@ -32,7 +33,6 @@ require_relative 'indefinite_article'
|
|
32
33
|
require_relative 'indefinite_pronoun'
|
33
34
|
require_relative 'linking_adverb'
|
34
35
|
require_relative 'modal_verb_can'
|
35
|
-
require_relative 'modal_verb_could'
|
36
36
|
require_relative 'personal_pronoun'
|
37
37
|
require_relative 'possessive_determiner'
|
38
38
|
require_relative 'preposition'
|
@@ -2,9 +2,10 @@ require_relative 'verb'
|
|
2
2
|
|
3
3
|
module Zenlish
|
4
4
|
module WClasses
|
5
|
-
# The verbs: be, have, do
|
5
|
+
# The verbs: be, have, do and the modal verbs can, could, may, must, shall,
|
6
|
+
# should, will, would
|
6
7
|
# As they are so important to the English language, they deserve
|
7
|
-
# their own class
|
8
|
+
# their own class(es)
|
8
9
|
class Auxiliary < Verb
|
9
10
|
end # class
|
10
11
|
end # module
|
@@ -2,8 +2,40 @@ require_relative 'auxiliary'
|
|
2
2
|
|
3
3
|
module Zenlish
|
4
4
|
module WClasses
|
5
|
-
# TODO: document
|
6
5
|
class AuxiliaryBe < Auxiliary
|
6
|
+
def initialize
|
7
|
+
super()
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def init_feature_defs
|
13
|
+
super
|
14
|
+
# Create standard feature definitions for modal verb can.
|
15
|
+
feature_def_dsl {
|
16
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_be_inflection'] # 2nd item is default value
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def init_paradigms
|
21
|
+
builder = Inflect::InflectionTableBuilder.new
|
22
|
+
table = builder.build('Verb_be_inflection') do
|
23
|
+
feature_heading 'PERSON'
|
24
|
+
feature_heading 'NUMBER'
|
25
|
+
feature_heading 'TIME'
|
26
|
+
# PERSON NUMBER TIME
|
27
|
+
rule([equals(:first), equals(:singular), equals(:present) ], literal('am'))
|
28
|
+
rule([equals(:second), equals(:singular), equals(:present) ], literal('are'))
|
29
|
+
rule([equals(:third), equals(:singular), equals(:present) ], literal('is'))
|
30
|
+
rule([dont_care, equals(:plural), equals(:present) ], literal('are'))
|
31
|
+
rule([dont_care, dont_care, equals(:progressive) ], literal('being'))
|
32
|
+
rule([in?(:first, :third), equals(:singular), equals(:past_simple) ], literal('was'))
|
33
|
+
rule([equals(:second), equals(:singular), equals(:past_simple) ], literal('were'))
|
34
|
+
rule([dont_care, equals(:plural), equals(:past_simple) ], literal('were'))
|
35
|
+
rule([dont_care, dont_care, equals(:past_participle)], literal('been'))
|
36
|
+
end
|
37
|
+
add_paradigm(table)
|
38
|
+
end
|
7
39
|
end # class
|
8
40
|
end # module
|
9
41
|
end # module
|
@@ -4,6 +4,36 @@ module Zenlish
|
|
4
4
|
module WClasses
|
5
5
|
# TODO: document
|
6
6
|
class AuxiliaryDo < Auxiliary
|
7
|
+
def initialize
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def init_feature_defs
|
14
|
+
super
|
15
|
+
# Create standard feature definitions for modal verb can.
|
16
|
+
feature_def_dsl {
|
17
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_do_inflection'] # 2nd item is default value
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def init_paradigms
|
22
|
+
builder = Inflect::InflectionTableBuilder.new
|
23
|
+
table = builder.build('Verb_do_inflection') do
|
24
|
+
feature_heading 'PERSON'
|
25
|
+
feature_heading 'NUMBER'
|
26
|
+
feature_heading 'TIME'
|
27
|
+
# PERSON NUMBER TIME
|
28
|
+
rule([not_equal(:third), equals(:singular), equals(:present) ], literal('do'))
|
29
|
+
rule([equals(:third), equals(:singular), equals(:present) ], literal('does'))
|
30
|
+
rule([dont_care, equals(:plural), equals(:present) ], literal('do'))
|
31
|
+
rule([dont_care, dont_care, equals(:progressive) ], literal('doing'))
|
32
|
+
rule([dont_care, dont_care, equals(:past_simple) ], literal('did'))
|
33
|
+
rule([dont_care, dont_care, equals(:past_participle)], literal('done'))
|
34
|
+
end
|
35
|
+
add_paradigm(table)
|
36
|
+
end
|
7
37
|
end # class
|
8
38
|
end # module
|
9
39
|
end # module
|
@@ -9,9 +9,6 @@ module Zenlish
|
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
super()
|
12
|
-
@paradigms = {}
|
13
|
-
init_feature_defs
|
14
|
-
init_paradigms
|
15
12
|
end
|
16
13
|
|
17
14
|
# The mix-in module used to extend the lexeme
|
@@ -43,16 +40,12 @@ module Zenlish
|
|
43
40
|
rule([equals(:third), equals(:singular), equals(:present), matches(/(?:[osxz]|ch|sh)$/)], concat(col('base_form'), 'es'))
|
44
41
|
rule([equals(:third), equals(:singular), equals(:present), dont_care], concat(col('base_form'), 's'))
|
45
42
|
rule([dont_care, dont_care, equals(:progressive), matches(/ie$/)], sub(col('base_form'), /ie$/, 'ying'))
|
46
|
-
rule([dont_care, dont_care, equals(:progressive), matches(/[^
|
43
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/[^eoy]e$/)], sub(col('base_form'), /e$/, 'ing'))
|
47
44
|
rule([dont_care, dont_care, equals(:progressive), dont_care], concat(col('base_form'), 'ing'))
|
48
45
|
rule([dont_care, dont_care, equals(:past_simple), dont_care], func('past_simple'))
|
49
46
|
rule([dont_care, dont_care, equals(:past_participle), dont_care], func('past_participle'))
|
50
47
|
end
|
51
48
|
add_paradigm(table)
|
52
|
-
end
|
53
|
-
|
54
|
-
def add_paradigm(anInflectionTable)
|
55
|
-
@paradigms[anInflectionTable.name] = anInflectionTable
|
56
49
|
end
|
57
50
|
end # class
|
58
51
|
end # module
|
@@ -43,20 +43,6 @@ module Zenlish
|
|
43
43
|
end
|
44
44
|
add_paradigm(table)
|
45
45
|
end
|
46
|
-
|
47
|
-
def add_paradigm(anInflectionTable)
|
48
|
-
@paradigms[anInflectionTable.name] = anInflectionTable
|
49
|
-
end
|
50
46
|
end # class
|
51
|
-
=begin
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
=end
|
61
47
|
end # module
|
62
48
|
end # module
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'irregular_verb'
|
2
|
+
|
3
|
+
module Zenlish
|
4
|
+
module WClasses
|
5
|
+
# Irregular verb can
|
6
|
+
class IrregularVerbCan < IrregularVerb
|
7
|
+
def initialize
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def init_feature_defs
|
14
|
+
super
|
15
|
+
# Create standard feature definitions for modal verb can.
|
16
|
+
feature_def_dsl {
|
17
|
+
feature_def 'TIME' => enumeration(:present, :past_simple)
|
18
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_can_inflection'] # 2nd item is default value
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def init_paradigms
|
23
|
+
builder = Inflect::InflectionTableBuilder.new
|
24
|
+
table = builder.build('Verb_can_inflection') do
|
25
|
+
feature_heading 'TIME'
|
26
|
+
# TIME
|
27
|
+
rule([equals(:present) ], literal('can'))
|
28
|
+
rule([equals(:past_simple) ], literal('could'))
|
29
|
+
end
|
30
|
+
add_paradigm(table)
|
31
|
+
end
|
32
|
+
end # class
|
33
|
+
end # module
|
34
|
+
end # module
|
@@ -7,12 +7,12 @@ module Zenlish
|
|
7
7
|
def initialize
|
8
8
|
super()
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
# The mix-in module used to extend the lexeme
|
12
12
|
# @return [Module, NilClass]
|
13
13
|
def extension
|
14
14
|
nil
|
15
|
-
end
|
15
|
+
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
@@ -31,19 +31,15 @@ module Zenlish
|
|
31
31
|
feature_heading 'NUMBER'
|
32
32
|
feature_heading 'TIME'
|
33
33
|
# PERSON NUMBER TIME
|
34
|
-
rule([not_equal(:third), equals(:singular), equals(:present)
|
34
|
+
rule([not_equal(:third), equals(:singular), equals(:present) ], literal('do'))
|
35
35
|
rule([equals(:third), equals(:singular), equals(:present) ], literal('does'))
|
36
36
|
rule([dont_care, equals(:plural), equals(:present) ], literal('do'))
|
37
37
|
rule([dont_care, dont_care, equals(:progressive) ], literal('doing'))
|
38
|
-
rule([dont_care, dont_care, equals(:past_simple) ], literal('did'))
|
38
|
+
rule([dont_care, dont_care, equals(:past_simple) ], literal('did'))
|
39
39
|
rule([dont_care, dont_care, equals(:past_participle)], literal('done'))
|
40
40
|
end
|
41
41
|
add_paradigm(table)
|
42
42
|
end
|
43
|
-
|
44
|
-
def add_paradigm(anInflectionTable)
|
45
|
-
@paradigms[anInflectionTable.name] = anInflectionTable
|
46
|
-
end
|
47
43
|
end # class
|
48
44
|
end # module
|
49
45
|
end # module
|
@@ -39,10 +39,6 @@ module Zenlish
|
|
39
39
|
rule([dont_care, dont_care, equals(:past_participle)], literal('had'))
|
40
40
|
end
|
41
41
|
add_paradigm(table)
|
42
|
-
end
|
43
|
-
|
44
|
-
def add_paradigm(anInflectionTable)
|
45
|
-
@paradigms[anInflectionTable.name] = anInflectionTable
|
46
42
|
end
|
47
43
|
end # class
|
48
44
|
end # module
|
@@ -4,6 +4,31 @@ module Zenlish
|
|
4
4
|
module WClasses
|
5
5
|
# The modal verb `can`
|
6
6
|
class ModalVerbCan < Auxiliary
|
7
|
+
def initialize
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def init_feature_defs
|
14
|
+
super
|
15
|
+
# Create standard feature definitions for modal verb can.
|
16
|
+
feature_def_dsl {
|
17
|
+
feature_def 'TIME' => enumeration(:present, :past_simple)
|
18
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_can_inflection'] # 2nd item is default value
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def init_paradigms
|
23
|
+
builder = Inflect::InflectionTableBuilder.new
|
24
|
+
table = builder.build('Verb_can_inflection') do
|
25
|
+
feature_heading 'TIME'
|
26
|
+
# TIME
|
27
|
+
rule([equals(:present) ], literal('can'))
|
28
|
+
rule([equals(:past_simple) ], literal('could'))
|
29
|
+
end
|
30
|
+
add_paradigm(table)
|
31
|
+
end
|
7
32
|
end # class
|
8
33
|
end # module
|
9
34
|
end # module
|
@@ -5,8 +5,6 @@ module Zenlish
|
|
5
5
|
class RegularVerb < LexicalVerb
|
6
6
|
def initialize
|
7
7
|
super
|
8
|
-
@paradigms = {}
|
9
|
-
init_paradigms
|
10
8
|
end
|
11
9
|
|
12
10
|
private
|
@@ -23,19 +21,15 @@ module Zenlish
|
|
23
21
|
rule([equals(:third), equals(:singular), equals(:present), matches(/[^aeiouy]y$/)], sub(col('base_form'), /y$/, 'ies'))
|
24
22
|
rule([equals(:third), equals(:singular), equals(:present), matches(/(?:[osxz]|ch|sh)$/)], concat(col('base_form'), 'es'))
|
25
23
|
rule([equals(:third), equals(:singular), equals(:present), dont_care], concat(col('base_form'), 's'))
|
26
|
-
rule([dont_care, dont_care, equals(:progressive),
|
27
|
-
rule([dont_care, dont_care, equals(:progressive),
|
28
|
-
rule([dont_care, dont_care, equals(:progressive),
|
24
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/ie$/)], sub(col('base_form'), /ie$/, 'ying'))
|
25
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/[^eoy]e$/)], sub(col('base_form'), /e$/, 'ing'))
|
26
|
+
rule([dont_care, dont_care, equals(:progressive), dont_care], concat(col('base_form'), 'ing'))
|
29
27
|
rule([dont_care, dont_care, in?(:past_simple, :past_participle), matches(/e$/)], concat(col('base_form'), 'd'))
|
30
28
|
rule([dont_care, dont_care, in?(:past_simple, :past_participle), matches(/[^aeiouy]y$/)], sub(col('base_form'), /y$/, 'ied'))
|
31
29
|
rule([dont_care, dont_care, in?(:past_simple, :past_participle), dont_care], concat(col('base_form'), 'ed'))
|
32
30
|
end
|
33
31
|
add_paradigm(table)
|
34
32
|
end
|
35
|
-
|
36
|
-
def add_paradigm(anInflectionTable)
|
37
|
-
@paradigms[anInflectionTable.name] = anInflectionTable
|
38
|
-
end
|
39
33
|
end # class
|
40
34
|
end # module
|
41
35
|
end # module
|
@@ -3,21 +3,29 @@ require_relative '../inflect/inflection_table_builder'
|
|
3
3
|
|
4
4
|
module Zenlish
|
5
5
|
module WClasses
|
6
|
-
# Abstract class. In traditional grammar, the verb is often defined
|
6
|
+
# Abstract class. In traditional grammar, the verb is often defined
|
7
7
|
# notionally as a 'doing' word (i.e. a word that describes the action
|
8
8
|
# in a clause).
|
9
9
|
class Verb < WordClass
|
10
10
|
def initialize
|
11
11
|
super()
|
12
|
+
@paradigms = {}
|
12
13
|
init_feature_defs
|
13
|
-
|
14
|
-
|
14
|
+
init_paradigms
|
15
|
+
end
|
16
|
+
|
15
17
|
# As all verbs inflect, or change form, to reflect changes in tense,
|
16
18
|
# person, number, and voice, they are, by definition, variable.
|
17
19
|
def invariable?
|
18
20
|
false
|
19
21
|
end
|
20
22
|
|
23
|
+
protected
|
24
|
+
|
25
|
+
def add_paradigm(anInflectionTable)
|
26
|
+
@paradigms[anInflectionTable.name] = anInflectionTable
|
27
|
+
end
|
28
|
+
|
21
29
|
private
|
22
30
|
|
23
31
|
def init_feature_defs
|
@@ -25,10 +33,14 @@ module Zenlish
|
|
25
33
|
feature_def_dsl {
|
26
34
|
feature_def 'NUMBER' => enumeration(:singular, :plural)
|
27
35
|
feature_def 'PERSON' => enumeration(:first, :second, :third)
|
28
|
-
feature_def 'TIME' => enumeration(:present, :progressive, :past_simple, :past_participle)
|
36
|
+
feature_def 'TIME' => enumeration(:present, :progressive, :past_simple, :past_participle)
|
29
37
|
feature_def 'PARADIGM' => [identifier, 'Regular_inflection'] # 2nd item is default value
|
30
38
|
}
|
31
|
-
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def init_paradigms
|
42
|
+
raise NotImplementedError, "Method #{__callee__} must implemented for #{self.class}."
|
43
|
+
end
|
32
44
|
end # class
|
33
45
|
end # module
|
34
46
|
end # module
|
@@ -81,20 +81,22 @@ module Zenlish
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should know how to inflect the verb be' do
|
84
|
-
|
85
|
-
|
86
|
-
[
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
84
|
+
[WClasses::IrregularVerbBe, WClasses::AuxiliaryBe].each do |wclass|
|
85
|
+
lexm = subject.get_lexeme('be', wclass)
|
86
|
+
expectations_1 = [
|
87
|
+
[present_1sg, 'am'],
|
88
|
+
[present_2sg, 'are'],
|
89
|
+
[present_3sg, 'is'],
|
90
|
+
[present_1pl, 'are'],
|
91
|
+
[progressive, 'being'],
|
92
|
+
[past_simple, 'was'],
|
93
|
+
[past_simple_2sg, 'were'],
|
94
|
+
[past_simple_3sg, 'was'],
|
95
|
+
[past_simple_1pl, 'were'],
|
96
|
+
[past_participle, 'been']
|
97
|
+
]
|
98
|
+
test_inflection_of(lexm, expectations_1, true)
|
99
|
+
end
|
98
100
|
end
|
99
101
|
|
100
102
|
end # context
|
@@ -56,7 +56,7 @@ module Zenlish
|
|
56
56
|
literal2var('body', 'body')
|
57
57
|
literal2var('but', 'but')
|
58
58
|
def can ; Lex::Literal.new('can', get_lexeme('can', WClasses::ModalVerbCan), 0) ; end
|
59
|
-
def can_irregular ; Lex::Literal.new('can', get_lexeme('can', WClasses::
|
59
|
+
def can_irregular ; Lex::Literal.new('can', get_lexeme('can', WClasses::IrregularVerbCan), 0) ; end
|
60
60
|
literal2var('cause', 'cause')
|
61
61
|
literal2var('cause', 'caused')
|
62
62
|
literal2var('cause', 'causes')
|
@@ -69,7 +69,7 @@ module Zenlish
|
|
69
69
|
literal2var('contain', 'contains')
|
70
70
|
literal2var('container', 'container')
|
71
71
|
literal2var('container', 'containers')
|
72
|
-
|
72
|
+
def could ; Lex::Literal.new('could', get_lexeme('can', WClasses::ModalVerbCan), 0) ; end
|
73
73
|
literal2var('damage', 'damaged')
|
74
74
|
def did ; Lex::Literal.new('did', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
|
75
75
|
literal2var('die', 'die')
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../spec_helper' # Use the RSpec framework
|
4
|
+
require_relative '../../../lib/zenlish/lex/lexical_entry'
|
5
|
+
require_relative '../../../lib/zenlish/lex/lexeme'
|
6
|
+
|
7
|
+
# Load the class under test
|
8
|
+
require_relative '../../../lib/zenlish/wclasses/irregular_verb_can'
|
9
|
+
|
10
|
+
module Zenlish
|
11
|
+
module WClasses
|
12
|
+
describe IrregularVerbCan do
|
13
|
+
subject { IrregularVerbCan.new }
|
14
|
+
|
15
|
+
context 'Initialization:' do
|
16
|
+
it 'should be initialized without argument' do
|
17
|
+
expect { IrregularVerbCan.new }.not_to raise_error
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
21
|
+
context 'Provided services:' do
|
22
|
+
it 'should know its inherited feature definitions' do
|
23
|
+
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
24
|
+
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
25
|
+
expect(subject['PARADIGM'].default.val).to eq('Verb_can_inflection')
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_verb(aBaseForm)
|
29
|
+
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
30
|
+
lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_inflection_of(verb_form, pairs)
|
34
|
+
verb = build_verb(verb_form)
|
35
|
+
pairs.each do |(time, expected_form)|
|
36
|
+
expect(verb.inflect([time])).to eq(expected_form)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should know how to inflect modal verb can' do
|
41
|
+
expectations_1 = [
|
42
|
+
[:present, 'can'],
|
43
|
+
[:past_simple, 'could']
|
44
|
+
]
|
45
|
+
test_inflection_of('can', expectations_1)
|
46
|
+
end
|
47
|
+
end # context
|
48
|
+
end # describe
|
49
|
+
end # module
|
50
|
+
end # module
|
@@ -7,6 +7,13 @@ require_relative '../../../lib/zenlish/wclasses/lexical_verb'
|
|
7
7
|
|
8
8
|
module Zenlish
|
9
9
|
module WClasses
|
10
|
+
class LexicalVerb
|
11
|
+
# Do limited monkeypatching, just for testing purposes
|
12
|
+
def init_paradigms
|
13
|
+
# Empty method
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
describe LexicalVerb do
|
11
18
|
subject { LexicalVerb.new }
|
12
19
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../spec_helper' # Use the RSpec framework
|
4
|
+
require_relative '../../../lib/zenlish/lex/lexical_entry'
|
5
|
+
require_relative '../../../lib/zenlish/lex/lexeme'
|
6
|
+
|
7
|
+
# Load the class under test
|
8
|
+
require_relative '../../../lib/zenlish/wclasses/modal_verb_can'
|
9
|
+
|
10
|
+
module Zenlish
|
11
|
+
module WClasses
|
12
|
+
describe ModalVerbCan do
|
13
|
+
subject { ModalVerbCan.new }
|
14
|
+
|
15
|
+
context 'Initialization:' do
|
16
|
+
it 'should be initialized without argument' do
|
17
|
+
expect { ModalVerbCan.new }.not_to raise_error
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
21
|
+
context 'Provided services:' do
|
22
|
+
it 'should know its inherited feature definitions' do
|
23
|
+
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
24
|
+
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
25
|
+
expect(subject['PARADIGM'].default.val).to eq('Verb_can_inflection')
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_verb(aBaseForm)
|
29
|
+
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
30
|
+
lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_inflection_of(verb_form, pairs)
|
34
|
+
verb = build_verb(verb_form)
|
35
|
+
pairs.each do |(time, expected_form)|
|
36
|
+
expect(verb.inflect([time])).to eq(expected_form)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should know how to inflect modal verb can' do
|
41
|
+
expectations_1 = [
|
42
|
+
[:present, 'can'],
|
43
|
+
[:past_simple, 'could']
|
44
|
+
]
|
45
|
+
test_inflection_of('can', expectations_1)
|
46
|
+
end
|
47
|
+
end # context
|
48
|
+
end # describe
|
49
|
+
end # module
|
50
|
+
end # module
|
@@ -5,6 +5,13 @@ require_relative '../../../lib/zenlish/wclasses/verb' # Load the class under tes
|
|
5
5
|
|
6
6
|
module Zenlish
|
7
7
|
module WClasses
|
8
|
+
class Verb
|
9
|
+
# Do limited monkeypatching, just for testing purposes
|
10
|
+
def init_paradigms
|
11
|
+
# Empty method
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
8
15
|
describe Verb do
|
9
16
|
subject { Verb.new }
|
10
17
|
|
@@ -18,11 +25,11 @@ module Zenlish
|
|
18
25
|
it 'should know that it has inflected forms' do
|
19
26
|
expect(subject).not_to be_invariable
|
20
27
|
end
|
21
|
-
|
28
|
+
|
22
29
|
it 'should know its feature definitions' do
|
23
30
|
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
24
31
|
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
25
|
-
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
32
|
+
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
26
33
|
end
|
27
34
|
end # context
|
28
35
|
end # describe
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenlish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.04
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/zenlish/wclasses/irregular_linking_verb.rb
|
159
159
|
- lib/zenlish/wclasses/irregular_verb.rb
|
160
160
|
- lib/zenlish/wclasses/irregular_verb_be.rb
|
161
|
+
- lib/zenlish/wclasses/irregular_verb_can.rb
|
161
162
|
- lib/zenlish/wclasses/irregular_verb_do.rb
|
162
163
|
- lib/zenlish/wclasses/irregular_verb_extension.rb
|
163
164
|
- lib/zenlish/wclasses/irregular_verb_have.rb
|
@@ -167,7 +168,6 @@ files:
|
|
167
168
|
- lib/zenlish/wclasses/lexical_verb.rb
|
168
169
|
- lib/zenlish/wclasses/linking_adverb.rb
|
169
170
|
- lib/zenlish/wclasses/modal_verb_can.rb
|
170
|
-
- lib/zenlish/wclasses/modal_verb_could.rb
|
171
171
|
- lib/zenlish/wclasses/noun.rb
|
172
172
|
- lib/zenlish/wclasses/numeral.rb
|
173
173
|
- lib/zenlish/wclasses/personal_pronoun.rb
|
@@ -225,9 +225,11 @@ files:
|
|
225
225
|
- spec/zenlish/support/minimal_lexicon.rb
|
226
226
|
- spec/zenlish/support/var2word.rb
|
227
227
|
- spec/zenlish/wclasses/common_noun_spec.rb
|
228
|
+
- spec/zenlish/wclasses/irregular_verb_can_spec.rb
|
228
229
|
- spec/zenlish/wclasses/irregular_verb_extension_spec.rb
|
229
230
|
- spec/zenlish/wclasses/irregular_verb_spec.rb
|
230
231
|
- spec/zenlish/wclasses/lexical_verb_spec.rb
|
232
|
+
- spec/zenlish/wclasses/modal_verb_can_spec.rb
|
231
233
|
- spec/zenlish/wclasses/noun_spec.rb
|
232
234
|
- spec/zenlish/wclasses/preposition_spec.rb
|
233
235
|
- spec/zenlish/wclasses/proper_noun_spec.rb
|
@@ -298,9 +300,11 @@ test_files:
|
|
298
300
|
- spec/zenlish/parser/lesson3_spec.rb
|
299
301
|
- spec/zenlish/parser/zparser_spec.rb
|
300
302
|
- spec/zenlish/wclasses/common_noun_spec.rb
|
303
|
+
- spec/zenlish/wclasses/irregular_verb_can_spec.rb
|
301
304
|
- spec/zenlish/wclasses/irregular_verb_extension_spec.rb
|
302
305
|
- spec/zenlish/wclasses/irregular_verb_spec.rb
|
303
306
|
- spec/zenlish/wclasses/lexical_verb_spec.rb
|
307
|
+
- spec/zenlish/wclasses/modal_verb_can_spec.rb
|
304
308
|
- spec/zenlish/wclasses/noun_spec.rb
|
305
309
|
- spec/zenlish/wclasses/preposition_spec.rb
|
306
310
|
- spec/zenlish/wclasses/proper_noun_spec.rb
|