zenlish 0.2.02 → 0.2.06
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +455 -0
- data/CHANGELOG.md +58 -1
- data/Gemfile +5 -3
- data/README.md +27 -0
- data/Rakefile +5 -3
- data/lib/zenlish/feature/boolean_domain.rb +9 -3
- data/lib/zenlish/feature/boolean_value.rb +3 -2
- data/lib/zenlish/feature/enumeration_domain.rb +8 -1
- data/lib/zenlish/feature/feature.rb +9 -7
- data/lib/zenlish/feature/feature_def.rb +10 -6
- data/lib/zenlish/feature/feature_domain.rb +9 -3
- data/lib/zenlish/feature/feature_struct.rb +3 -1
- data/lib/zenlish/feature/feature_struct_def.rb +5 -1
- data/lib/zenlish/feature/feature_struct_def_bearer.rb +6 -4
- data/lib/zenlish/feature/feature_value.rb +4 -2
- data/lib/zenlish/feature/identifier_domain.rb +5 -3
- data/lib/zenlish/feature/identifier_value.rb +3 -2
- data/lib/zenlish/feature/symbol_value.rb +3 -1
- data/lib/zenlish/inflect/atomic_o_expression.rb +2 -1
- data/lib/zenlish/inflect/composite_o_expression.rb +3 -1
- data/lib/zenlish/inflect/concatenation.rb +3 -2
- data/lib/zenlish/inflect/equals_literal.rb +7 -1
- data/lib/zenlish/inflect/feature_heading.rb +11 -5
- data/lib/zenlish/inflect/formal_argument.rb +3 -1
- data/lib/zenlish/inflect/function_call.rb +4 -1
- data/lib/zenlish/inflect/heading.rb +5 -0
- data/lib/zenlish/inflect/inflection_rule.rb +2 -0
- data/lib/zenlish/inflect/inflection_table.rb +29 -4
- data/lib/zenlish/inflect/inflection_table_builder.rb +27 -20
- data/lib/zenlish/inflect/input_asis.rb +3 -0
- data/lib/zenlish/inflect/input_expression.rb +4 -2
- data/lib/zenlish/inflect/literal_asis.rb +4 -1
- data/lib/zenlish/inflect/matches_pattern.rb +2 -0
- data/lib/zenlish/inflect/membership.rb +2 -0
- data/lib/zenlish/inflect/method_heading.rb +7 -6
- data/lib/zenlish/inflect/not_equals_literal.rb +2 -0
- data/lib/zenlish/inflect/nullary_input_expression.rb +3 -1
- data/lib/zenlish/inflect/output_expression.rb +2 -0
- data/lib/zenlish/inflect/substitution.rb +3 -1
- data/lib/zenlish/inflect/unary_input_expression.rb +4 -1
- data/lib/zenlish/inflect/unconditionally_true.rb +4 -2
- data/lib/zenlish/lang/dictionary.rb +35 -29
- data/lib/zenlish/lang/lemmatizer.rb +40 -0
- data/lib/zenlish/lang/zenlish_grammar.rb +9 -6
- data/lib/zenlish/lex/empty_lexicon_factory.rb +4 -3
- data/lib/zenlish/lex/lexeme.rb +9 -2
- data/lib/zenlish/lex/lexical_entry.rb +6 -4
- data/lib/zenlish/lex/lexicon.rb +10 -8
- data/lib/zenlish/lex/literal.rb +3 -1
- data/lib/zenlish/lexer/lexer.rb +144 -0
- data/lib/zenlish/trie/base_trie_node.rb +27 -0
- data/lib/zenlish/trie/trie.rb +132 -0
- data/lib/zenlish/trie/trie_node.rb +21 -0
- data/lib/zenlish/trie/trie_root.rb +10 -0
- data/lib/zenlish/version.rb +3 -1
- data/lib/zenlish/wclasses/adjective.rb +5 -2
- data/lib/zenlish/wclasses/adverb.rb +3 -1
- data/lib/zenlish/wclasses/adverb_maybe.rb +3 -1
- data/lib/zenlish/wclasses/adverb_not.rb +2 -0
- data/lib/zenlish/wclasses/all_word_classes.rb +4 -2
- data/lib/zenlish/wclasses/article.rb +2 -0
- data/lib/zenlish/wclasses/auxiliary.rb +5 -2
- data/lib/zenlish/wclasses/auxiliary_be.rb +34 -1
- data/lib/zenlish/wclasses/auxiliary_do.rb +31 -0
- data/lib/zenlish/wclasses/cardinal.rb +3 -1
- data/lib/zenlish/wclasses/common_noun.rb +2 -0
- data/lib/zenlish/wclasses/comparative_particle.rb +5 -3
- data/lib/zenlish/wclasses/conjunction.rb +2 -0
- data/lib/zenlish/wclasses/conjunctive_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/coordinator.rb +4 -2
- data/lib/zenlish/wclasses/definite_article.rb +2 -0
- data/lib/zenlish/wclasses/degree_adverb.rb +2 -0
- data/lib/zenlish/wclasses/demonstrative_determiner.rb +40 -1
- data/lib/zenlish/wclasses/demonstrative_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/determiner.rb +3 -1
- data/lib/zenlish/wclasses/distributive_determiner.rb +2 -0
- data/lib/zenlish/wclasses/existential_there.rb +2 -0
- data/lib/zenlish/wclasses/fronting_quantifier.rb +3 -1
- data/lib/zenlish/wclasses/indefinite_article.rb +2 -0
- data/lib/zenlish/wclasses/indefinite_pronoun.rb +3 -1
- data/lib/zenlish/wclasses/irregular_linking_verb.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb.rb +14 -22
- data/lib/zenlish/wclasses/irregular_verb_be.rb +41 -1
- data/lib/zenlish/wclasses/irregular_verb_can.rb +35 -0
- data/lib/zenlish/wclasses/irregular_verb_do.rb +38 -1
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +8 -6
- data/lib/zenlish/wclasses/irregular_verb_have.rb +38 -1
- data/lib/zenlish/wclasses/irregular_verb_know.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_say.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_think.rb +3 -1
- data/lib/zenlish/wclasses/lexical_verb.rb +3 -4
- data/lib/zenlish/wclasses/linking_adverb.rb +2 -0
- data/lib/zenlish/wclasses/modal_verb_can.rb +27 -0
- data/lib/zenlish/wclasses/noun.rb +4 -2
- data/lib/zenlish/wclasses/numeral.rb +2 -0
- data/lib/zenlish/wclasses/personal_pronoun.rb +70 -1
- data/lib/zenlish/wclasses/possessive_determiner.rb +60 -0
- data/lib/zenlish/wclasses/preposition.rb +3 -1
- data/lib/zenlish/wclasses/preposition_of.rb +2 -0
- data/lib/zenlish/wclasses/preposition_than.rb +2 -0
- data/lib/zenlish/wclasses/pronoun.rb +3 -1
- data/lib/zenlish/wclasses/proper_noun.rb +10 -8
- data/lib/zenlish/wclasses/quantifier.rb +3 -1
- data/lib/zenlish/wclasses/regular_verb.rb +13 -18
- data/lib/zenlish/wclasses/regular_verb_want.rb +4 -2
- data/lib/zenlish/wclasses/relative_pronoun.rb +4 -2
- data/lib/zenlish/wclasses/subordinating_conjunction.rb +7 -5
- data/lib/zenlish/wclasses/verb.rb +16 -8
- data/lib/zenlish/wclasses/word_class.rb +11 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/zenlish/feature/boolean_domain_spec.rb +6 -1
- data/spec/zenlish/feature/boolean_value_spec.rb +1 -1
- data/spec/zenlish/feature/enumeration_domain_spec.rb +9 -5
- data/spec/zenlish/feature/feature_spec.rb +3 -3
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +10 -8
- data/spec/zenlish/feature/feature_struct_def_spec.rb +3 -2
- data/spec/zenlish/feature/identifier_domain_spec.rb +3 -3
- data/spec/zenlish/feature/identifier_value_spec.rb +4 -4
- data/spec/zenlish/feature/symbol_value_spec.rb +3 -3
- data/spec/zenlish/inflect/concatenation_spec.rb +7 -7
- data/spec/zenlish/inflect/feature_heading_spec.rb +23 -3
- data/spec/zenlish/inflect/formal_argument_spec.rb +2 -2
- data/spec/zenlish/inflect/function_call_spec.rb +4 -4
- data/spec/zenlish/inflect/inflection_rule_spec.rb +9 -5
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +26 -21
- data/spec/zenlish/inflect/inflection_table_spec.rb +39 -22
- data/spec/zenlish/inflect/input_asis_spec.rb +2 -6
- data/spec/zenlish/inflect/literal_asis_spec.rb +3 -3
- data/spec/zenlish/inflect/matches_pattern_spec.rb +1 -1
- data/spec/zenlish/inflect/membership_spec.rb +2 -2
- data/spec/zenlish/inflect/method_heading_spec.rb +7 -1
- data/spec/zenlish/inflect/substitution_spec.rb +1 -1
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +2 -2
- data/spec/zenlish/lang/dictionary_spec.rb +51 -16
- data/spec/zenlish/lang/lemmatizer_spec.rb +43 -0
- data/spec/zenlish/lang/zenlish_grammar_spec.rb +2 -2
- data/spec/zenlish/lex/lexeme_spec.rb +16 -11
- data/spec/zenlish/lex/lexical_entry_spec.rb +1 -2
- data/spec/zenlish/lex/lexicon_spec.rb +9 -8
- data/spec/zenlish/lex/literal_spec.rb +2 -2
- data/spec/zenlish/lexer/lexer_spec.rb +52 -0
- data/spec/zenlish/parser/lesson1_spec.rb +2 -2
- data/spec/zenlish/parser/lesson2_spec.rb +31 -36
- data/spec/zenlish/parser/lesson3_spec.rb +98 -138
- data/spec/zenlish/parser/zparser_spec.rb +2 -1
- data/spec/zenlish/support/minimal_lexicon.rb +2 -0
- data/spec/zenlish/support/var2word.rb +27 -18
- data/spec/zenlish/trie/base_trie_node_spec.rb +33 -0
- data/spec/zenlish/trie/trie_spec.rb +108 -0
- data/spec/zenlish/wclasses/common_noun_spec.rb +19 -7
- data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +47 -0
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +60 -0
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +14 -4
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +9 -2
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +50 -0
- data/spec/zenlish/wclasses/personal_pronoun_spec.rb +66 -0
- data/spec/zenlish/wclasses/possessive_determiner_spec.rb +69 -0
- data/spec/zenlish/wclasses/regular_verb_spec.rb +35 -15
- data/spec/zenlish/wclasses/regular_verb_want_spec.rb +30 -0
- data/spec/zenlish/wclasses/verb_spec.rb +9 -2
- data/spec/zenlish_spec.rb +3 -1
- data/zenlish.gemspec +17 -14
- metadata +37 -10
- data/lib/zenlish/wclasses/modal_verb_could.rb +0 -9
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'conjunction'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
|
-
# A coordinator (aka coordinating conjunction) is a word or phrase that
|
7
|
+
# A coordinator (aka coordinating conjunction) is a word or phrase that
|
6
8
|
# can join words, phrases, and clauses that share some logical relationhip
|
7
9
|
# Common coordinators are enumerated in the FANBOYS acronym:
|
8
10
|
# For, And, Nor, But, Or, Yet and So.
|
9
|
-
class Coordinator < WordClass
|
11
|
+
class Coordinator < WordClass
|
10
12
|
end # class
|
11
13
|
end # module
|
12
14
|
end # module
|
@@ -1,9 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'determiner'
|
4
|
+
require_relative '../inflect/inflection_table_builder'
|
2
5
|
|
3
6
|
module Zenlish
|
4
7
|
module WClasses
|
5
|
-
#
|
8
|
+
# In grammar, a demonstrative is a determiner or a pronoun
|
9
|
+
# that points to a particular noun or to the noun it replaces (the antecedent).
|
6
10
|
class DemonstrativeDeterminer < Determiner
|
11
|
+
def initialize
|
12
|
+
super()
|
13
|
+
init_feature_defs
|
14
|
+
init_paradigms
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [FalseClass] Indicates that demonstrative determiners inflects.
|
18
|
+
def invariable?
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def init_feature_defs
|
25
|
+
# Create standard feature definitions for irregular verbs.
|
26
|
+
feature_def_dsl do
|
27
|
+
feature_def 'NUMBER' => enumeration(:singular, :plural)
|
28
|
+
feature_def 'DISTANCE' => enumeration(:near, :far)
|
29
|
+
feature_def 'PARADIGM' => [identifier, 'Demonstrative_det_paradigm'] # 2nd item is default value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def init_paradigms
|
34
|
+
builder = Inflect::InflectionTableBuilder.new
|
35
|
+
table = builder.build('Demonstrative_det_paradigm') do
|
36
|
+
feature_heading 'NUMBER'
|
37
|
+
feature_heading 'DISTANCE'
|
38
|
+
# NUMBER DISTANCE
|
39
|
+
rule([equals(:singular), equals(:near)], func('base_form'))
|
40
|
+
rule([equals(:singular), equals(:far)], literal('that'))
|
41
|
+
rule([equals(:plural), equals(:near)], literal('these'))
|
42
|
+
rule([equals(:plural), equals(:far)], literal('those'))
|
43
|
+
end
|
44
|
+
add_paradigm(table)
|
45
|
+
end
|
7
46
|
end # class
|
8
47
|
end # module
|
9
48
|
end # module
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'quantifier'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
7
|
# Quantifiers that appear in front of determiners: all, both
|
6
|
-
class
|
8
|
+
class FrontingQuantifier < Quantifier
|
7
9
|
end # class
|
8
10
|
end # module
|
9
11
|
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lexical_verb'
|
2
4
|
require_relative 'irregular_verb_extension'
|
3
5
|
|
@@ -7,27 +9,20 @@ module Zenlish
|
|
7
9
|
# @return [Array<String>] [the past simple form, past participle form].
|
8
10
|
attr_writer :forms
|
9
11
|
|
10
|
-
def initialize
|
11
|
-
super()
|
12
|
-
@paradigms = {}
|
13
|
-
init_feature_defs
|
14
|
-
init_paradigms
|
15
|
-
end
|
16
|
-
|
17
12
|
# The mix-in module used to extend the lexeme
|
18
13
|
# @return [Module, NilClass]
|
19
14
|
def extension
|
20
15
|
IrregularVerbExtension
|
21
|
-
end
|
16
|
+
end
|
22
17
|
|
23
18
|
private
|
24
|
-
|
19
|
+
|
25
20
|
def init_feature_defs
|
26
21
|
super
|
27
22
|
# Create standard feature definitions for irregular verbs.
|
28
|
-
feature_def_dsl
|
23
|
+
feature_def_dsl do
|
29
24
|
feature_def 'PARADIGM' => [identifier, 'Irregular_inflection'] # 2nd item is default value
|
30
|
-
|
25
|
+
end
|
31
26
|
end
|
32
27
|
|
33
28
|
def init_paradigms
|
@@ -38,22 +33,19 @@ module Zenlish
|
|
38
33
|
feature_heading 'TIME'
|
39
34
|
method_heading 'base_form'
|
40
35
|
# PERSON NUMBER TIME base_form
|
41
|
-
rule([not_equal(:third),
|
36
|
+
rule([not_equal(:third), equals(:singular), equals(:present), dont_care], col('base_form'))
|
42
37
|
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,
|
46
|
-
rule([dont_care, dont_care, equals(:progressive), matches(/
|
38
|
+
rule([equals(:third), equals(:singular), equals(:present), matches(/(?:[osxz]|ch|sh)$/)], concat(col('base_form'), 'es'))
|
39
|
+
rule([equals(:third), equals(:singular), equals(:present), dont_care], concat(col('base_form'), 's'))
|
40
|
+
rule([dont_care, equals(:plural), equals(:present), dont_care], col('base_form'))
|
41
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/ie$/)], sub(col('base_form'), /ie$/, 'ying'))
|
42
|
+
rule([dont_care, dont_care, equals(:progressive), matches(/[^eoy]e$/)], sub(col('base_form'), /e$/, 'ing'))
|
47
43
|
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'))
|
44
|
+
rule([dont_care, dont_care, equals(:past_simple), dont_care], func('past_simple'))
|
49
45
|
rule([dont_care, dont_care, equals(:past_participle), dont_care], func('past_participle'))
|
50
46
|
end
|
51
47
|
add_paradigm(table)
|
52
48
|
end
|
53
|
-
|
54
|
-
def add_paradigm(anInflectionTable)
|
55
|
-
@paradigms[anInflectionTable.name] = anInflectionTable
|
56
|
-
end
|
57
49
|
end # class
|
58
50
|
end # module
|
59
|
-
end # module
|
51
|
+
end # module
|
@@ -1,9 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'irregular_verb'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
7
|
# The `be` verb used as a lexical verb (as opposed auxiliary verb).
|
6
8
|
class IrregularVerbBe < IrregularVerb
|
9
|
+
# rubocop: disable Layout/SpaceInsideArrayLiteralBrackets
|
10
|
+
|
11
|
+
# The mix-in module used to extend the lexeme
|
12
|
+
# @return [Module, NilClass]
|
13
|
+
def extension
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def init_feature_defs
|
20
|
+
super
|
21
|
+
# Create standard feature definitiofor irregular verbs.
|
22
|
+
feature_def_dsl do
|
23
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_be_inflection'] # 2nd item is default value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def init_paradigms
|
28
|
+
builder = Inflect::InflectionTableBuilder.new
|
29
|
+
table = builder.build('Verb_be_inflection') do
|
30
|
+
feature_heading 'PERSON'
|
31
|
+
feature_heading 'NUMBER'
|
32
|
+
feature_heading 'TIME'
|
33
|
+
# PERSON NUMBER TIME
|
34
|
+
rule([equals(:first), equals(:singular), equals(:present) ], literal('am'))
|
35
|
+
rule([equals(:second), equals(:singular), equals(:present) ], literal('are'))
|
36
|
+
rule([equals(:third), equals(:singular), equals(:present) ], literal('is'))
|
37
|
+
rule([dont_care, equals(:plural), equals(:present) ], literal('are'))
|
38
|
+
rule([dont_care, dont_care, equals(:progressive) ], literal('being'))
|
39
|
+
rule([in?(:first, :third), equals(:singular), equals(:past_simple) ], literal('was'))
|
40
|
+
rule([equals(:second), equals(:singular), equals(:past_simple) ], literal('were'))
|
41
|
+
rule([dont_care, equals(:plural), equals(:past_simple) ], literal('were'))
|
42
|
+
rule([dont_care, dont_care, equals(:past_participle)], literal('been'))
|
43
|
+
end
|
44
|
+
add_paradigm(table)
|
45
|
+
end
|
46
|
+
# rubocop: enable Layout/SpaceInsideArrayLiteralBrackets
|
7
47
|
end # class
|
8
48
|
end # module
|
9
|
-
end # module
|
49
|
+
end # module
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'irregular_verb'
|
4
|
+
|
5
|
+
module Zenlish
|
6
|
+
module WClasses
|
7
|
+
# Irregular verb can
|
8
|
+
class IrregularVerbCan < IrregularVerb
|
9
|
+
# rubocop: disable Layout/SpaceInsideArrayLiteralBrackets
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def init_feature_defs
|
14
|
+
super
|
15
|
+
# Create standard feature definitions for modal verb can.
|
16
|
+
feature_def_dsl do
|
17
|
+
feature_def 'TIME' => enumeration(:present, :past_simple)
|
18
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_can_inflection'] # 2nd item is default value
|
19
|
+
end
|
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
|
+
# rubocop: enable Layout/SpaceInsideArrayLiteralBrackets
|
33
|
+
end # class
|
34
|
+
end # module
|
35
|
+
end # module
|
@@ -1,9 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'irregular_verb'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
7
|
# The `do` verb used as a lexical verb (as opposed auxiliary verb).
|
6
8
|
class IrregularVerbDo < IrregularVerb
|
9
|
+
# rubocop: disable Layout/SpaceInsideArrayLiteralBrackets
|
10
|
+
|
11
|
+
# The mix-in module used to extend the lexeme
|
12
|
+
# @return [Module, NilClass]
|
13
|
+
def extension
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def init_feature_defs
|
20
|
+
super
|
21
|
+
# Create standard feature definitions for irregular verbs.
|
22
|
+
feature_def_dsl do
|
23
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_do_inflection'] # 2nd item is default value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def init_paradigms
|
28
|
+
builder = Inflect::InflectionTableBuilder.new
|
29
|
+
table = builder.build('Verb_do_inflection') do
|
30
|
+
feature_heading 'PERSON'
|
31
|
+
feature_heading 'NUMBER'
|
32
|
+
feature_heading 'TIME'
|
33
|
+
# PERSON NUMBER TIME
|
34
|
+
rule([not_equal(:third), equals(:singular), equals(:present) ], literal('do'))
|
35
|
+
rule([equals(:third), equals(:singular), equals(:present) ], literal('does'))
|
36
|
+
rule([dont_care, equals(:plural), equals(:present) ], literal('do'))
|
37
|
+
rule([dont_care, dont_care, equals(:progressive) ], literal('doing'))
|
38
|
+
rule([dont_care, dont_care, equals(:past_simple) ], literal('did'))
|
39
|
+
rule([dont_care, dont_care, equals(:past_participle)], literal('done'))
|
40
|
+
end
|
41
|
+
add_paradigm(table)
|
42
|
+
end
|
43
|
+
# rubocop: enable Layout/SpaceInsideArrayLiteralBrackets
|
7
44
|
end # class
|
8
45
|
end # module
|
9
|
-
end # module
|
46
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lexical_verb'
|
2
4
|
require_relative 'irregular_verb_extension'
|
3
5
|
|
@@ -10,10 +12,10 @@ module Zenlish
|
|
10
12
|
def init_extension(host)
|
11
13
|
host.instance_variable_set(:@forms, [])
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
# @param theForm [Hash{Symbol => String}]
|
15
17
|
def forms(theForms)
|
16
|
-
valid_symbols = [
|
18
|
+
valid_symbols = %i[past_simple past_participle]
|
17
19
|
actual_symbols = theForms.keys
|
18
20
|
actual_symbols.each do |symb|
|
19
21
|
raise StandardError, "Invalid verb form #{symb}" unless valid_symbols.include?(symb)
|
@@ -26,14 +28,14 @@ module Zenlish
|
|
26
28
|
@forms[0] = theForms[valid_symbols[0]]
|
27
29
|
@forms[1] = theForms[valid_symbols[1]]
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
def past_simple
|
31
33
|
@forms.first
|
32
34
|
end
|
33
|
-
|
35
|
+
|
34
36
|
def past_participle
|
35
37
|
@forms.last
|
36
|
-
end
|
38
|
+
end
|
37
39
|
end # class
|
38
40
|
end # module
|
39
|
-
end # module
|
41
|
+
end # module
|
@@ -1,9 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'irregular_verb'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
7
|
# The `have` verb used as a lexical verb (as opposed auxiliary verb).
|
6
8
|
class IrregularVerbHave < IrregularVerb
|
9
|
+
# rubocop: disable Layout/SpaceInsideArrayLiteralBrackets
|
10
|
+
|
11
|
+
# The mix-in module used to extend the lexeme
|
12
|
+
# @return [Module, NilClass]
|
13
|
+
def extension
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def init_feature_defs
|
20
|
+
super
|
21
|
+
# Create standard feature definitions for irregular verbs.
|
22
|
+
feature_def_dsl do
|
23
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_have_inflection'] # 2nd item is default value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def init_paradigms
|
28
|
+
builder = Inflect::InflectionTableBuilder.new
|
29
|
+
table = builder.build('Verb_have_inflection') do
|
30
|
+
feature_heading 'PERSON'
|
31
|
+
feature_heading 'NUMBER'
|
32
|
+
feature_heading 'TIME'
|
33
|
+
# PERSON NUMBER TIME
|
34
|
+
rule([not_equal(:third), equals(:singular), equals(:present) ], literal('have'))
|
35
|
+
rule([equals(:third), equals(:singular), equals(:present) ], literal('has'))
|
36
|
+
rule([dont_care, equals(:plural), equals(:present) ], literal('have'))
|
37
|
+
rule([dont_care, dont_care, equals(:progressive) ], literal('having'))
|
38
|
+
rule([dont_care, dont_care, equals(:past_simple) ], literal('had'))
|
39
|
+
rule([dont_care, dont_care, equals(:past_participle)], literal('had'))
|
40
|
+
end
|
41
|
+
add_paradigm(table)
|
42
|
+
end
|
43
|
+
# rubocop: enable Layout/SpaceInsideArrayLiteralBrackets
|
7
44
|
end # class
|
8
45
|
end # module
|
9
|
-
end # module
|
46
|
+
end # module
|