zenlish 0.1.25 → 0.2.00
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -1
- data/LICENSE.txt +1 -1
- data/README.md +3 -3
- data/lib/zenlish/feature/boolean_domain.rb +29 -0
- data/lib/zenlish/feature/boolean_value.rb +9 -0
- data/lib/zenlish/feature/enumeration_domain.rb +32 -0
- data/lib/zenlish/feature/feature.rb +30 -0
- data/lib/zenlish/feature/feature_def.rb +48 -0
- data/lib/zenlish/feature/feature_domain.rb +9 -0
- data/lib/zenlish/feature/feature_struct.rb +24 -0
- data/lib/zenlish/feature/feature_struct_def.rb +44 -0
- data/lib/zenlish/feature/feature_struct_def_bearer.rb +65 -0
- data/lib/zenlish/feature/feature_value.rb +17 -0
- data/lib/zenlish/feature/identifier_domain.rb +29 -0
- data/lib/zenlish/feature/identifier_value.rb +9 -0
- data/lib/zenlish/feature/symbol_value.rb +8 -0
- data/lib/zenlish/inflect/atomic_o_expression.rb +9 -0
- data/lib/zenlish/inflect/composite_o_expression.rb +14 -0
- data/lib/zenlish/inflect/concatenation.rb +36 -0
- data/lib/zenlish/inflect/equals_literal.rb +25 -0
- data/lib/zenlish/inflect/feature_heading.rb +16 -0
- data/lib/zenlish/inflect/formal_argument.rb +11 -0
- data/lib/zenlish/inflect/heading.rb +11 -0
- data/lib/zenlish/inflect/inflection_rule.rb +28 -0
- data/lib/zenlish/inflect/inflection_table.rb +46 -0
- data/lib/zenlish/inflect/inflection_table_builder.rb +120 -0
- data/lib/zenlish/inflect/input_asis.rb +22 -0
- data/lib/zenlish/inflect/input_expression.rb +9 -0
- data/lib/zenlish/inflect/literal_asis.rb +17 -0
- data/lib/zenlish/inflect/matches_pattern.rb +26 -0
- data/lib/zenlish/inflect/method_heading.rb +16 -0
- data/lib/zenlish/inflect/nullary_input_expression.rb +8 -0
- data/lib/zenlish/inflect/output_expression.rb +6 -0
- data/lib/zenlish/inflect/substitution.rb +65 -0
- data/lib/zenlish/inflect/unary_input_expression.rb +13 -0
- data/lib/zenlish/inflect/unconditionally_true.rb +11 -0
- data/lib/zenlish/lang/dictionary.rb +19 -6
- data/lib/zenlish/lang/zenlish_grammar.rb +1 -0
- data/lib/zenlish/lex/empty_lexicon_factory.rb +3 -0
- data/lib/zenlish/lex/lexeme.rb +27 -4
- data/lib/zenlish/lex/lexicon.rb +3 -0
- data/lib/zenlish/lex/literal.rb +5 -1
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/common_noun.rb +45 -0
- data/lib/zenlish/wclasses/noun.rb +21 -0
- data/lib/zenlish/wclasses/preposition.rb +5 -0
- data/lib/zenlish/wclasses/proper_noun.rb +11 -0
- data/lib/zenlish/wclasses/verb.rb +9 -1
- data/lib/zenlish/wclasses/word_class.rb +21 -6
- data/spec/spec_helper.rb +2 -3
- data/spec/zenlish/feature/boolean_domain_spec.rb +35 -0
- data/spec/zenlish/feature/boolean_value_spec.rb +26 -0
- data/spec/zenlish/feature/enumeration_domain_spec.rb +42 -0
- data/spec/zenlish/feature/feature_def_spec.rb +50 -0
- data/spec/zenlish/feature/feature_spec.rb +51 -0
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +54 -0
- data/spec/zenlish/feature/feature_struct_def_spec.rb +69 -0
- data/spec/zenlish/feature/identifier_domain_spec.rb +36 -0
- data/spec/zenlish/feature/identifier_value_spec.rb +26 -0
- data/spec/zenlish/feature/symbol_value_spec.rb +27 -0
- data/spec/zenlish/inflect/concatenation_spec.rb +40 -0
- data/spec/zenlish/inflect/equals_literal_spec.rb +58 -0
- data/spec/zenlish/inflect/feature_heading_spec.rb +30 -0
- data/spec/zenlish/inflect/formal_argument_spec.rb +25 -0
- data/spec/zenlish/inflect/inflection_rule_spec.rb +102 -0
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +127 -0
- data/spec/zenlish/inflect/inflection_table_spec.rb +129 -0
- data/spec/zenlish/inflect/input_asis_spec.rb +50 -0
- data/spec/zenlish/inflect/literal_asis_spec.rb +31 -0
- data/spec/zenlish/inflect/matches_pattern_spec.rb +61 -0
- data/spec/zenlish/inflect/method_heading_spec.rb +31 -0
- data/spec/zenlish/inflect/substitution_spec.rb +43 -0
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +28 -0
- data/spec/zenlish/lang/dictionary_spec.rb +33 -0
- data/spec/zenlish/lex/lexeme_spec.rb +24 -9
- data/spec/zenlish/lex/literal_spec.rb +3 -11
- data/spec/zenlish/parser/lesson3_spec.rb +44 -0
- data/spec/zenlish/support/minimal_lexicon.rb +0 -2
- data/spec/zenlish/support/var2word.rb +5 -1
- data/spec/zenlish/wclasses/common_noun_spec.rb +25 -4
- data/spec/zenlish/wclasses/noun_spec.rb +31 -0
- data/spec/zenlish/wclasses/preposition_spec.rb +24 -0
- data/spec/zenlish/wclasses/verb_spec.rb +24 -0
- metadata +89 -2
@@ -1,20 +1,35 @@
|
|
1
1
|
require 'rley'
|
2
|
+
require_relative '../feature/feature_struct_def_bearer'
|
2
3
|
|
3
4
|
module Zenlish
|
4
5
|
module WClasses
|
5
6
|
# Also known as: part of speech, syntactic category or word category.
|
6
7
|
# A word class represents a group of word which have similar functions.
|
7
8
|
# Word classes are divided into:
|
8
|
-
# - Lexical words (?? same as content words??) such as nouns, verbs, adjectives,
|
9
|
-
# Content words carry the meaning of a sentence
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
9
|
+
# - Lexical words (?? same as content words??) such as nouns, verbs, adjectives,
|
10
|
+
# adverbs. Content words carry the meaning of a sentence for the chosen discourse
|
11
|
+
# universe.
|
12
|
+
#
|
13
|
+
# - Function words (?? same as structure words??) such as pronouns, determiners,
|
14
|
+
# modal verbs, auxiliary verbs. Structure words helpt to structure a sentence.
|
15
|
+
# They working is independent of the chosen discourse universe.
|
13
16
|
# conjunctions and prepositions
|
14
17
|
class WordClass < Rley::Syntax::Terminal
|
18
|
+
include Feature::FeatureStructDefBearer
|
19
|
+
# @return [Hash] pair of the kind: String => InflectionTable
|
20
|
+
attr_reader :paradigms
|
21
|
+
|
15
22
|
def initialize
|
16
23
|
super(self.class.name.split('::').last)
|
24
|
+
init_struct_def(nil, {})
|
25
|
+
@paradigms = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Indicates whether all words from the word class have a single (uninflected)
|
29
|
+
# form.
|
30
|
+
def invariable?
|
31
|
+
raise NotImplementedError, "Missing implementation for #{self.class}."
|
17
32
|
end
|
18
33
|
end # class
|
19
|
-
end # module
|
34
|
+
end # module
|
20
35
|
end # module
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'rspec' # Use the RSpec framework
|
3
|
-
# require_relative '../lib/zenlish'
|
4
3
|
|
5
4
|
RSpec.configure do |config|
|
6
5
|
# Enable flags like --only-failures and --next-failure
|
7
6
|
config.example_status_persistence_file_path = ".rspec_status"
|
8
|
-
|
7
|
+
|
9
8
|
config.expect_with :rspec do |c|
|
10
9
|
# Disable the `should` syntax
|
11
10
|
c.syntax = :expect
|
12
11
|
end
|
13
12
|
|
14
13
|
# Display stack trace in case of failure
|
15
|
-
config.full_backtrace = true
|
14
|
+
config.full_backtrace = true
|
16
15
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/feature/boolean_domain' # Load the class under test
|
4
|
+
|
5
|
+
module Zenlish
|
6
|
+
module Feature
|
7
|
+
describe BooleanDomain do
|
8
|
+
subject { BooleanDomain.instance }
|
9
|
+
|
10
|
+
context 'Initialization:' do
|
11
|
+
it 'should be initialized without argument' do
|
12
|
+
expect { BooleanDomain.instance }.not_to raise_error
|
13
|
+
end
|
14
|
+
end # context
|
15
|
+
|
16
|
+
context 'Provided services:' do
|
17
|
+
it 'should know whether a value is in domain' do
|
18
|
+
expect(subject.include?('invalid')).to be_falsey
|
19
|
+
expect(subject.include?(true)).to be_truthy
|
20
|
+
expect(subject.include?(false)).to be_truthy
|
21
|
+
end
|
22
|
+
it 'should provide a factory method for boolean values' do
|
23
|
+
expect(subject.build_value(true)).to be_kind_of(BooleanValue)
|
24
|
+
expect(subject.build_value(false)).to be_kind_of(BooleanValue)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should complain when asked to build a non-boolean value' do
|
28
|
+
err = StandardError
|
29
|
+
err_msg = 'Expected a boolean instead of String.'
|
30
|
+
expect { subject.build_value('?') }.to raise_error(err, err_msg)
|
31
|
+
end
|
32
|
+
end # context
|
33
|
+
end # describe
|
34
|
+
end # module
|
35
|
+
end # module
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/feature/boolean_domain'
|
4
|
+
require_relative '../../../lib/zenlish/feature/boolean_value' # Load the class under test
|
5
|
+
|
6
|
+
module Zenlish
|
7
|
+
module Feature
|
8
|
+
describe BooleanValue do
|
9
|
+
let(:its_value) { false }
|
10
|
+
subject { BooleanValue.new(its_value) }
|
11
|
+
|
12
|
+
context 'Initialization:' do
|
13
|
+
it 'should be initialized with a value argument' do
|
14
|
+
expect { BooleanValue.new(its_value) }.not_to raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should know its internal value' do
|
18
|
+
expect(subject.val.class).to eq(FalseClass)
|
19
|
+
end
|
20
|
+
end # context
|
21
|
+
|
22
|
+
context 'Provided services:' do
|
23
|
+
end # context
|
24
|
+
end # describe
|
25
|
+
end # module
|
26
|
+
end # module
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Load the class under test
|
4
|
+
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
5
|
+
|
6
|
+
module Zenlish
|
7
|
+
module Feature
|
8
|
+
describe EnumerationDomain do
|
9
|
+
subject { EnumerationDomain.new(:singular, :plural) }
|
10
|
+
|
11
|
+
context 'Initialization:' do
|
12
|
+
it 'should be initialized with arguments' do
|
13
|
+
expect { EnumerationDomain.new(:singular, :plural) }.not_to raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should know the values of enumeration' do
|
17
|
+
expect(subject.enum).to eq([:singular, :plural])
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
21
|
+
context 'Provided services:' do
|
22
|
+
it 'should know whether a value is in domain' do
|
23
|
+
expect(subject.include?(:dual)).to be_falsey
|
24
|
+
expect(subject.include?(:singular)).to be_truthy
|
25
|
+
expect(subject.include?(:plural)).to be_truthy
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should provide a factory method for enumerated value' do
|
29
|
+
expect(subject.build_value(:plural)).to be_kind_of(SymbolValue)
|
30
|
+
value = subject.build_value(:plural)
|
31
|
+
expect(value.val).to eq(:plural)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should complain when asked to build a non-member value' do
|
35
|
+
err = StandardError
|
36
|
+
err_msg = "dual isn't part of enumeration [singular, plural]."
|
37
|
+
expect { subject.build_value(:dual) }.to raise_error(err, err_msg)
|
38
|
+
end
|
39
|
+
end # context
|
40
|
+
end # describe
|
41
|
+
end # module
|
42
|
+
end # module
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
4
|
+
# Load the class under test
|
5
|
+
require_relative '../../../lib/zenlish/feature/feature_def'
|
6
|
+
|
7
|
+
module Zenlish
|
8
|
+
module Feature
|
9
|
+
describe FeatureDef do
|
10
|
+
let(:a_name) { 'NUMBER' }
|
11
|
+
let(:a_domain) { EnumerationDomain.new(:singular, :plural) }
|
12
|
+
subject { FeatureDef.new(a_name, a_domain) }
|
13
|
+
|
14
|
+
context 'Initialization:' do
|
15
|
+
it 'should be initialized with at least two arguments' do
|
16
|
+
expect { FeatureDef.new(a_name, a_domain) }.not_to raise_error
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'could be initialized with a default value argument' do
|
20
|
+
deflt = double('dummy')
|
21
|
+
expect { FeatureDef.new(a_name, a_domain, deflt) }.not_to raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should know its name' do
|
25
|
+
expect(subject.name).to eq(a_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should know the domain of its values' do
|
29
|
+
expect(subject.domain).to eq(a_domain)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should know the domain of its default value' do
|
33
|
+
expect(subject.default).to be_nil
|
34
|
+
deflt = double('dummy')
|
35
|
+
instance = FeatureDef.new(a_name, a_domain, deflt)
|
36
|
+
expect(instance.default).to eq(deflt)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should guess its default if enumeration has a single member' do
|
40
|
+
basic_domain = EnumerationDomain.new(:plural)
|
41
|
+
instance = FeatureDef.new(a_name, basic_domain)
|
42
|
+
expect(instance.default.val).to eq(:plural)
|
43
|
+
end
|
44
|
+
end # context
|
45
|
+
|
46
|
+
context 'Provided services:' do
|
47
|
+
end # context
|
48
|
+
end # describe
|
49
|
+
end # module
|
50
|
+
end # module
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
4
|
+
require_relative '../../../lib/zenlish/feature/feature_def'
|
5
|
+
# Load the class under test
|
6
|
+
require_relative '../../../lib/zenlish/feature/feature'
|
7
|
+
|
8
|
+
|
9
|
+
module Zenlish
|
10
|
+
module Feature
|
11
|
+
describe Feature do
|
12
|
+
let(:a_name) { 'NUMBER' }
|
13
|
+
let(:a_domain) { EnumerationDomain.new(:singular, :plural) }
|
14
|
+
let(:feat_def) { FeatureDef.new(a_name, a_domain) }
|
15
|
+
let(:plural_value) { a_domain.build_value(:plural) }
|
16
|
+
|
17
|
+
subject { Feature.new(feat_def) }
|
18
|
+
|
19
|
+
context 'Initialization:' do
|
20
|
+
it 'should be initialized with one definition argument' do
|
21
|
+
expect { Feature.new(feat_def) }.not_to raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should know its definition' do
|
25
|
+
expect(subject.definition).to eq(feat_def)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should'nt be bound yet to a value" do
|
29
|
+
expect(subject.binding).to be_nil
|
30
|
+
expect(subject).not_to be_bound
|
31
|
+
end
|
32
|
+
end # context
|
33
|
+
|
34
|
+
context 'Provided services:' do
|
35
|
+
it "should know the definition's name" do
|
36
|
+
expect(subject.name).to eq(feat_def.name)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should know the domain of its values" do
|
40
|
+
expect(subject.domain).to eq(a_domain)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should accept a value binding' do
|
44
|
+
expect { subject.bind_to(plural_value) }.not_to raise_error
|
45
|
+
expect(subject).to be_bound
|
46
|
+
expect(subject.binding).to eq(plural_value)
|
47
|
+
end
|
48
|
+
end # context
|
49
|
+
end # describe
|
50
|
+
end # module
|
51
|
+
end # module
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Load the class under test
|
4
|
+
require_relative '../../../lib/zenlish/feature/feature_struct_def_bearer'
|
5
|
+
|
6
|
+
module Zenlish
|
7
|
+
module Feature
|
8
|
+
describe FeatureStructDefBearer do
|
9
|
+
# @nodoc Class created just for testing purposes.
|
10
|
+
class Dummy
|
11
|
+
include FeatureStructDefBearer
|
12
|
+
|
13
|
+
def initialize(aParent)
|
14
|
+
feature_hash = {
|
15
|
+
'NUMBER' => enumeration(:singular, :plural),
|
16
|
+
'COUNTABILITY' => boolean,
|
17
|
+
'PARADIGM' => [identifier, 'CommonForm']
|
18
|
+
}
|
19
|
+
|
20
|
+
init_struct_def(aParent, feature_hash)
|
21
|
+
end
|
22
|
+
end # class
|
23
|
+
|
24
|
+
subject { Dummy.new (nil) }
|
25
|
+
|
26
|
+
context 'Mix-in initialization' do
|
27
|
+
it 'should have initialized properly the injected data' do
|
28
|
+
expect { Dummy.new(nil) }.not_to raise_error
|
29
|
+
expect(subject.struct).to be_kind_of(FeatureStructDef)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have the feature definitions created' do
|
33
|
+
expect(subject['NUMBER']).not_to be_nil
|
34
|
+
expect(subject['NUMBER']).to be_kind_of(FeatureDef)
|
35
|
+
ft = subject['NUMBER']
|
36
|
+
expect(ft.domain.enum).to eq([:singular, :plural])
|
37
|
+
|
38
|
+
expect(subject['COUNTABILITY']).to be_kind_of(FeatureDef)
|
39
|
+
expect(subject['COUNTABILITY'].domain).to be_kind_of(BooleanDomain)
|
40
|
+
expect(subject['PARADIGM']).to be_kind_of(FeatureDef)
|
41
|
+
expect(subject['PARADIGM'].domain).to be_kind_of(IdentifierDomain)
|
42
|
+
expect(subject['PARADIGM'].default).to be_kind_of(IdentifierValue)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should support the addition of feature def' do
|
46
|
+
subject.feature_def_dsl { feature_def 'CASE' => boolean }
|
47
|
+
|
48
|
+
expect(subject['CASE']).to be_kind_of(FeatureDef)
|
49
|
+
expect(subject['CASE'].domain).to be_kind_of(BooleanDomain)
|
50
|
+
end
|
51
|
+
end # context
|
52
|
+
end # describe
|
53
|
+
end # module
|
54
|
+
end # module
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../../../lib/zenlish/feature/boolean_domain'
|
3
|
+
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
4
|
+
require_relative '../../../lib/zenlish/feature/feature_def'
|
5
|
+
# Load the class under test
|
6
|
+
require_relative '../../../lib/zenlish/feature/feature_struct_def'
|
7
|
+
|
8
|
+
|
9
|
+
module Zenlish
|
10
|
+
module Feature
|
11
|
+
describe FeatureStructDef do
|
12
|
+
let(:enum_number) { EnumerationDomain.new(:singular, :plural) }
|
13
|
+
let(:ft_number) { FeatureDef.new('NUMBER', enum_number) }
|
14
|
+
let(:countable_domain) { BooleanDomain.instance }
|
15
|
+
let(:ft_countability) { FeatureDef.new('COUNTABILITY', countable_domain) }
|
16
|
+
let(:sample_parent) { FeatureStructDef.new }
|
17
|
+
let(:case_domain) { EnumerationDomain.new(:common, :genitive) }
|
18
|
+
let(:ft_case) { FeatureDef.new('CASE', case_domain) }
|
19
|
+
|
20
|
+
subject { FeatureStructDef.new(sample_parent) }
|
21
|
+
|
22
|
+
context 'Initialization:' do
|
23
|
+
it 'could be initialized without argument' do
|
24
|
+
expect { FeatureStructDef.new }.not_to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'could be initialized with a parent struct' do
|
28
|
+
expect { FeatureStructDef.new(sample_parent) }.not_to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have an empty structure at initialization' do
|
32
|
+
expect(subject.struct).to be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should know its parent (if any)' do
|
36
|
+
expect(subject.parent).to eq(sample_parent)
|
37
|
+
instance = FeatureStructDef.new
|
38
|
+
expect(instance.parent).to be_nil
|
39
|
+
end
|
40
|
+
end # context
|
41
|
+
|
42
|
+
context 'Provided services:' do
|
43
|
+
it 'should accept the addition of a feature definition' do
|
44
|
+
expect { subject.add_feature_def(ft_number) }.not_to raise_error
|
45
|
+
expect(subject.struct.size).to eq(1)
|
46
|
+
expect(subject['NUMBER']).to eq(ft_number)
|
47
|
+
|
48
|
+
expect { subject.add_feature_def(ft_countability) }.not_to raise_error
|
49
|
+
expect(subject.struct.size).to eq(2)
|
50
|
+
expect(subject['COUNTABILITY']).to eq(ft_countability)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should inherit the feature definition of its parent' do
|
54
|
+
sample_parent.add_feature_def(ft_case)
|
55
|
+
expect(subject['CASE']).to eq(ft_case)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be able to override parent's feature def" do
|
59
|
+
sample_parent.add_feature_def(ft_case)
|
60
|
+
|
61
|
+
other_case_domain = BooleanDomain.instance
|
62
|
+
other_ft_case = FeatureDef.new('CASE', other_case_domain)
|
63
|
+
subject.add_feature_def(other_ft_case)
|
64
|
+
expect(subject['CASE']).to eq(other_ft_case)
|
65
|
+
end
|
66
|
+
end # context
|
67
|
+
end # describe
|
68
|
+
end # module
|
69
|
+
end # module
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/feature/identifier_domain' # Load the class under test
|
4
|
+
|
5
|
+
module Zenlish
|
6
|
+
module Feature
|
7
|
+
describe IdentifierDomain do
|
8
|
+
subject { IdentifierDomain.instance }
|
9
|
+
|
10
|
+
context 'Initialization:' do
|
11
|
+
it 'should be instantiated without argument' do
|
12
|
+
expect { IdentifierDomain.instance }.not_to raise_error
|
13
|
+
end
|
14
|
+
end # context
|
15
|
+
|
16
|
+
context 'Provided services:' do
|
17
|
+
it 'should know whether a value is in domain' do
|
18
|
+
expect(subject.include?('CommonForm')).to be_truthy
|
19
|
+
expect(subject.include?('Common Form')).to be_falsey
|
20
|
+
expect(subject.include?('+123')).to be_falsey
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should provide a factory method for identifier values' do
|
24
|
+
expect(subject.build_value('CommonForm')).to be_kind_of(IdentifierValue)
|
25
|
+
expect(subject.build_value('Common_Form')).to be_kind_of(IdentifierValue)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should complain when asked to build an invalid identifier' do
|
29
|
+
err = StandardError
|
30
|
+
err_msg = "?1234 isn't a valid identifier."
|
31
|
+
expect { subject.build_value('?1234') }.to raise_error(err, err_msg)
|
32
|
+
end
|
33
|
+
end # context
|
34
|
+
end # describe
|
35
|
+
end # module
|
36
|
+
end # module
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Load the class under test
|
4
|
+
require_relative '../../../lib/zenlish/feature/identifier_value'
|
5
|
+
|
6
|
+
module Zenlish
|
7
|
+
module Feature
|
8
|
+
describe IdentifierValue do
|
9
|
+
let(:its_value) { 'CommonForm' }
|
10
|
+
subject { IdentifierValue.new(its_value) }
|
11
|
+
|
12
|
+
context 'Initialization:' do
|
13
|
+
it 'should be initialized with a value argument' do
|
14
|
+
expect { IdentifierValue.new(its_value) }.not_to raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should know its internal value' do
|
18
|
+
expect(subject.val).to eq(its_value)
|
19
|
+
end
|
20
|
+
end # context
|
21
|
+
|
22
|
+
context 'Provided services:' do
|
23
|
+
end # context
|
24
|
+
end # describe
|
25
|
+
end # module
|
26
|
+
end # module
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
4
|
+
# Load the class under test
|
5
|
+
require_relative '../../../lib/zenlish/feature/symbol_value'
|
6
|
+
|
7
|
+
module Zenlish
|
8
|
+
module Feature
|
9
|
+
describe SymbolValue do
|
10
|
+
let(:its_value) { :plural }
|
11
|
+
subject { SymbolValue.new(its_value) }
|
12
|
+
|
13
|
+
context 'Initialization:' do
|
14
|
+
it 'should be initialized with a value argument' do
|
15
|
+
expect { SymbolValue.new(its_value) }.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should know its internal value' do
|
19
|
+
expect(subject.val).to eq(its_value)
|
20
|
+
end
|
21
|
+
end # context
|
22
|
+
|
23
|
+
context 'Provided services:' do
|
24
|
+
end # context
|
25
|
+
end # describe
|
26
|
+
end # module
|
27
|
+
end # module
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/inflect/formal_argument'
|
4
|
+
require_relative '../../../lib/zenlish/inflect/input_asis'
|
5
|
+
# Load the class under test
|
6
|
+
require_relative '../../../lib/zenlish/inflect/concatenation'
|
7
|
+
|
8
|
+
module Zenlish
|
9
|
+
module Inflect
|
10
|
+
describe Concatenation do
|
11
|
+
let(:suffix) { LiteralAsIs.new('s') }
|
12
|
+
let(:sample_argument) { FormalArgument.new(2) }
|
13
|
+
let(:base_form) { InputAsIs.new(sample_argument) }
|
14
|
+
|
15
|
+
subject { Concatenation.new(base_form, suffix) }
|
16
|
+
|
17
|
+
context 'Initialization:' do
|
18
|
+
it 'should be initialized with two arguments' do
|
19
|
+
expect { Concatenation.new(base_form, suffix) }.not_to raise_error
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should know its arguments' do
|
23
|
+
expect(subject.children.first).to eq(base_form)
|
24
|
+
expect(subject.children.last).to eq(suffix)
|
25
|
+
end
|
26
|
+
end # context
|
27
|
+
|
28
|
+
context 'Provided services:' do
|
29
|
+
let(:sample_values) { [nil, nil, 'place', nil] }
|
30
|
+
|
31
|
+
it 'should do the concatenation of children results' do
|
32
|
+
headings = double('fake-headings')
|
33
|
+
lexeme = double('fake-lexeme')
|
34
|
+
|
35
|
+
expect(subject.generate(headings, lexeme, sample_values)).to eq('places')
|
36
|
+
end
|
37
|
+
end # context
|
38
|
+
end # describe
|
39
|
+
end # module
|
40
|
+
end # module
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../lib/zenlish/wclasses/common_noun'
|
4
|
+
require_relative '../../../lib/zenlish/lex/lexeme'
|
5
|
+
require_relative '../../../lib/zenlish/lex/lexical_entry'
|
6
|
+
require_relative '../../../lib/zenlish/inflect/feature_heading'
|
7
|
+
require_relative '../../../lib/zenlish/inflect/formal_argument'
|
8
|
+
# Load the class under test
|
9
|
+
require_relative '../../../lib/zenlish/inflect/equals_literal'
|
10
|
+
|
11
|
+
module Zenlish
|
12
|
+
module Inflect
|
13
|
+
describe EqualsLiteral do
|
14
|
+
let(:an_argument) { FormalArgument.new(1) }
|
15
|
+
let(:feat_val) { :plural }
|
16
|
+
subject { EqualsLiteral.new(an_argument, feat_val) }
|
17
|
+
|
18
|
+
context 'Initialization:' do
|
19
|
+
it 'should be initialized with a method name' do
|
20
|
+
expect { EqualsLiteral.new(an_argument, feat_val) }.not_to raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should know its argument' do
|
24
|
+
expect(subject.argument).to eq(an_argument)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should know the literal' do
|
28
|
+
expect(subject.literal).to eq(feat_val)
|
29
|
+
end
|
30
|
+
end # context
|
31
|
+
|
32
|
+
context 'Provided services:' do
|
33
|
+
it 'should test the actual argument' do
|
34
|
+
lexeme = double('dummy-lexeme')
|
35
|
+
headings = double('fake-headings')
|
36
|
+
actual_args = [nil, :plural, nil]
|
37
|
+
expect(subject.success?(headings, lexeme, actual_args)).to be_truthy
|
38
|
+
actual_args[1] = :singular
|
39
|
+
expect(subject.success?(headings, lexeme, actual_args)).to be_falsy
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should test the lexeme' do
|
43
|
+
c_noun = WClasses::CommonNoun.new
|
44
|
+
entry = Lex::LexicalEntry.new('animal')
|
45
|
+
lexeme = Lex::Lexeme.new(c_noun, entry)
|
46
|
+
headings = [nil, FeatureHeading.new('NUMBER'), nil]
|
47
|
+
expect(subject.success?(headings, lexeme, [])).to be_truthy
|
48
|
+
|
49
|
+
instance = EqualsLiteral.new(an_argument, :singular)
|
50
|
+
expect(instance.success?(headings, lexeme, [])).to be_truthy
|
51
|
+
|
52
|
+
instance = EqualsLiteral.new(an_argument, :irregular)
|
53
|
+
expect(instance.success?(headings, lexeme, [])).to be_falsey
|
54
|
+
end
|
55
|
+
end # context
|
56
|
+
end # describe
|
57
|
+
end # module
|
58
|
+
end # module
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Load the class under test
|
4
|
+
require_relative '../../../lib/zenlish/inflect/feature_heading'
|
5
|
+
|
6
|
+
module Zenlish
|
7
|
+
module Inflect
|
8
|
+
describe FeatureHeading do
|
9
|
+
let(:feature_name) { 'NUMBER' }
|
10
|
+
subject { FeatureHeading.new(feature_name) }
|
11
|
+
|
12
|
+
context 'Initialization:' do
|
13
|
+
it 'should be initialized with a feature name' do
|
14
|
+
expect { FeatureHeading.new(feature_name) }.not_to raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should know its label' do
|
18
|
+
expect(subject.label).to eq(feature_name)
|
19
|
+
end
|
20
|
+
end # context
|
21
|
+
|
22
|
+
context 'Provided services:' do
|
23
|
+
it 'should obtain the feature value from a word' do
|
24
|
+
mocked = { 'NUMBER' => :plural }
|
25
|
+
expect(subject.evaluate_for(mocked)).to eq(:plural)
|
26
|
+
end
|
27
|
+
end # context
|
28
|
+
end # describe
|
29
|
+
end # module
|
30
|
+
end # module
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Load the class under test
|
4
|
+
require_relative '../../../lib/zenlish/inflect/formal_argument'
|
5
|
+
|
6
|
+
module Zenlish
|
7
|
+
module Inflect
|
8
|
+
describe FormalArgument do
|
9
|
+
subject { FormalArgument.new(3) }
|
10
|
+
|
11
|
+
context 'Initialization:' do
|
12
|
+
it 'should be initialized with a text literal' do
|
13
|
+
expect { FormalArgument.new(1) }.not_to raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should know its index value' do
|
17
|
+
expect(subject.index).to eq(3)
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
21
|
+
context 'Provided services:' do
|
22
|
+
end # context
|
23
|
+
end # describe
|
24
|
+
end # module
|
25
|
+
end # module
|