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
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zenlish
|
4
|
+
module Trie
|
5
|
+
# Abstract class for representing nodes in the trie data structure.
|
6
|
+
class BaseTrieNode
|
7
|
+
# @return [Hash{String => TrieNode}] the successor nodes
|
8
|
+
attr_reader :succ
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@succ = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def include?(aKey)
|
15
|
+
succ.include?(aKey)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_succ(aKey, aNode)
|
19
|
+
succ[aKey] = aNode
|
20
|
+
end
|
21
|
+
|
22
|
+
def leaf?
|
23
|
+
succ.empty?
|
24
|
+
end
|
25
|
+
end # class
|
26
|
+
end # module
|
27
|
+
end # module
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'trie_root'
|
4
|
+
require_relative 'trie_node'
|
5
|
+
|
6
|
+
# https://raw.githubusercontent.com/first20hours/google-10000-english/master/20k.txt
|
7
|
+
# https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt
|
8
|
+
|
9
|
+
module Zenlish
|
10
|
+
module Trie
|
11
|
+
# A trie (aka prefix tree or digital tree) is a kind of search tree.
|
12
|
+
class Trie
|
13
|
+
# @return [TrieRoot] The root node of the trie data structure
|
14
|
+
attr_reader :root
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@root = TrieRoot.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def add(aWord, aValue)
|
21
|
+
append_node(root, aWord, 0, aValue)
|
22
|
+
end
|
23
|
+
|
24
|
+
def search(aWord)
|
25
|
+
search_node(root, aWord, 0)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def append_node(aNode, aText, anIndex, aValue)
|
31
|
+
key = aText[anIndex]
|
32
|
+
unless aNode.include?(key)
|
33
|
+
aNode.add_succ(key, TrieNode.new(key))
|
34
|
+
end
|
35
|
+
successor = aNode.succ[key]
|
36
|
+
|
37
|
+
if anIndex == aText.size - 1
|
38
|
+
current_value = successor.value
|
39
|
+
if current_value
|
40
|
+
if current_value.kind_of?(Array)
|
41
|
+
current_value << aValue
|
42
|
+
else
|
43
|
+
successor.value = [current_value, aValue]
|
44
|
+
end
|
45
|
+
else
|
46
|
+
successor.value = aValue
|
47
|
+
end
|
48
|
+
else
|
49
|
+
append_node(successor, aText, anIndex + 1, aValue)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def search_node(aNode, aText, anIndex)
|
54
|
+
key = aText[anIndex]
|
55
|
+
return nil unless aNode.include?(key)
|
56
|
+
|
57
|
+
successor = aNode.succ[key]
|
58
|
+
return successor if anIndex == aText.size - 1
|
59
|
+
|
60
|
+
search_node(successor, aText, anIndex + 1)
|
61
|
+
end
|
62
|
+
=begin
|
63
|
+
|
64
|
+
|
65
|
+
def include?(word)
|
66
|
+
find_word(word) { |found, base| return found && base.word }
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_word(word)
|
70
|
+
letters = word.chars
|
71
|
+
base = @root
|
72
|
+
|
73
|
+
letters.each { |letter| base = add_character(letter, base.next) }
|
74
|
+
|
75
|
+
base.word = true
|
76
|
+
end
|
77
|
+
|
78
|
+
def find_word(word)
|
79
|
+
letters = word.chars
|
80
|
+
base = @root
|
81
|
+
|
82
|
+
word_found =
|
83
|
+
letters.all? { |letter| base = find_character(letter, base.next) }
|
84
|
+
|
85
|
+
yield word_found, base if block_given?
|
86
|
+
|
87
|
+
base
|
88
|
+
end
|
89
|
+
|
90
|
+
def find_words_starting_with(prefix)
|
91
|
+
stack = []
|
92
|
+
words = []
|
93
|
+
prefix_stack = []
|
94
|
+
|
95
|
+
stack << find_word(prefix)
|
96
|
+
prefix_stack << prefix.chars.take(prefix.size-1)
|
97
|
+
|
98
|
+
return [] unless stack.first
|
99
|
+
|
100
|
+
until stack.empty?
|
101
|
+
node = stack.pop
|
102
|
+
|
103
|
+
prefix_stack.pop and next if node == :guard_node
|
104
|
+
|
105
|
+
prefix_stack << node.value
|
106
|
+
stack << :guard_node
|
107
|
+
|
108
|
+
words << prefix_stack.join if node.word
|
109
|
+
|
110
|
+
node.next.each { |n| stack << n }
|
111
|
+
end
|
112
|
+
|
113
|
+
words
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def add_character(character, trie)
|
119
|
+
trie.find { |n| n.value == character } || add_node(character, trie)
|
120
|
+
end
|
121
|
+
|
122
|
+
def find_character(character, trie)
|
123
|
+
trie.find { |n| n.value == character }
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_node(character, trie)
|
127
|
+
TrieNode.new(character).tap { |new_node| trie << new_node }
|
128
|
+
end
|
129
|
+
=end
|
130
|
+
end # class
|
131
|
+
end # module
|
132
|
+
end # module
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_trie_node'
|
4
|
+
|
5
|
+
module Zenlish
|
6
|
+
module Trie
|
7
|
+
class TrieNode < BaseTrieNode
|
8
|
+
# @return [String] the matching character
|
9
|
+
attr_reader :key
|
10
|
+
|
11
|
+
# @return [Object, NilClass] Result when this character matches end-of-word.
|
12
|
+
attr_accessor :value
|
13
|
+
|
14
|
+
def initialize(aChar)
|
15
|
+
super()
|
16
|
+
@key = aChar
|
17
|
+
@value = nil
|
18
|
+
end
|
19
|
+
end # class
|
20
|
+
end # module
|
21
|
+
end # module
|
data/lib/zenlish/version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'word_class'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -6,8 +8,9 @@ module Zenlish
|
|
6
8
|
class Adjective < WordClass
|
7
9
|
# @return [FalseClass] Indicates that an adjective may inflect.
|
8
10
|
def invariable?
|
9
|
-
false
|
10
|
-
|
11
|
+
# TODO: set to false once we introduce the degrees (basic, comparative, superlative)
|
12
|
+
true
|
13
|
+
end
|
11
14
|
end # class
|
12
15
|
end # module
|
13
16
|
end # module
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'adverb'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
|
-
# The adverb maybe expresses uncertainty and is often placed in front
|
7
|
+
# The adverb maybe expresses uncertainty and is often placed in front
|
6
8
|
# of clauses.
|
7
9
|
class AdverbMaybe < Adverb
|
8
10
|
end # class
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Load the WordClass class hierarchy
|
2
4
|
# Algorithm: load the leaf classes from hierarchy
|
3
5
|
|
@@ -20,6 +22,7 @@ require_relative 'proper_noun'
|
|
20
22
|
require_relative 'irregular_linking_verb'
|
21
23
|
require_relative 'irregular_verb'
|
22
24
|
require_relative 'irregular_verb_be'
|
25
|
+
require_relative 'irregular_verb_can'
|
23
26
|
require_relative 'irregular_verb_do'
|
24
27
|
require_relative 'irregular_verb_have'
|
25
28
|
require_relative 'irregular_verb_know'
|
@@ -32,7 +35,6 @@ require_relative 'indefinite_article'
|
|
32
35
|
require_relative 'indefinite_pronoun'
|
33
36
|
require_relative 'linking_adverb'
|
34
37
|
require_relative 'modal_verb_can'
|
35
|
-
require_relative 'modal_verb_could'
|
36
38
|
require_relative 'personal_pronoun'
|
37
39
|
require_relative 'possessive_determiner'
|
38
40
|
require_relative 'preposition'
|
@@ -43,4 +45,4 @@ require_relative 'fronting_quantifier'
|
|
43
45
|
require_relative 'regular_verb'
|
44
46
|
require_relative 'regular_verb_want'
|
45
47
|
require_relative 'relative_pronoun'
|
46
|
-
require_relative 'subordinating_conjunction'
|
48
|
+
require_relative 'subordinating_conjunction'
|
@@ -1,10 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'verb'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
|
-
# The verbs: be, have, do
|
7
|
+
# The verbs: be, have, do and the modal verbs can, could, may, must, shall,
|
8
|
+
# should, will, would
|
6
9
|
# As they are so important to the English language, they deserve
|
7
|
-
# their own class
|
10
|
+
# their own class(es)
|
8
11
|
class Auxiliary < Verb
|
9
12
|
end # class
|
10
13
|
end # module
|
@@ -1,9 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'auxiliary'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
|
-
# TODO: document
|
6
7
|
class AuxiliaryBe < Auxiliary
|
8
|
+
# rubocop: disable Layout/SpaceInsideArrayLiteralBrackets
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def init_feature_defs
|
13
|
+
super
|
14
|
+
# Create standard feature definitions for modal verb can.
|
15
|
+
feature_def_dsl do
|
16
|
+
feature_def 'PARADIGM' => [identifier, 'Verb_be_inflection'] # 2nd item is default value
|
17
|
+
end
|
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
|
39
|
+
# rubocop: enable Layout/SpaceInsideArrayLiteralBrackets
|
7
40
|
end # class
|
8
41
|
end # module
|
9
42
|
end # module
|
@@ -1,9 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'auxiliary'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
7
|
# TODO: document
|
6
8
|
class AuxiliaryDo < Auxiliary
|
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 'PARADIGM' => [identifier, 'Verb_do_inflection'] # 2nd item is default value
|
18
|
+
end
|
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
|
37
|
+
# rubocop: enable Layout/SpaceInsideArrayLiteralBrackets
|
7
38
|
end # class
|
8
39
|
end # module
|
9
40
|
end # module
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'word_class'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module WClasses
|
5
|
-
# TODO: document
|
7
|
+
# TODO: document
|
6
8
|
# Example: 'as' in 'same ... as'
|
7
|
-
class ComparativeParticle < WordClass
|
9
|
+
class ComparativeParticle < WordClass
|
8
10
|
end # class
|
9
11
|
end # module
|
10
|
-
end # module
|
12
|
+
end # module
|