zenlish 0.2.01 → 0.2.02
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +19 -4
- data/lib/zenlish/lang/dictionary.rb +27 -9
- data/lib/zenlish/lex/lexeme.rb +9 -4
- data/lib/zenlish/lex/lexical_entry.rb +10 -3
- data/lib/zenlish/lex/lexicon.rb +5 -0
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/adjective.rb +4 -0
- data/lib/zenlish/wclasses/adverb.rb +1 -1
- data/lib/zenlish/wclasses/comparative_particle.rb +1 -1
- data/lib/zenlish/wclasses/coordinator.rb +1 -1
- data/lib/zenlish/wclasses/determiner.rb +1 -1
- data/lib/zenlish/wclasses/fronting_quantifier.rb +1 -1
- data/lib/zenlish/wclasses/irregular_verb.rb +39 -13
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +39 -0
- data/lib/zenlish/wclasses/preposition.rb +1 -6
- data/lib/zenlish/wclasses/pronoun.rb +1 -1
- data/lib/zenlish/wclasses/quantifier.rb +1 -1
- data/lib/zenlish/wclasses/regular_verb.rb +3 -3
- data/lib/zenlish/wclasses/subordinating_conjunction.rb +1 -1
- data/lib/zenlish/wclasses/word_class.rb +7 -1
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +26 -27
- data/spec/zenlish/lang/dictionary_spec.rb +36 -0
- data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +37 -0
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +53 -2
- data/spec/zenlish/wclasses/regular_verb_spec.rb +12 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a4f38ce593249cf97998ec7d51977400b6bb1445a368823b3c8db0f779aec41
|
4
|
+
data.tar.gz: 30e519af42ccf67586f3314892d63a8150200e671a4c42e5185154746ea2218d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 007460f06685b5a84c239b70f14503d1420deffd8291b087bea657a966292e3c04be01f3dd973cbd7e6f543ba1e0daf86afad73d2085da2b7c23ad5c3e3e7624
|
7
|
+
data.tar.gz: 9a3a5904dfd78edbb50a7886d1d830e400619039bc736760356381c9845dd9ec2919089c0803c64ffef89b2d9d55fe0b061b4542e25a1371550c6863a7d4aafa
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
# CHANGELOG
|
2
|
+
## [0.2.02] - 2020-02-06
|
3
|
+
Extending the inflection model to irregular verbs. Zenlish can inflect all irregular verbs in its dictionary (except modals and be).
|
4
|
+
|
5
|
+
### Added
|
6
|
+
- Module `WordClasses::IreegularVerbExtension` mix-in module for extending the lexeme for irregular verbs.
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
- File `dictionary.rb`: added past simple and past participles to most irregular verbs in lexicon.
|
10
|
+
- Class `Lex::Lexeme`: added capability of word class to add dynamically extension (specialization) to lexeme instances.
|
11
|
+
- Class `WordClass::IrregularVerb` added inflection table.
|
12
|
+
- File `.travis.yml` Added Ruby 2.7 and increased version number for other rubies.
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Class `WordClass::RegularVerb` fixed rules for gerund spelling.
|
16
|
+
|
2
17
|
## [0.2.01] - 2020-02-02
|
3
18
|
Extending the inflection table capabilities.
|
4
19
|
Extending the inflection model to regular verbs. Zenlish can inflect all regular verbs in its dictionary.
|
@@ -26,7 +41,7 @@ This is WIP.
|
|
26
41
|
## [0.1.25] - 2019-12-06
|
27
42
|
__Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-G (352 sentences in total) from
|
28
43
|
[Learn These Words First](http://learnthesewordsfirst.com/).
|
29
|
-
|
44
|
+
|
30
45
|
### Changed
|
31
46
|
- File `lesson3_spec.rb`: tests include all sentences from lesson 3-A to 3-G.
|
32
47
|
- `ZenlishGrammar`: refactoring of the predicative_sentence rules.
|
@@ -40,7 +55,7 @@ __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-F (323 sentences
|
|
40
55
|
### Added
|
41
56
|
- Class `ModalVerbCould` to represent the auxiliary verb `could`.
|
42
57
|
- Support module `Var2Word`: used to create variable names and assign them specific `Literal` objects.
|
43
|
-
|
58
|
+
|
44
59
|
### Changed
|
45
60
|
- File `zparser_spec.rb` splitted. Lesson-specific test suites have their own spec file.
|
46
61
|
- File `lesson3_spec.rb`: tests include all sentences from lesson 3-A .. 3-F.
|
@@ -73,7 +88,7 @@ __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-C from
|
|
73
88
|
[Learn These Words First](http://learnthesewordsfirst.com/).
|
74
89
|
|
75
90
|
### Added
|
76
|
-
- Class `DistributiveDeterminer` to represent the words `each`, `every`, `either`, `neither`.
|
91
|
+
- Class `DistributiveDeterminer` to represent the words `each`, `every`, `either`, `neither`.
|
77
92
|
- Class `FrontingQuantifier` to represent the quantifiers `all` and `both`.
|
78
93
|
|
79
94
|
### Changed
|
@@ -140,7 +155,7 @@ __Zenlish__ can parse all sentences in lesson 1 and 2-A..2-H from
|
|
140
155
|
## [0.1.16] - 2019-11-23
|
141
156
|
__Zenlish__ can parse all sentences in lesson 1 and 2-A..2-G from
|
142
157
|
[Learn These Words First](http://learnthesewordsfirst.com/).
|
143
|
-
|
158
|
+
|
144
159
|
### Changed
|
145
160
|
- `ZenlishGrammar`: Vast grammar reworking.
|
146
161
|
- File `dictionary.rb`: `there` in lexicon has `ExistentialThere` as word class.
|
@@ -43,7 +43,9 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
43
43
|
add_entry('be', 'AuxiliaryBe')
|
44
44
|
add_entry('be', 'IrregularVerbBe')
|
45
45
|
add_entry('because', 'SubordinatingConjunction')
|
46
|
-
add_entry('become', 'IrregularLinkingVerb')
|
46
|
+
add_entry('become', 'IrregularLinkingVerb') do
|
47
|
+
forms past_simple: 'became', past_participle: 'become'
|
48
|
+
end
|
47
49
|
add_entry('before', 'Adverb')
|
48
50
|
add_entry('before', 'Adjective')
|
49
51
|
add_entry('before', 'Preposition')
|
@@ -58,7 +60,9 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
58
60
|
add_entry('can', 'ModalVerbCan')
|
59
61
|
add_entry('cause', 'RegularVerb')
|
60
62
|
add_entry('change', 'RegularVerb')
|
61
|
-
add_entry('choose', 'IrregularVerb')
|
63
|
+
add_entry('choose', 'IrregularVerb') do
|
64
|
+
forms past_simple: 'chose', past_participle: 'chosen'
|
65
|
+
end
|
62
66
|
add_entry('contain', 'RegularVerb')
|
63
67
|
add_entry('container', 'CommonNoun')
|
64
68
|
add_entry('could', 'ModalVerbCould')
|
@@ -67,14 +71,18 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
67
71
|
add_entry('difficult', 'Adjective')
|
68
72
|
add_entry('different', 'Adjective')
|
69
73
|
add_entry('do', 'AuxiliaryDo')
|
70
|
-
add_entry('do', 'IrregularVerbDo')
|
74
|
+
add_entry('do', 'IrregularVerbDo') do
|
75
|
+
forms past_simple: 'did', past_participle: 'done'
|
76
|
+
end
|
71
77
|
add_entry('each', 'DistributiveDeterminer')
|
72
78
|
add_entry('each', 'Pronoun')
|
73
79
|
add_entry('exist', 'RegularVerb')
|
74
80
|
add_entry('false', 'Adjective')
|
75
81
|
add_entry('far', 'Adverb')
|
76
82
|
add_entry('far from', 'Preposition')
|
77
|
-
add_entry('feel', 'IrregularLinkingVerb')
|
83
|
+
add_entry('feel', 'IrregularLinkingVerb') do
|
84
|
+
forms past_simple: 'felt', past_participle: 'felt'
|
85
|
+
end
|
78
86
|
add_entry('for', 'Preposition')
|
79
87
|
add_entry('from', 'Preposition')
|
80
88
|
add_entry('good', 'Adjective')
|
@@ -92,13 +100,17 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
92
100
|
add_entry('it', 'PersonalPronoun')
|
93
101
|
add_entry('its', 'PossessiveDeterminer')
|
94
102
|
add_entry('kind', 'CommonNoun')
|
95
|
-
add_entry('know', 'IrregularVerbKnow')
|
103
|
+
add_entry('know', 'IrregularVerbKnow') do
|
104
|
+
forms past_simple: 'knew', past_participle: 'known'
|
105
|
+
end
|
96
106
|
add_entry('like', 'Preposition')
|
97
107
|
add_entry('live', 'RegularVerb')
|
98
108
|
add_entry('living', 'Adjective')
|
99
109
|
add_entry('long', 'Adjective')
|
100
110
|
add_entry('machine', 'CommonNoun')
|
101
|
-
add_entry('make', 'IrregularVerb')
|
111
|
+
add_entry('make', 'IrregularVerb') do
|
112
|
+
forms past_simple: 'made', past_participle: 'made'
|
113
|
+
end
|
102
114
|
add_entry('many', 'Quantifier')
|
103
115
|
add_entry('maybe', 'AdverbMaybe')
|
104
116
|
add_entry('me', 'PersonalPronoun')
|
@@ -129,8 +141,12 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
129
141
|
add_entry('place', 'CommonNoun')
|
130
142
|
add_entry('same', 'Adjective')
|
131
143
|
add_entry('same', 'Pronoun')
|
132
|
-
add_entry('say', 'IrregularVerbSay')
|
133
|
-
|
144
|
+
add_entry('say', 'IrregularVerbSay') do
|
145
|
+
forms past_simple: 'said', past_participle: 'said'
|
146
|
+
end
|
147
|
+
add_entry('see', 'IrregularVerb') do
|
148
|
+
forms past_simple: 'saw', past_participle: 'seen'
|
149
|
+
end
|
134
150
|
add_entry('short', 'Adjective')
|
135
151
|
add_entry('side', 'CommonNoun')
|
136
152
|
add_entry('small', 'Adjective')
|
@@ -148,7 +164,9 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
148
164
|
add_entry('there', 'ExistentialThere')
|
149
165
|
add_entry('they', 'PersonalPronoun')
|
150
166
|
add_entry('thing', 'CommonNoun')
|
151
|
-
add_entry('think', 'IrregularVerbThink')
|
167
|
+
add_entry('think', 'IrregularVerbThink') do
|
168
|
+
forms past_simple: 'thought', past_participle: 'thought'
|
169
|
+
end
|
152
170
|
add_entry('this', 'DemonstrativeDeterminer')
|
153
171
|
add_entry('this', 'DemonstrativePronoun')
|
154
172
|
add_entry('this one', 'DemonstrativePronoun')
|
data/lib/zenlish/lex/lexeme.rb
CHANGED
@@ -18,10 +18,15 @@ module Zenlish
|
|
18
18
|
@wclass = aWClass
|
19
19
|
@entry = anEntry.object_id
|
20
20
|
anEntry.add_lexeme(self)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
if aWClass.kind_of?(WClasses::WordClass)
|
22
|
+
unless wclass.extension.nil?
|
23
|
+
self.extend(wclass.extension)
|
24
|
+
init_extension(self)
|
25
|
+
end
|
26
|
+
p_struct = aWClass.kind_of?(WClasses::WordClass) ? aWClass.struct : nil
|
27
|
+
overriding_struct_defs = aFeatureHash.nil? ? {} : aFeatureHash
|
28
|
+
init_struct_def(p_struct, overriding_struct_defs)
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
# @return [Zenlish::Lex::LexicalEntry] Link to its dictionary entry (headword)
|
@@ -2,18 +2,25 @@ module Zenlish
|
|
2
2
|
module Lex
|
3
3
|
# TODO: document
|
4
4
|
class LexicalEntry
|
5
|
+
#@return [String] the lemma (dictionary) form of a word.
|
5
6
|
attr_reader :lemma
|
7
|
+
|
8
|
+
# @return [Array<Lexeme, Rley::Syntax::Terminal>]
|
6
9
|
attr_reader :lexemes
|
7
|
-
|
10
|
+
|
11
|
+
# @param theLemma [String] lemma (= citation form), a word form used
|
12
|
+
# conventionnaly to represent a lexeme.
|
13
|
+
# @param aLexeme [Lexeme, NilClass] the lexeme to link with lexical entry.
|
8
14
|
def initialize(theLemma, aLexeme = nil)
|
9
15
|
@lemma = theLemma.dup
|
10
16
|
@lexemes = []
|
11
17
|
add_lexeme(aLexeme)
|
12
18
|
end
|
13
|
-
|
19
|
+
|
20
|
+
# @param aLexeme [Lexeme, NilClass] the lexeme to link with lexical entry.
|
14
21
|
def add_lexeme(aLexeme)
|
15
22
|
lexemes << aLexeme if aLexeme
|
16
23
|
end
|
17
24
|
end # class
|
18
|
-
end # module
|
25
|
+
end # module
|
19
26
|
end # module
|
data/lib/zenlish/lex/lexicon.rb
CHANGED
@@ -5,6 +5,8 @@ module Zenlish
|
|
5
5
|
class Lexicon
|
6
6
|
# @return [Array<Lex::LexicalEntry>] entries in the lexicon
|
7
7
|
attr_reader :entries
|
8
|
+
|
9
|
+
# @return [Hash{String => Lex::LexicalEntry}] the lexical entry for the given lemma.
|
8
10
|
attr_reader :lemma2entry
|
9
11
|
|
10
12
|
# The list of terminal symbols. Examples of terminal symbols:
|
@@ -23,6 +25,7 @@ module Zenlish
|
|
23
25
|
# @param aLemma[String] retrieve the lexeme form the given "head word".
|
24
26
|
# @param aWordClass [WordClasses::WordClass, NilClass] the word class of
|
25
27
|
# the lexeme.
|
28
|
+
# @return [Lex::Lexeme]
|
26
29
|
def get_lexeme(aLemma, aWordClass = nil)
|
27
30
|
if aWordClass
|
28
31
|
lexeme = nil
|
@@ -51,11 +54,13 @@ module Zenlish
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
57
|
+
# @param aTerminal [Rley::Syntax::Terminal]
|
54
58
|
def add_terminal(aTerminal)
|
55
59
|
terminals << aTerminal
|
56
60
|
name2terminal[aTerminal.name] = aTerminal
|
57
61
|
end
|
58
62
|
|
63
|
+
# @param anEntry [Lex::LexicalEntry]
|
59
64
|
def add_entry(anEntry)
|
60
65
|
entries << anEntry
|
61
66
|
lemma = anEntry.lemma
|
data/lib/zenlish/version.rb
CHANGED
@@ -6,7 +6,7 @@ module Zenlish
|
|
6
6
|
# can join words, phrases, and clauses that share some logical relationhip
|
7
7
|
# Common coordinators are enumerated in the FANBOYS acronym:
|
8
8
|
# For, And, Nor, But, Or, Yet and So.
|
9
|
-
class Coordinator < WordClass
|
9
|
+
class Coordinator < WordClass
|
10
10
|
end # class
|
11
11
|
end # module
|
12
12
|
end # module
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'lexical_verb'
|
2
|
+
require_relative 'irregular_verb_extension'
|
2
3
|
|
3
4
|
module Zenlish
|
4
5
|
module WClasses
|
@@ -8,26 +9,51 @@ module Zenlish
|
|
8
9
|
|
9
10
|
def initialize
|
10
11
|
super()
|
12
|
+
@paradigms = {}
|
11
13
|
init_feature_defs
|
14
|
+
init_paradigms
|
12
15
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
raise StandardError
|
20
|
-
end
|
16
|
+
|
17
|
+
# The mix-in module used to extend the lexeme
|
18
|
+
# @return [Module, NilClass]
|
19
|
+
def extension
|
20
|
+
IrregularVerbExtension
|
21
|
+
end
|
21
22
|
|
22
23
|
private
|
23
|
-
|
24
|
+
|
24
25
|
def init_feature_defs
|
25
|
-
super
|
26
|
-
#
|
27
|
-
feature_def_dsl {
|
28
|
-
feature_def 'PARADIGM' => [identifier, '
|
26
|
+
super
|
27
|
+
# Create standard feature definitions for irregular verbs.
|
28
|
+
feature_def_dsl {
|
29
|
+
feature_def 'PARADIGM' => [identifier, 'Irregular_inflection'] # 2nd item is default value
|
29
30
|
}
|
30
31
|
end
|
32
|
+
|
33
|
+
def init_paradigms
|
34
|
+
builder = Inflect::InflectionTableBuilder.new
|
35
|
+
table = builder.build('Irregular_inflection') do
|
36
|
+
feature_heading 'PERSON'
|
37
|
+
feature_heading 'NUMBER'
|
38
|
+
feature_heading 'TIME'
|
39
|
+
method_heading 'base_form'
|
40
|
+
# PERSON NUMBER TIME base_form
|
41
|
+
rule([not_equal(:third), dont_care, equals(:present), dont_care], col('base_form'))
|
42
|
+
rule([equals(:third), equals(:singular), equals(:present), matches(/[^aeiouy]y$/)], sub(col('base_form'), /y$/, 'ies'))
|
43
|
+
rule([equals(:third), equals(:singular), equals(:present), matches(/(?:[osxz]|ch|sh)$/)], concat(col('base_form'), 'es'))
|
44
|
+
rule([equals(:third), equals(:singular), equals(:present), dont_care], concat(col('base_form'), 's'))
|
45
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/ie$/)], sub(col('base_form'), /ie$/, 'ying'))
|
46
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/[^e]e$/)], sub(col('base_form'), /e$/, 'ing'))
|
47
|
+
rule([dont_care, dont_care, equals(:progressive), dont_care], concat(col('base_form'), 'ing'))
|
48
|
+
rule([dont_care, dont_care, equals(:past_simple), dont_care], func('past_simple'))
|
49
|
+
rule([dont_care, dont_care, equals(:past_participle), dont_care], func('past_participle'))
|
50
|
+
end
|
51
|
+
add_paradigm(table)
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_paradigm(anInflectionTable)
|
55
|
+
@paradigms[anInflectionTable.name] = anInflectionTable
|
56
|
+
end
|
31
57
|
end # class
|
32
58
|
end # module
|
33
59
|
end # module
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'lexical_verb'
|
2
|
+
require_relative 'irregular_verb_extension'
|
3
|
+
|
4
|
+
module Zenlish
|
5
|
+
module WClasses
|
6
|
+
module IrregularVerbExtension
|
7
|
+
# This callback when the module is extending an object.
|
8
|
+
# Purpose: to inject a number of instance variables in the host
|
9
|
+
# def extended(host)
|
10
|
+
def init_extension(host)
|
11
|
+
host.instance_variable_set(:@forms, [])
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param theForm [Hash{Symbol => String}]
|
15
|
+
def forms(theForms)
|
16
|
+
valid_symbols = [:past_simple, :past_participle]
|
17
|
+
actual_symbols = theForms.keys
|
18
|
+
actual_symbols.each do |symb|
|
19
|
+
raise StandardError, "Invalid verb form #{symb}" unless valid_symbols.include?(symb)
|
20
|
+
end
|
21
|
+
if actual_symbols.size < valid_symbols.size
|
22
|
+
missing = valid_symbols.find { |symb| !actual_symbols.include?(symb) }
|
23
|
+
raise StandardError, "Missing form #{missing}"
|
24
|
+
end
|
25
|
+
@forms = [nil, nil]
|
26
|
+
@forms[0] = theForms[valid_symbols[0]]
|
27
|
+
@forms[1] = theForms[valid_symbols[1]]
|
28
|
+
end
|
29
|
+
|
30
|
+
def past_simple
|
31
|
+
@forms.first
|
32
|
+
end
|
33
|
+
|
34
|
+
def past_participle
|
35
|
+
@forms.last
|
36
|
+
end
|
37
|
+
end # class
|
38
|
+
end # module
|
39
|
+
end # module
|
@@ -3,12 +3,7 @@ require_relative 'word_class'
|
|
3
3
|
module Zenlish
|
4
4
|
module WClasses
|
5
5
|
# TODO: document
|
6
|
-
class Preposition < WordClass
|
7
|
-
|
8
|
-
# Prepositions do not inflect, so they're invariable.
|
9
|
-
def invariable?
|
10
|
-
true
|
11
|
-
end
|
6
|
+
class Preposition < WordClass
|
12
7
|
end # class
|
13
8
|
end # module
|
14
9
|
end # module
|
@@ -4,7 +4,7 @@ module Zenlish
|
|
4
4
|
module WClasses
|
5
5
|
# Quantifiers are used to indicate the number or quantity of the noun under consideration.
|
6
6
|
# enough, few, little, many, more, most, much, none, several, some
|
7
|
-
class Quantifier < Determiner
|
7
|
+
class Quantifier < Determiner
|
8
8
|
end # class
|
9
9
|
end # module
|
10
10
|
end # module
|
@@ -2,7 +2,6 @@ require_relative 'lexical_verb'
|
|
2
2
|
|
3
3
|
module Zenlish
|
4
4
|
module WClasses
|
5
|
-
# TODO: document 'touch'
|
6
5
|
class RegularVerb < LexicalVerb
|
7
6
|
def initialize
|
8
7
|
super
|
@@ -24,8 +23,9 @@ module Zenlish
|
|
24
23
|
rule([equals(:third), equals(:singular), equals(:present), matches(/[^aeiouy]y$/)], sub(col('base_form'), /y$/, 'ies'))
|
25
24
|
rule([equals(:third), equals(:singular), equals(:present), matches(/(?:[osxz]|ch|sh)$/)], concat(col('base_form'), 'es'))
|
26
25
|
rule([equals(:third), equals(:singular), equals(:present), dont_care], concat(col('base_form'), 's'))
|
27
|
-
rule([dont_care, dont_care,
|
28
|
-
rule([dont_care, dont_care,
|
26
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/ie$/)], sub(col('base_form'), /ie$/, 'ying'))
|
27
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/[^e]e$/)], sub(col('base_form'), /e$/, 'ing'))
|
28
|
+
rule([dont_care, dont_care, equals(:progressive), dont_care], concat(col('base_form'), 'ing'))
|
29
29
|
rule([dont_care, dont_care, in?(:past_simple, :past_participle), matches(/e$/)], concat(col('base_form'), 'd'))
|
30
30
|
rule([dont_care, dont_care, in?(:past_simple, :past_participle), matches(/[^aeiouy]y$/)], sub(col('base_form'), /y$/, 'ied'))
|
31
31
|
rule([dont_care, dont_care, in?(:past_simple, :past_participle), dont_care], concat(col('base_form'), 'ed'))
|
@@ -10,7 +10,7 @@ module Zenlish
|
|
10
10
|
# Common subordinating conjunctions: after, although, as, because, before,
|
11
11
|
# how, if, once, since, than, that, though, till, until, when, where,
|
12
12
|
# whether, while
|
13
|
-
class SubordinatingConjunction < WordClass
|
13
|
+
class SubordinatingConjunction < WordClass
|
14
14
|
end # class
|
15
15
|
end # module
|
16
16
|
end # module
|
@@ -27,8 +27,14 @@ module Zenlish
|
|
27
27
|
|
28
28
|
# Indicates whether all words from the word class have a single (uninflected)
|
29
29
|
# form.
|
30
|
+
# @return [FalseClass, TrueClass] true iff the words in the class are invariable.
|
30
31
|
def invariable?
|
31
|
-
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Module, NilClass]
|
36
|
+
def extension
|
37
|
+
nil
|
32
38
|
end
|
33
39
|
end # class
|
34
40
|
end # module
|
@@ -174,33 +174,32 @@ module Zenlish
|
|
174
174
|
expect(table.inflect(verb_4, [nil, nil, :past_participle, nil])).to eq('caused')
|
175
175
|
end
|
176
176
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
#
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
# end
|
177
|
+
MockIrregularVerb = Struct.new(:base_form, :PERSON, :NUMBER, :TIME, :past_simple, :past_participle)
|
178
|
+
it 'should build default paradigm for irregular verbs' do
|
179
|
+
table = subject.build('Irregular_inflection') do
|
180
|
+
feature_heading 'PERSON'
|
181
|
+
feature_heading 'NUMBER'
|
182
|
+
feature_heading 'TIME'
|
183
|
+
method_heading 'base_form'
|
184
|
+
# PERSON NUMBER TIME base_form
|
185
|
+
rule([not_equal(:third), dont_care, equals(:present), dont_care], col('base_form'))
|
186
|
+
rule([equals(:third), equals(:singular), equals(:present), matches(/[^aeiouy]y$/)], sub(col('base_form'), /y$/, 'ies'))
|
187
|
+
rule([equals(:third), equals(:singular), equals(:present), matches(/(?:[osxz]|ch|sh)$/)], concat(col('base_form'), 'es'))
|
188
|
+
rule([equals(:third), equals(:singular), equals(:present), dont_care], concat(col('base_form'), 's'))
|
189
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/e$/)], sub(col('base_form'), /e$/, 'ing'))
|
190
|
+
rule([dont_care, dont_care, equals(:progressive), dont_care], concat(col('base_form'), 'ing'))
|
191
|
+
rule([dont_care, dont_care, equals(:past_simple), dont_care], func('past_simple'))
|
192
|
+
rule([dont_care, dont_care, equals(:past_participle), dont_care], func('past_participle'))
|
193
|
+
end
|
194
|
+
|
195
|
+
verb_1 = MockIrregularVerb.new('choose', :first, :singular, :present, 'chose', 'chosen')
|
196
|
+
expect(table.inflect(verb_1, [nil, nil, nil, nil] )).to eq('choose')
|
197
|
+
expect(table.inflect(verb_1, [:third, nil, nil, nil] )).to eq('chooses')
|
198
|
+
expect(table.inflect(verb_1, [nil, :plural, nil, nil] )).to eq('choose')
|
199
|
+
expect(table.inflect(verb_1, [nil, nil, :progressive, nil] )).to eq('choosing')
|
200
|
+
expect(table.inflect(verb_1, [nil, nil, :past_simple, nil] )).to eq('chose')
|
201
|
+
expect(table.inflect(verb_1, [nil, nil, :past_participle, nil])).to eq('chosen')
|
202
|
+
end
|
204
203
|
end # context
|
205
204
|
end # describe
|
206
205
|
end # module
|
@@ -27,6 +27,42 @@ module Zenlish
|
|
27
27
|
expect(common_nouns.all? { |c_n| lemmas.include?(c_n) }).to be_truthy
|
28
28
|
end
|
29
29
|
|
30
|
+
let(:present_1sg) { [:first, :singular, :present, nil] }
|
31
|
+
let(:present_3sg) { [:third, :singular, :present, nil] }
|
32
|
+
let(:present_1pl) { [:first, :plural, :present, nil] }
|
33
|
+
let(:progressive) { [nil, nil, :progressive, nil] }
|
34
|
+
let(:past_simple) { [nil, nil, :past_simple, nil] }
|
35
|
+
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
36
|
+
|
37
|
+
def test_inflection_of(verb_lexeme, pairs)
|
38
|
+
pairs.each do |(constraints, expected_form)|
|
39
|
+
expect(verb_lexeme.inflect(constraints)).to eq(expected_form)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should know how to inflect an (irregular) verb' do
|
44
|
+
lexm = subject.get_lexeme('become')
|
45
|
+
expectations_1 = [
|
46
|
+
[present_1sg, 'become'],
|
47
|
+
[present_3sg, 'becomes'],
|
48
|
+
[present_1pl, 'become'],
|
49
|
+
[progressive, 'becoming'],
|
50
|
+
[past_simple, 'became'],
|
51
|
+
[past_participle, 'become']
|
52
|
+
]
|
53
|
+
test_inflection_of(lexm, expectations_1)
|
54
|
+
|
55
|
+
lexm = subject.get_lexeme('do', WClasses::IrregularVerbDo)
|
56
|
+
expectations_2 = [
|
57
|
+
[present_1sg, 'do'],
|
58
|
+
[present_3sg, 'does'],
|
59
|
+
[present_1pl, 'do'],
|
60
|
+
[progressive, 'doing'],
|
61
|
+
[past_simple, 'did'],
|
62
|
+
[past_participle, 'done']
|
63
|
+
]
|
64
|
+
test_inflection_of(lexm, expectations_2)
|
65
|
+
end
|
30
66
|
end # context
|
31
67
|
end # describe
|
32
68
|
end # module
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../spec_helper' # Use the RSpec framework
|
4
|
+
|
5
|
+
# Load the class under test
|
6
|
+
require_relative '../../../lib/zenlish/wclasses/irregular_verb_extension'
|
7
|
+
|
8
|
+
module Zenlish
|
9
|
+
module WClasses
|
10
|
+
describe IrregularVerbExtension do
|
11
|
+
subject do
|
12
|
+
obj = Object.new
|
13
|
+
obj.extend(IrregularVerbExtension)
|
14
|
+
obj.init_extension(obj)
|
15
|
+
obj
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'Initialization:' do
|
19
|
+
it 'should mix-in with a host object' do
|
20
|
+
expect { Object.new.extend(IrregularVerbExtension) }.not_to raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should inject an instance variable' do
|
24
|
+
expect(subject.instance_variable_get(:@forms)).to be_kind_of(Array)
|
25
|
+
end
|
26
|
+
end # context
|
27
|
+
|
28
|
+
context 'Provided services:' do
|
29
|
+
it 'should provide a write accessor' do
|
30
|
+
subject.forms past_simple: 'chose', past_participle: 'chosen'
|
31
|
+
expect(subject.past_simple).to eq('chose')
|
32
|
+
expect(subject.past_participle).to eq('chosen')
|
33
|
+
end
|
34
|
+
end # context
|
35
|
+
end # describe
|
36
|
+
end # module
|
37
|
+
end # module
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../../spec_helper' # Use the RSpec framework
|
4
|
-
require_relative '../../../lib/zenlish/
|
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'
|
5
9
|
|
6
10
|
module Zenlish
|
7
11
|
module WClasses
|
@@ -15,7 +19,54 @@ module Zenlish
|
|
15
19
|
end # context
|
16
20
|
|
17
21
|
context 'Provided services:' do
|
18
|
-
|
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('Irregular_inflection')
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:present_1sg) { [:first, :singular, :present, nil] }
|
29
|
+
let(:present_3sg) { [:third, :singular, :present, nil] }
|
30
|
+
let(:present_1pl) { [:first, :plural, :present, nil] }
|
31
|
+
let(:progressive) { [nil, nil, :progressive, nil] }
|
32
|
+
let(:past_simple) { [nil, nil, :past_simple, nil] }
|
33
|
+
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
34
|
+
|
35
|
+
def build_verb(aBaseForm, p_simple, p_participle)
|
36
|
+
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
37
|
+
lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
|
38
|
+
lexeme.forms past_simple: p_simple, past_participle: p_participle
|
39
|
+
lexeme
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_inflection_of(verb_form, p_simple, p_participle, pairs)
|
43
|
+
verb = build_verb(verb_form, p_simple, p_participle)
|
44
|
+
pairs.each do |(constraints, expected_form)|
|
45
|
+
expect(verb.inflect(constraints)).to eq(expected_form)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should know how to inflect irregular verbs' do
|
50
|
+
expectations_1 = [
|
51
|
+
[present_1sg, 'see'],
|
52
|
+
[present_3sg, 'sees'],
|
53
|
+
[present_1pl, 'see'],
|
54
|
+
[progressive, 'seeing'],
|
55
|
+
[past_simple, 'saw'],
|
56
|
+
[past_participle, 'seen']
|
57
|
+
]
|
58
|
+
test_inflection_of('see', 'saw', 'seen', expectations_1)
|
59
|
+
|
60
|
+
expectations_2 = [
|
61
|
+
[present_1sg, 'make'],
|
62
|
+
[present_3sg, 'makes'],
|
63
|
+
[present_1pl, 'make'],
|
64
|
+
[progressive, 'making'],
|
65
|
+
[past_simple, 'made'],
|
66
|
+
[past_participle, 'made']
|
67
|
+
]
|
68
|
+
test_inflection_of('make', 'made', 'made', expectations_2)
|
69
|
+
end
|
19
70
|
end # context
|
20
71
|
end # describe
|
21
72
|
end # module
|
@@ -44,7 +44,7 @@ module Zenlish
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
it 'should how to inflect regular verbs' do
|
47
|
+
it 'should know how to inflect regular verbs' do
|
48
48
|
expectations_1 = [
|
49
49
|
[present_1sg, 'exist'],
|
50
50
|
[present_3sg, 'exists'],
|
@@ -83,7 +83,17 @@ module Zenlish
|
|
83
83
|
[past_simple, 'touched'],
|
84
84
|
[past_participle, 'touched']
|
85
85
|
]
|
86
|
-
test_inflection_of('touch', expectations_4)
|
86
|
+
test_inflection_of('touch', expectations_4)
|
87
|
+
|
88
|
+
expectations_5 = [
|
89
|
+
[present_1sg, 'die'],
|
90
|
+
[present_3sg, 'dies'],
|
91
|
+
[present_1pl, 'die'],
|
92
|
+
[progressive, 'dying'],
|
93
|
+
[past_simple, 'died'],
|
94
|
+
[past_participle, 'died']
|
95
|
+
]
|
96
|
+
test_inflection_of('die', expectations_5)
|
87
97
|
end
|
88
98
|
end # context
|
89
99
|
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.02
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/zenlish/wclasses/irregular_verb.rb
|
160
160
|
- lib/zenlish/wclasses/irregular_verb_be.rb
|
161
161
|
- lib/zenlish/wclasses/irregular_verb_do.rb
|
162
|
+
- lib/zenlish/wclasses/irregular_verb_extension.rb
|
162
163
|
- lib/zenlish/wclasses/irregular_verb_have.rb
|
163
164
|
- lib/zenlish/wclasses/irregular_verb_know.rb
|
164
165
|
- lib/zenlish/wclasses/irregular_verb_say.rb
|
@@ -224,6 +225,7 @@ files:
|
|
224
225
|
- spec/zenlish/support/minimal_lexicon.rb
|
225
226
|
- spec/zenlish/support/var2word.rb
|
226
227
|
- spec/zenlish/wclasses/common_noun_spec.rb
|
228
|
+
- spec/zenlish/wclasses/irregular_verb_extension_spec.rb
|
227
229
|
- spec/zenlish/wclasses/irregular_verb_spec.rb
|
228
230
|
- spec/zenlish/wclasses/lexical_verb_spec.rb
|
229
231
|
- spec/zenlish/wclasses/noun_spec.rb
|
@@ -296,6 +298,7 @@ test_files:
|
|
296
298
|
- spec/zenlish/parser/lesson3_spec.rb
|
297
299
|
- spec/zenlish/parser/zparser_spec.rb
|
298
300
|
- spec/zenlish/wclasses/common_noun_spec.rb
|
301
|
+
- spec/zenlish/wclasses/irregular_verb_extension_spec.rb
|
299
302
|
- spec/zenlish/wclasses/irregular_verb_spec.rb
|
300
303
|
- spec/zenlish/wclasses/lexical_verb_spec.rb
|
301
304
|
- spec/zenlish/wclasses/noun_spec.rb
|