zenlish 0.2.06 → 0.2.07

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +48 -275
  3. data/CHANGELOG.md +8 -0
  4. data/LICENSE.txt +1 -1
  5. data/lib/zenlish/feature/feature_struct_def.rb +0 -2
  6. data/lib/zenlish/inflect/output_expression.rb +4 -0
  7. data/lib/zenlish/version.rb +1 -1
  8. data/lib/zenlish/wclasses/irregular_verb_extension.rb +0 -1
  9. data/lib/zenlish.rb +3 -3
  10. data/spec/zenlish/feature/boolean_domain_spec.rb +14 -14
  11. data/spec/zenlish/feature/boolean_value_spec.rb +6 -5
  12. data/spec/zenlish/feature/enumeration_domain_spec.rb +16 -16
  13. data/spec/zenlish/feature/feature_def_spec.rb +15 -14
  14. data/spec/zenlish/feature/feature_spec.rb +16 -16
  15. data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +16 -16
  16. data/spec/zenlish/feature/feature_struct_def_spec.rb +23 -23
  17. data/spec/zenlish/feature/identifier_domain_spec.rb +12 -12
  18. data/spec/zenlish/feature/identifier_value_spec.rb +6 -5
  19. data/spec/zenlish/feature/symbol_value_spec.rb +6 -5
  20. data/spec/zenlish/inflect/concatenation_spec.rb +8 -8
  21. data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
  22. data/spec/zenlish/inflect/feature_heading_spec.rb +14 -13
  23. data/spec/zenlish/inflect/formal_argument_spec.rb +5 -5
  24. data/spec/zenlish/inflect/function_call_spec.rb +8 -9
  25. data/spec/zenlish/inflect/inflection_rule_spec.rb +20 -20
  26. data/spec/zenlish/inflect/inflection_table_builder_spec.rb +37 -37
  27. data/spec/zenlish/inflect/inflection_table_spec.rb +33 -32
  28. data/spec/zenlish/inflect/input_asis_spec.rb +10 -9
  29. data/spec/zenlish/inflect/literal_asis_spec.rb +7 -7
  30. data/spec/zenlish/inflect/matches_pattern_spec.rb +15 -14
  31. data/spec/zenlish/inflect/membership_spec.rb +16 -15
  32. data/spec/zenlish/inflect/method_heading_spec.rb +12 -11
  33. data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
  34. data/spec/zenlish/inflect/substitution_spec.rb +9 -10
  35. data/spec/zenlish/inflect/unconditionally_true_spec.rb +7 -5
  36. data/spec/zenlish/lang/dictionary_spec.rb +17 -19
  37. data/spec/zenlish/lang/lemmatizer_spec.rb +23 -23
  38. data/spec/zenlish/lang/zenlish_grammar_spec.rb +3 -3
  39. data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
  40. data/spec/zenlish/lex/lexeme_spec.rb +18 -18
  41. data/spec/zenlish/lex/lexical_entry_spec.rb +14 -13
  42. data/spec/zenlish/lex/lexicon_spec.rb +44 -43
  43. data/spec/zenlish/lex/literal_spec.rb +6 -6
  44. data/spec/zenlish/lexer/lexer_spec.rb +10 -10
  45. data/spec/zenlish/parser/lesson1_spec.rb +79 -79
  46. data/spec/zenlish/parser/lesson2_spec.rb +102 -102
  47. data/spec/zenlish/parser/lesson3_spec.rb +89 -89
  48. data/spec/zenlish/parser/zparser_spec.rb +6 -6
  49. data/spec/zenlish/support/var2word.rb +0 -2
  50. data/spec/zenlish/trie/base_trie_node_spec.rb +11 -11
  51. data/spec/zenlish/trie/trie_spec.rb +46 -46
  52. data/spec/zenlish/wclasses/common_noun_spec.rb +9 -9
  53. data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +11 -11
  54. data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +10 -10
  55. data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
  56. data/spec/zenlish/wclasses/irregular_verb_spec.rb +19 -19
  57. data/spec/zenlish/wclasses/lexical_verb_spec.rb +7 -7
  58. data/spec/zenlish/wclasses/modal_verb_can_spec.rb +9 -9
  59. data/spec/zenlish/wclasses/noun_spec.rb +7 -7
  60. data/spec/zenlish/wclasses/personal_pronoun_spec.rb +15 -15
  61. data/spec/zenlish/wclasses/possessive_determiner_spec.rb +15 -15
  62. data/spec/zenlish/wclasses/preposition_spec.rb +5 -5
  63. data/spec/zenlish/wclasses/proper_noun_spec.rb +3 -3
  64. data/spec/zenlish/wclasses/regular_verb_spec.rb +12 -12
  65. data/spec/zenlish/wclasses/regular_verb_want_spec.rb +7 -7
  66. data/spec/zenlish/wclasses/verb_spec.rb +9 -9
  67. data/spec/zenlish_spec.rb +1 -1
  68. data/zenlish.gemspec +6 -5
  69. metadata +32 -16
@@ -7,7 +7,7 @@ require_relative '../../../lib/zenlish/lang/dictionary' # Load the class under t
7
7
  module Zenlish
8
8
  module Lang
9
9
  describe Dictionary do
10
- subject { Dictionary }
10
+ subject(:dictionary) { described_class }
11
11
 
12
12
  context 'Provided services:' do
13
13
  let(:common_nouns) do
@@ -15,18 +15,6 @@ module Zenlish
15
15
  %w(animal body container here kind machine moment now part people
16
16
  person place side surface thing time word)
17
17
  end
18
-
19
- it 'should give the list of common nouns' do
20
- lexemes = []
21
- subject.entries.each do |ent|
22
- lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(Zenlish::WClasses::CommonNoun) }
23
- lexemes.concat(lexm) if lexm
24
- end
25
- lemmas = lexemes.map { |lx| lx.entry.lemma }
26
-
27
- expect(common_nouns.all? { |c_n| lemmas.include?(c_n) }).to be_truthy
28
- end
29
-
30
18
  let(:present_1sg) { [:first, :singular, :present, nil] }
31
19
  let(:present_2sg) { [:second, :singular, :present, nil] }
32
20
  let(:present_3sg) { [:third, :singular, :present, nil] }
@@ -45,8 +33,18 @@ module Zenlish
45
33
  end
46
34
  end
47
35
 
48
- it 'should know how to inflect an (irregular) verb' do
49
- lexm = subject.get_lexeme('become')
36
+ it 'gives the list of common nouns' do
37
+ lexemes = []
38
+ dictionary.entries.each do |ent|
39
+ lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(Zenlish::WClasses::CommonNoun) }
40
+ lexemes.concat(lexm) if lexm
41
+ end
42
+ lemmas = lexemes.map { |lx| lx.entry.lemma }
43
+ expect(common_nouns.all? { |c_n| lemmas.include?(c_n) }).to be_truthy
44
+ end
45
+
46
+ it 'knows how to inflect an (irregular) verb' do
47
+ lexm = dictionary.get_lexeme('become')
50
48
  expectations1 = [
51
49
  [present_1sg, 'become'],
52
50
  [present_3sg, 'becomes'],
@@ -57,7 +55,7 @@ module Zenlish
57
55
  ]
58
56
  test_inflection_of(lexm, expectations1)
59
57
 
60
- lexm = subject.get_lexeme('do', WClasses::IrregularVerbDo)
58
+ lexm = dictionary.get_lexeme('do', WClasses::IrregularVerbDo)
61
59
  expectations2 = [
62
60
  [present_1sg, 'do'],
63
61
  [present_3sg, 'does'],
@@ -68,7 +66,7 @@ module Zenlish
68
66
  ]
69
67
  test_inflection_of(lexm, expectations2, true)
70
68
 
71
- lexm = subject.get_lexeme('have', WClasses::IrregularVerbHave)
69
+ lexm = dictionary.get_lexeme('have', WClasses::IrregularVerbHave)
72
70
  expectations3 = [
73
71
  [present_1sg, 'have'],
74
72
  [present_3sg, 'has'],
@@ -80,9 +78,9 @@ module Zenlish
80
78
  test_inflection_of(lexm, expectations3, true)
81
79
  end
82
80
 
83
- it 'should know how to inflect the verb be' do
81
+ it 'knows how to inflect the verb be' do
84
82
  [WClasses::IrregularVerbBe, WClasses::AuxiliaryBe].each do |wclass|
85
- lexm = subject.get_lexeme('be', wclass)
83
+ lexm = dictionary.get_lexeme('be', wclass)
86
84
  expectations1 = [
87
85
  [present_1sg, 'am'],
88
86
  [present_2sg, 'are'],
@@ -9,34 +9,34 @@ require_relative '../../../lib/zenlish/lang/lemmatizer'
9
9
  module Zenlish
10
10
  module Lang
11
11
  describe Lemmatizer do
12
- subject { Lemmatizer.new(Dictionary) }
12
+ subject { described_class.new(Dictionary) }
13
13
 
14
14
  context 'Initialization:' do
15
- it 'should be initialized with a lexicon argument' do
16
- expect { Lemmatizer.new(Dictionary) }.not_to raise_error
17
- end
15
+ # it 'is initialized with a lexicon argument' do
16
+ # expect { described_class.new(Dictionary) }.not_to raise_error
17
+ # end
18
18
  end # context
19
19
 
20
20
  context 'Provided services:' do
21
- it 'should retrieve an unambiguous word form' do
22
- # Coordinator
23
- found = subject.lemmatize('and')
24
- expect(found).to be_kind_of(Lex::Lexeme)
25
- expect(found.lemma).to eq('and')
26
- expect(found.wclass).to be_kind_of(WClasses::Coordinator)
27
-
28
- # Common noun
29
- found = subject.lemmatize('surfaces')
30
- expect(found).to be_kind_of(Lex::Lexeme)
31
- expect(found.lemma).to eq('surface')
32
- expect(found.wclass).to be_kind_of(WClasses::CommonNoun)
33
-
34
- # Verb
35
- found = subject.lemmatize('seeing')
36
- expect(found).to be_kind_of(Lex::Lexeme)
37
- expect(found.lemma).to eq('see')
38
- expect(found.wclass).to be_kind_of(WClasses::IrregularVerb)
39
- end
21
+ # it 'retrieves an unambiguous word form' do
22
+ # # Coordinator
23
+ # found = described_class.lemmatize('and')
24
+ # expect(found).to be_a(Lex::Lexeme)
25
+ # expect(found.lemma).to eq('and')
26
+ # expect(found.wclass).to be_a(WClasses::Coordinator)
27
+ #
28
+ # # Common noun
29
+ # found = described_class.lemmatize('surfaces')
30
+ # expect(found).to be_a(Lex::Lexeme)
31
+ # expect(found.lemma).to eq('surface')
32
+ # expect(found.wclass).to be_a(WClasses::CommonNoun)
33
+ #
34
+ # # Verb
35
+ # found = described_class.lemmatize('seeing')
36
+ # expect(found).to be_a(Lex::Lexeme)
37
+ # expect(found.lemma).to eq('see')
38
+ # expect(found.wclass).to be_a(WClasses::IrregularVerb)
39
+ # end
40
40
  end # context
41
41
  end # describe
42
42
  end # module
@@ -6,11 +6,11 @@ require_relative '../../../lib/zenlish/lang/zenlish_grammar' # Load the class un
6
6
  module Zenlish
7
7
  module Lang
8
8
  describe ZenlishGrammar do
9
- subject { ZenlishGrammar }
9
+ subject(:grammar) { described_class }
10
10
 
11
11
  context 'Initialization:' do
12
- it 'should know its terminal symbols' do
13
- expect { subject.name2symbol['CommonNoun'] }.not_to raise_error
12
+ it 'knows its terminal symbols' do
13
+ expect { grammar.name2symbol['CommonNoun'] }.not_to raise_error
14
14
  end
15
15
  end # context
16
16
 
@@ -8,24 +8,24 @@ require_relative '../../../lib/zenlish/lex/empty_lexicon_factory'
8
8
  module Zenlish
9
9
  module Lex
10
10
  describe EmptyLexiconFactory do
11
- subject do
11
+ subject(:factory) do
12
12
  obj = Object.new
13
- obj.extend(EmptyLexiconFactory)
13
+ obj.extend(described_class)
14
14
  end
15
15
 
16
16
  context 'Mix-in integration:' do
17
- it 'should acquire the methods of the mix-in module' do
18
- expect(subject.respond_to?(:create_empty_lexicon)).to be_truthy
17
+ it 'acquires the methods of the mix-in module' do
18
+ expect(factory).to respond_to(:create_empty_lexicon)
19
19
  end
20
20
  end # context
21
21
 
22
22
  context 'Created lexicon:' do
23
- it 'should allow the creation of empty lexicon' do
24
- expect(subject.create_empty_lexicon).to be_kind_of(Lexicon)
23
+ it 'allows the creation of empty lexicon' do
24
+ expect(factory.create_empty_lexicon).to be_a(Lexicon)
25
25
  end
26
26
 
27
- it 'should initialize lexicon with terminal symbols of the language' do
28
- lexicon = subject.create_empty_lexicon
27
+ it 'initializes lexicon with terminal symbols of the language' do
28
+ lexicon = factory.create_empty_lexicon
29
29
  found = lexicon.terminals.find { |symb| symb.kind_of?(WClasses::CommonNoun) }
30
30
  expect(found).to be_truthy
31
31
  end
@@ -19,43 +19,43 @@ module Zenlish
19
19
  'PARADIGM' => [identifier, 'Plural_only'] }
20
20
  end
21
21
 
22
- subject { Lexeme.new(a_wclass, an_entry) }
22
+ subject(:a_lexeme) { described_class.new(a_wclass, an_entry) }
23
23
 
24
24
  context 'Initialization:' do
25
- it 'could be initialized with a word class and a lexical entry' do
26
- expect { Lexeme.new(a_wclass, an_entry) }.not_to raise_error
25
+ it 'can be initialized with a word class and a lexical entry' do
26
+ expect { described_class.new(a_wclass, an_entry) }.not_to raise_error
27
27
  end
28
28
 
29
- it 'could be initialized with a w. class, lexical ent., feature hash' do
30
- expect { Lexeme.new(a_wclass, an_entry, a_feat_struct_def) }.not_to raise_error
29
+ it 'can be initialized with a w. class, lexical ent., feature hash' do
30
+ expect { described_class.new(a_wclass, an_entry, a_feat_struct_def) }.not_to raise_error
31
31
  end
32
32
 
33
- it 'should know its word class' do
34
- expect(subject.wclass).to eq(a_wclass)
33
+ it 'knows its word class' do
34
+ expect(a_lexeme.wclass).to eq(a_wclass)
35
35
  end
36
36
 
37
- it 'should know its lexical entry' do
38
- expect(subject.entry).to eq(an_entry)
37
+ it 'knows its lexical entry' do
38
+ expect(a_lexeme.entry).to eq(an_entry)
39
39
  end
40
40
  end # context
41
41
 
42
42
  context 'Provided services:' do
43
- subject { Lexeme.new(a_wclass, an_entry, a_feat_struct_def) }
44
- it 'should know its lemma' do
45
- expect(subject.lemma).to eq(a_lemma)
43
+ subject(:a_lexeme) { described_class.new(a_wclass, an_entry, a_feat_struct_def) }
44
+ it 'knows its lemma' do
45
+ expect(a_lexeme.lemma).to eq(a_lemma)
46
46
  end
47
47
 
48
- it 'should know its own feature defs' do
49
- instance = Lexeme.new(a_wclass, an_entry, a_feat_struct_def)
48
+ it 'knows its own feature defs' do
49
+ instance = described_class.new(a_wclass, an_entry, a_feat_struct_def)
50
50
  expect(instance['NUMBER'].default.val).to eq(:plural)
51
51
  end
52
52
 
53
- it 'should know its inflection paradigm' do
54
- expect(subject.paradigm).to be_kind_of(Inflect::InflectionTable)
53
+ it 'knows its inflection paradigm' do
54
+ expect(a_lexeme.paradigm).to be_a(Inflect::InflectionTable)
55
55
  end
56
56
 
57
- it 'should know all its inflections' do
58
- expect(subject.all_inflections).to eq(['people'])
57
+ it 'knows all its inflections' do
58
+ expect(a_lexeme.all_inflections).to eq(['people'])
59
59
  end
60
60
  end # context
61
61
  end # describe
@@ -9,35 +9,36 @@ module Zenlish
9
9
  let(:sample_lemma) { 'other' }
10
10
  let(:sample_lexeme1) { double('other-as-adjective') }
11
11
  let(:sample_lexeme2) { double('other-as-pronoun') }
12
- subject { LexicalEntry.new(sample_lemma) }
12
+
13
+ subject(:lex_entry) { described_class.new(sample_lemma) }
13
14
 
14
15
  context 'Initialization:' do
15
16
  it 'can be initialized with a lemma only' do
16
- expect { LexicalEntry.new(sample_lemma) }.not_to raise_error
17
+ expect { described_class.new(sample_lemma) }.not_to raise_error
17
18
  end
18
19
 
19
20
  it 'can be initialized with a lemma and a word class' do
20
- expect { LexicalEntry.new(sample_lemma, sample_lexeme1) }.not_to raise_error
21
+ expect { described_class.new(sample_lemma, sample_lexeme1) }.not_to raise_error
21
22
  end
22
23
 
23
- it 'should know its lemma' do
24
- expect(subject.lemma).to eq(sample_lemma)
24
+ it 'knows its lemma' do
25
+ expect(lex_entry.lemma).to eq(sample_lemma)
25
26
  end
26
27
 
27
- it 'should know its lexeme (if any)' do
28
- expect(subject.lexemes).to be_empty
29
- instance = LexicalEntry.new(sample_lemma, sample_lexeme1)
28
+ it 'knows its lexeme (if any)' do
29
+ expect(lex_entry.lexemes).to be_empty
30
+ instance = described_class.new(sample_lemma, sample_lexeme1)
30
31
  expect(instance.lexemes).to eq([sample_lexeme1])
31
32
  end
32
33
  end # context
33
34
 
34
35
  context 'Provided services:' do
35
- it 'should accept links with lexeme(s)' do
36
- subject.add_lexeme(sample_lexeme1)
37
- expect(subject.lexemes).to eq([sample_lexeme1])
36
+ it 'accepts links with lexeme(s)' do
37
+ lex_entry.add_lexeme(sample_lexeme1)
38
+ expect(lex_entry.lexemes).to eq([sample_lexeme1])
38
39
 
39
- subject.add_lexeme(sample_lexeme2)
40
- expect(subject.lexemes).to eq([sample_lexeme1, sample_lexeme2])
40
+ lex_entry.add_lexeme(sample_lexeme2)
41
+ expect(lex_entry.lexemes).to eq([sample_lexeme1, sample_lexeme2])
41
42
  end
42
43
  end # context
43
44
  end # describe
@@ -24,78 +24,79 @@ module Zenlish
24
24
  let(:sample_entry) { create_entry('other', adjective) }
25
25
  let(:similar_entry) { create_entry('other', pronoun) }
26
26
  let(:distinct_entry) { create_entry('hope', irregular_verb) }
27
- subject { Lexicon.new }
27
+
28
+ subject(:lexicon) { described_class.new }
28
29
 
29
30
  context 'Initialization:' do
30
- it 'should be initialized without parameter' do
31
- expect { Lexicon.new }.not_to raise_error
31
+ it 'is initialized without parameter' do
32
+ expect { described_class.new }.not_to raise_error
32
33
  end
33
34
 
34
- it 'should have no registered terminals at initialization' do
35
- expect(subject.terminals).to be_empty
35
+ it 'has no registered terminals at initialization' do
36
+ expect(lexicon.terminals).to be_empty
36
37
  end
37
38
 
38
- it 'should have no entry at initialization' do
39
- expect(subject.entries).to be_empty
40
- expect(subject.lemma2entry).to be_empty
39
+ it 'has no entry at initialization' do
40
+ expect(lexicon.entries).to be_empty
41
+ expect(lexicon.lemma2entry).to be_empty
41
42
  end
42
43
  end # context
43
44
 
44
45
  context 'Provided services:' do
45
- it 'should accept the addition of terminals' do
46
+ it 'accepts the addition of terminals' do
46
47
  terminal1 = pronoun
47
48
  terminal2 = irregular_verb
48
49
  terminal3 = adjective
49
50
 
50
- subject.add_terminal(terminal1)
51
- expect(subject.terminals).to eq([terminal1])
52
- subject.add_terminal(terminal2)
53
- expect(subject.terminals).to eq([terminal1, terminal2])
54
- subject.add_terminal(terminal3)
55
- expect(subject.terminals).to eq([terminal1, terminal2, terminal3])
56
- expect(subject.name2terminal['Pronoun']).to eq(terminal1)
57
- expect(subject.name2terminal['IrregularVerb']).to eq(terminal2)
58
- expect(subject.name2terminal['Adjective']).to eq(terminal3)
51
+ lexicon.add_terminal(terminal1)
52
+ expect(lexicon.terminals).to eq([terminal1])
53
+ lexicon.add_terminal(terminal2)
54
+ expect(lexicon.terminals).to eq([terminal1, terminal2])
55
+ lexicon.add_terminal(terminal3)
56
+ expect(lexicon.terminals).to eq([terminal1, terminal2, terminal3])
57
+ expect(lexicon.name2terminal['Pronoun']).to eq(terminal1)
58
+ expect(lexicon.name2terminal['IrregularVerb']).to eq(terminal2)
59
+ expect(lexicon.name2terminal['Adjective']).to eq(terminal3)
59
60
  end
60
61
 
61
- it 'should accept the addition of entries' do
62
- subject.add_entry(sample_entry)
63
- expect(subject.entries).to eq([sample_entry])
64
- expect(subject.lemma2entry['other']).to eq(sample_entry)
62
+ it 'accepts the addition of entries' do
63
+ lexicon.add_entry(sample_entry)
64
+ expect(lexicon.entries).to eq([sample_entry])
65
+ expect(lexicon.lemma2entry['other']).to eq(sample_entry)
65
66
 
66
67
  # Add dissimilar entry
67
- subject.add_entry(distinct_entry)
68
- expect(subject.entries).to eq([sample_entry, distinct_entry])
69
- expect(subject.lemma2entry['hope']).to eq(distinct_entry)
68
+ lexicon.add_entry(distinct_entry)
69
+ expect(lexicon.entries).to eq([sample_entry, distinct_entry])
70
+ expect(lexicon.lemma2entry['hope']).to eq(distinct_entry)
70
71
 
71
72
  # Add "homonym" entry
72
- subject.add_entry(similar_entry)
73
- expect(subject.entries).to eq([sample_entry, distinct_entry, similar_entry])
74
- expect(subject.lemma2entry['other']).to eq([sample_entry, similar_entry])
73
+ lexicon.add_entry(similar_entry)
74
+ expect(lexicon.entries).to eq([sample_entry, distinct_entry, similar_entry])
75
+ expect(lexicon.lemma2entry['other']).to eq([sample_entry, similar_entry])
75
76
  end
76
77
 
77
- it 'should retrieve the lexeme of an entry with unique lemma' do
78
- subject.add_entry(sample_entry)
79
- subject.add_entry(distinct_entry)
80
- subject.add_entry(similar_entry)
78
+ it 'retrieves the lexeme of an entry with unique lemma' do
79
+ lexicon.add_entry(sample_entry)
80
+ lexicon.add_entry(distinct_entry)
81
+ lexicon.add_entry(similar_entry)
81
82
 
82
- lexeme = subject.get_lexeme('hope')
83
- expect(lexeme.wclass).to be_kind_of(Zenlish::WClasses::IrregularVerb)
83
+ lexeme = lexicon.get_lexeme('hope')
84
+ expect(lexeme.wclass).to be_a(Zenlish::WClasses::IrregularVerb)
84
85
  end
85
86
 
86
- it 'should retrieve the lexeme of an entry with duplicate lemma' do
87
- subject.add_entry(sample_entry)
88
- subject.add_entry(distinct_entry)
89
- subject.add_entry(similar_entry)
87
+ it 'retrieves the lexeme of an entry with duplicate lemma' do
88
+ lexicon.add_entry(sample_entry)
89
+ lexicon.add_entry(distinct_entry)
90
+ lexicon.add_entry(similar_entry)
90
91
 
91
- lexeme = subject.get_lexeme('other', Zenlish::WClasses::Pronoun)
92
- expect(lexeme).to be_kind_of(Zenlish::Lex::Lexeme)
92
+ lexeme = lexicon.get_lexeme('other', Zenlish::WClasses::Pronoun)
93
+ expect(lexeme).to be_a(Zenlish::Lex::Lexeme)
93
94
  end
94
95
 
95
- it 'should complain when retrieving an non-existing entry' do
96
- subject.add_entry(sample_entry)
96
+ it 'complains when retrieving an non-existing entry' do
97
+ lexicon.add_entry(sample_entry)
97
98
  err_msg = 'key not found: "hapax"'
98
- expect { subject.get_lexeme('hapax') }.to raise_error(KeyError, err_msg)
99
+ expect { lexicon.get_lexeme('hapax') }.to raise_error(KeyError, err_msg)
99
100
  end
100
101
  end # context
101
102
  end # describe
@@ -12,20 +12,20 @@ module Zenlish
12
12
  let(:sample_wclass) { WClasses::CommonNoun.new }
13
13
  let(:sample_lemma) { 'thing' }
14
14
  let(:sample_entry) { LexicalEntry.new(sample_lemma) }
15
- let(:sample_position) { double('position') }
15
+ let(:sample_position) { instance_double(Rley::Lexical::Position) }
16
16
  let(:sample_lexeme) { Lexeme.new(sample_wclass, sample_entry) }
17
17
 
18
- subject { Literal.new('things', sample_lexeme, sample_position) }
18
+ subject(:literal) { described_class.new('things', sample_lexeme, sample_position) }
19
19
 
20
20
  context 'Initialization:' do
21
- it 'should be initialized with a string, a lexeme and a position' do
22
- expect { Literal.new('things', sample_lexeme, sample_position) }.not_to raise_error
21
+ it 'is initialized with a string, a lexeme and a position' do
22
+ expect { described_class.new('things', sample_lexeme, sample_position) }.not_to raise_error
23
23
  end
24
24
  end # context
25
25
 
26
26
  context 'Provided services:' do
27
- it 'should know its lexeme' do
28
- expect(subject.zlexeme).to eq(sample_lexeme)
27
+ it 'knows its lexeme' do
28
+ expect(literal.zlexeme).to eq(sample_lexeme)
29
29
  end
30
30
  end # context
31
31
  end # describe
@@ -18,26 +18,26 @@ module Zenlish
18
18
  # let(:sample_lexeme) { Lexeme.new(sample_wclass, sample_entry) }
19
19
  let(:sample_sentence) { 'Tony sees Lisa.' }
20
20
 
21
- subject { Lexer.new(sample_sentence) }
21
+ subject(:lexer) { described_class.new(sample_sentence) }
22
22
 
23
23
  context 'Initialization:' do
24
- it 'should be initialized with Zenlish text' do
25
- expect { Lexer.new(sample_sentence) }.not_to raise_error
24
+ it 'is initialized with Zenlish text' do
25
+ expect { described_class.new(sample_sentence) }.not_to raise_error
26
26
  end
27
27
 
28
- it 'should its scanner object' do
29
- expect(subject.scanner).not_to be_nil
28
+ it 'knows its scanner object' do
29
+ expect(lexer.scanner).not_to be_nil
30
30
  end
31
31
 
32
- it 'should have an initial position' do
33
- expect(subject.lineno).to eq(1)
34
- expect(subject.line_start).to eq(0)
32
+ it 'has an initial position' do
33
+ expect(lexer.lineno).to eq(1)
34
+ expect(lexer.line_start).to eq(0)
35
35
  end
36
36
  end # context
37
37
 
38
38
  context 'Provided services:' do
39
- it 'should return a sequence of literals' do
40
- tokens = subject.tokens
39
+ it 'returns a sequence of literals' do
40
+ tokens = lexer.tokens
41
41
  expect(tokens.size).to eq(4)
42
42
  expect(tokens[0].lexeme).to eq('Tony')
43
43
  expect(tokens[0].terminal).to eq('WORD')