gullah 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73c8674a510b84d261ae0575c6d9b65109aea210b1b3bc0832a018ef572ee6b5
4
- data.tar.gz: e5497a3d4e967fd3547496caf23728d03ce0f2f485bc97c53332713331027b9e
3
+ metadata.gz: cdb5fc63d2f73407d20cfc3fdb709f27e800a1b4c4b572243e46af970d2563c6
4
+ data.tar.gz: 4803e11f42479445bc125013777e797fe526f949e1d9620bea34a974f83fd3dc
5
5
  SHA512:
6
- metadata.gz: b51e5eb27bec2a7d1554f332c5c71e26280ad76a704e07f7146e60cb60b59ef106c6e61bef1cb5c877889487cb51033a968a6d62575e429468486dbfb939c921
7
- data.tar.gz: 0fdc0bc2d67ac9833f92ae9a6535e092ede3e5c95fde414604d685a0e0835f016fae11db1578dee251bf7947b0f861e6c428b81b2ae25a45b349bea50a808ebc
6
+ metadata.gz: 03ad7649f31e61e78cb7220809a13e68ce6e8bdc88c497b251c36c9c5a885688bb1fd075b8d0e31e8724ee4d697446ace38cce36381a9ef1f1a2ac5c5642d334
7
+ data.tar.gz: 0d86b4e95ef0f6390cac7a47bafc45ed45e68d3bedc0524b95dd82fc2140281da3db3a380a71814f0862ca94e3b05f21634f3975a2b38eb42719254debbd03e3
data/CHANGES.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.2 *2021-8-29*
4
+ * still more improvements to documentation
5
+
3
6
  ## 0.0.1 *2021-8-29*
4
7
  * improvements to documentation
5
8
 
data/README.md CHANGED
@@ -20,11 +20,11 @@ A simple, fault-tolerant bottom-up parser written in Ruby.
20
20
  rule :N, 'nouns'
21
21
  rule :A, 'adjectives'
22
22
 
23
- leaf :determiners, /\b(the|a)\b/i
23
+ leaf :determiners, /\b(the|an?)\b/i
24
24
  leaf :nouns, /\b(cat|mat)\b/i
25
25
  leaf :prepositions, /\b(on|in|around|above|beside)\b/i
26
26
  leaf :verbs, /\b(sat|slept|moped)\b/
27
- leaf :adjectives, /\b(big|small|hairy|bald)\b/i
27
+ leaf :adjectives, /\b(big|small|hairy|bald|fat)\b/i
28
28
 
29
29
  ignore :whatever, /[^\w\s]+/
30
30
  end
@@ -33,8 +33,8 @@ A simple, fault-tolerant bottom-up parser written in Ruby.
33
33
  parses = Cat.parse 'The fat cat sat on the mat.'
34
34
  assert_equal 1, parses.length, 'there is only one parse of this sentence'
35
35
  parse = parses.first
36
- assert_equal 1, parse.nodes.reject(&:ignorable?).count, 'there is a root node for this parse'
37
- root = parse.nodes.first
36
+ assert_equal 1, parse.roots.reject(&:ignorable?).length, 'there is a root node for this parse'
37
+ root = parse.roots.reject(&:ignorable?).first
38
38
  assert_equal :S, root.name, 'the root node is a sentence'
39
39
  verb = root.descendants.find { |d| d.name == :VP }&.descendants&.find { |d| d.name == :V }
40
40
  assert_equal 'sat', verb&.text, 'we have the expected verb'
data/lib/gullah/node.rb CHANGED
@@ -7,6 +7,7 @@ module Gullah
7
7
  # The parent node of this node, if any.
8
8
  attr_reader :parent
9
9
 
10
+ # @private
10
11
  attr_reader :rule # :nodoc:
11
12
 
12
13
  ##
@@ -26,6 +27,7 @@ module Gullah
26
27
  # An alternative method for when a more telegraphic coding style is useful.
27
28
  alias atts attributes
28
29
 
30
+ # @private
29
31
  def initialize(parse, s, e, rule) # :nodoc:
30
32
  @rule = rule
31
33
  @leaf = rule.is_a?(Leaf) || trash?
@@ -100,6 +102,7 @@ module Gullah
100
102
  end
101
103
 
102
104
  # is this node some sort of boundary to further matching
105
+ # @private
103
106
  def traversible? # :nodoc:
104
107
  !(boundary? || trash? || error?)
105
108
  end
@@ -337,6 +340,7 @@ module Gullah
337
340
  root.descendants.select { |n| n.start >= self.end }
338
341
  end
339
342
 
343
+ # @private
340
344
  def clone # :nodoc:
341
345
  super.tap do |c|
342
346
  c._attributes = deep_clone(attributes)
@@ -416,13 +420,16 @@ module Gullah
416
420
  ## ADVISORILY PRIVATE
417
421
 
418
422
  # :stopdoc:
423
+ # @!visibility private
419
424
 
425
+ # @private
420
426
  def _summary=(str) # :nodoc:
421
427
  @summary = str
422
428
  end
423
429
 
424
430
  # used during parsing
425
431
  # make sure we don't have any repeated symbols in a unary branch
432
+ # @private
426
433
  def _loop_check?(seen = nil) # :nodoc:
427
434
  return true if seen == name
428
435
 
@@ -437,26 +444,32 @@ module Gullah
437
444
  @leaf ? false : children.first._loop_check?(seen)
438
445
  end
439
446
 
447
+ # @private
440
448
  def _attributes=(attributes) # :nodoc:
441
449
  @attributes = attributes
442
450
  end
443
451
 
452
+ # @private
444
453
  def _parent=(other) # :nodoc:
445
454
  @parent = other
446
455
  end
447
456
 
457
+ # @private
448
458
  def _children=(children) # :nodoc:
449
459
  @children = children
450
460
  end
451
461
 
462
+ # @private
452
463
  def _descendants(skip) # :nodoc:
453
464
  Descendants.new(self, skip)
454
465
  end
455
466
 
467
+ # @private
456
468
  def _ancestors(skip) # :nodoc:
457
469
  Ancestors.new(self, skip)
458
470
  end
459
471
 
472
+ # @private
460
473
  def _failed_test=(bool) # :nodoc:
461
474
  @failed_test = bool
462
475
  end
@@ -3,5 +3,5 @@
3
3
  module Gullah
4
4
  # This is an alpha release. Gullah has not yet been used in anything
5
5
  # other than unit tests.
6
- VERSION = '0.0.1'
6
+ VERSION = '0.0.2'
7
7
  end
@@ -30,4 +30,39 @@ class ParseDemoTest < Minitest::Test
30
30
  assert_equal 8, parse.size
31
31
  assert_equal 'S[NP[D,_ws,N],_ws,VP[V]]', parse.summary
32
32
  end
33
+
34
+ class Cat
35
+ extend Gullah
36
+
37
+ rule :S, 'NP VP'
38
+ rule :NP, 'D NB'
39
+ rule :NB, 'A* N'
40
+ rule :VP, 'VP PP'
41
+ rule :VP, 'V'
42
+ rule :PP, 'P NP'
43
+ rule :P, 'prepositions'
44
+ rule :V, 'verbs'
45
+ rule :D, 'determiners'
46
+ rule :N, 'nouns'
47
+ rule :A, 'adjectives'
48
+
49
+ leaf :determiners, /\b(the|an?)\b/i
50
+ leaf :nouns, /\b(cat|mat)\b/i
51
+ leaf :prepositions, /\b(on|in|around|above|beside)\b/i
52
+ leaf :verbs, /\b(sat|slept|moped)\b/
53
+ leaf :adjectives, /\b(big|small|hairy|bald|fat)\b/i
54
+
55
+ ignore :whatever, /[^\w\s]+/
56
+ end
57
+
58
+ def test_cat
59
+ parses = Cat.parse 'The fat cat sat on the mat.'
60
+ assert_equal 1, parses.length, 'there is only one parse of this sentence'
61
+ parse = parses.first
62
+ assert_equal 1, parse.roots.reject(&:ignorable?).length, 'there is a root node for this parse'
63
+ root = parse.roots.reject(&:ignorable?).first
64
+ assert_equal :S, root.name, 'the root node is a sentence'
65
+ verb = root.descendants.find { |d| d.name == :VP }&.descendants&.find { |d| d.name == :V }
66
+ assert_equal 'sat', verb&.text, 'we have the expected verb'
67
+ end
33
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gullah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David F. Houghton