bracket_notation 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README.rdoc +40 -0
- data/bracket_notation.gemspec +2 -2
- data/lib/bracket_notation/expressions/expression.rb +2 -1
- data/lib/bracket_notation/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= Version History
|
2
2
|
|
3
|
+
== 1.0.5 / 2011-03-09:
|
4
|
+
|
5
|
+
* Removed an extraneous space from the #pretty_print output that has always
|
6
|
+
bugged me. *So* worth a new release
|
7
|
+
* Added information and a usage example to the README
|
8
|
+
|
3
9
|
== 1.0.4 / 2011-01-09:
|
4
10
|
|
5
11
|
* Added a validation class method to the Parser class to help with error
|
data/README.rdoc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
= BracketNotation
|
2
|
+
|
1
3
|
BracketNotation is a parser for generating syntax trees from sentences
|
2
4
|
annotated with the kind of bracket notation that is commonly used by
|
3
5
|
linguists. The result is a tree structure with nodes that describe the phrases
|
@@ -9,3 +11,41 @@ and small portions of his code have been incorporated in the parser.
|
|
9
11
|
Author:: Cody Brimhall (mailto:brimhall@somuchwit.com)
|
10
12
|
Copyright:: Copyright (c) 2010 Cody Brimhall
|
11
13
|
License:: Distributed under the terms of the GNU General Public License, v. 3
|
14
|
+
|
15
|
+
== Using BracketNotation
|
16
|
+
|
17
|
+
To use BracketNotation, simply initialize a Parser instance with the string you
|
18
|
+
want to parse, and call the #parse method. Parser performs some basic validation
|
19
|
+
before attempting to evaluate the string. If validation fails, Parser raises a
|
20
|
+
ValidationError. If the evaluator encounters a syntax error in the string, it
|
21
|
+
raises an EvaluationError.
|
22
|
+
|
23
|
+
require 'bracket_notation'
|
24
|
+
include BracketNotation
|
25
|
+
|
26
|
+
input = "[S [NP colorless green ideas] [VP [V sleep] [Adv furiously]]]"
|
27
|
+
|
28
|
+
begin
|
29
|
+
parser = Parser.new(input)
|
30
|
+
tree = parser.parse
|
31
|
+
|
32
|
+
puts tree.pretty_print # => S
|
33
|
+
# -- NP
|
34
|
+
# ---- colorless
|
35
|
+
# ---- green
|
36
|
+
# ---- ideas
|
37
|
+
# -- VP
|
38
|
+
# ---- V
|
39
|
+
# ------ sleep
|
40
|
+
# ---- Adv
|
41
|
+
# ------ furiously
|
42
|
+
rescue ValidationError
|
43
|
+
puts "Validation failed: #{$!}"
|
44
|
+
rescue EvaluationError
|
45
|
+
puts "Evaluation failed: #{$!}"
|
46
|
+
end
|
47
|
+
|
48
|
+
== Bugs, Feature Requests, Et Cetera
|
49
|
+
|
50
|
+
If you have any bugs, feature requests, or glowing praise, you can
|
51
|
+
find this project on GitHub[http://github.com/zbrimhall/bracket_notation].
|
data/bracket_notation.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{bracket_notation}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Cody Brimhall"]
|
9
|
-
s.date = %q{2011-03-
|
9
|
+
s.date = %q{2011-03-09}
|
10
10
|
s.description = %q{Generates a representation of a syntax tree using a string of bracket notation.}
|
11
11
|
s.email = %q{zbrimhall@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "COPYING", "README.rdoc", "lib/bracket_notation.rb", "lib/bracket_notation/evaluator.rb", "lib/bracket_notation/expressions.rb", "lib/bracket_notation/expressions/expression.rb", "lib/bracket_notation/expressions/identifier.rb", "lib/bracket_notation/expressions/terminal.rb", "lib/bracket_notation/parser.rb", "lib/bracket_notation/scanner.rb", "lib/bracket_notation/token.rb", "lib/bracket_notation/version.rb"]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bracket_notation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Cody Brimhall
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-09 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|