linkparser 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +526 -0
- data/LICENSE +27 -0
- data/README +88 -0
- data/Rakefile +315 -0
- data/Rakefile.local +60 -0
- data/ext/dictionary.c +269 -0
- data/ext/extconf.rb +53 -0
- data/ext/linkage.c +894 -0
- data/ext/linkparser.c +120 -0
- data/ext/linkparser.h +112 -0
- data/ext/parseoptions.c +1188 -0
- data/ext/sentence.c +536 -0
- data/lib/linkparser.rb +38 -0
- data/lib/linkparser/linkage.rb +248 -0
- data/lib/linkparser/sentence.rb +106 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +395 -0
- data/rake/manual.rb +755 -0
- data/rake/packaging.rb +112 -0
- data/rake/publishing.rb +308 -0
- data/rake/rdoc.rb +47 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +602 -0
- data/rake/testing.rb +202 -0
- data/rake/verifytask.rb +64 -0
- data/spec/bugfixes_spec.rb +42 -0
- data/spec/linkparser/dictionary_spec.rb +90 -0
- data/spec/linkparser/linkage_spec.rb +434 -0
- data/spec/linkparser/parseoptions_spec.rb +78 -0
- data/spec/linkparser/sentence_spec.rb +117 -0
- data/spec/linkparser_spec.rb +30 -0
- metadata +219 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Specification for the LinkParser::ParseOptions class
|
4
|
+
# $Id: parseoptions_spec.rb 48 2008-12-19 18:30:33Z deveiant $
|
5
|
+
#
|
6
|
+
# See the LICENSE file in the distribution for information about copyright and licensing.
|
7
|
+
#
|
8
|
+
|
9
|
+
BEGIN {
|
10
|
+
require 'pathname'
|
11
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
12
|
+
|
13
|
+
libdir = basedir + 'lib'
|
14
|
+
extdir = basedir + 'ext'
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
17
|
+
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
|
18
|
+
}
|
19
|
+
|
20
|
+
require 'spec/runner'
|
21
|
+
require 'linkparser'
|
22
|
+
|
23
|
+
|
24
|
+
describe LinkParser::ParseOptions do
|
25
|
+
|
26
|
+
before( :each ) do
|
27
|
+
@opts = LinkParser::ParseOptions.new
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
it "starts out with documented defaults" do
|
32
|
+
@opts.verbosity.should == 1 # Docs say this is 0
|
33
|
+
@opts.linkage_limit.should == 100 # Docs say this is 10000
|
34
|
+
@opts.min_null_count.should == 0
|
35
|
+
@opts.max_null_count.should == 0
|
36
|
+
@opts.null_block.should == 1
|
37
|
+
@opts.islands_ok?.should == false
|
38
|
+
@opts.short_length.should == 6
|
39
|
+
@opts.display_walls?.should == false
|
40
|
+
@opts.display_union?.should == false
|
41
|
+
@opts.allow_null?.should == true
|
42
|
+
@opts.echo_on?.should == false
|
43
|
+
@opts.batch_mode?.should == false
|
44
|
+
@opts.panic_mode?.should == false
|
45
|
+
@opts.screen_width.should == 79
|
46
|
+
@opts.display_on?.should == true
|
47
|
+
@opts.display_postscript? == false
|
48
|
+
@opts.display_bad?.should == false
|
49
|
+
@opts.display_links?.should == false
|
50
|
+
@opts.all_short_connectors?.should == false
|
51
|
+
end
|
52
|
+
|
53
|
+
it "supports all the members mentioned in the documentation" do
|
54
|
+
pending "some of them aren't implemented in the link-grammar library"
|
55
|
+
@opts.display_short?.should == true # Not in the API
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
it "knows whether the timer constraints were exceeded or not" do
|
60
|
+
@opts.timer_expired?.should == false
|
61
|
+
end
|
62
|
+
|
63
|
+
it "knows whether the memory constraints were exceeded or not" do
|
64
|
+
@opts.memory_exhausted?.should == false
|
65
|
+
end
|
66
|
+
|
67
|
+
it "knows whether the timer constraints were exceeded or not" do
|
68
|
+
@opts.resources_exhausted?.should == false
|
69
|
+
end
|
70
|
+
|
71
|
+
it "can reset the resource constraints" do
|
72
|
+
lambda {
|
73
|
+
@opts.reset_resources
|
74
|
+
}.should_not raise_error()
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Specification for the LinkParser::Sentence class
|
4
|
+
# $Id: sentence_spec.rb 48 2008-12-19 18:30:33Z deveiant $
|
5
|
+
#
|
6
|
+
# See the LICENSE file in the distribution for information about copyright and licensing.
|
7
|
+
#
|
8
|
+
|
9
|
+
BEGIN {
|
10
|
+
require 'pathname'
|
11
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
12
|
+
|
13
|
+
libdir = basedir + 'lib'
|
14
|
+
extdir = basedir + 'ext'
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
17
|
+
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
|
18
|
+
}
|
19
|
+
|
20
|
+
require 'spec/runner'
|
21
|
+
require 'linkparser'
|
22
|
+
|
23
|
+
|
24
|
+
describe LinkParser::Sentence do
|
25
|
+
|
26
|
+
|
27
|
+
before( :all ) do
|
28
|
+
@dict = LinkParser::Dictionary.new( :verbosity => 0 )
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
before( :each ) do
|
33
|
+
@sentence = LinkParser::Sentence.new( "The cat runs.", @dict )
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
it "returns an informational string when inspected" do
|
38
|
+
@sentence.inspect.should =~ %r{
|
39
|
+
<
|
40
|
+
LinkParser::Sentence:0x[[:xdigit:]]+
|
41
|
+
\s
|
42
|
+
(?-x:"LEFT-WALL the cat runs . RIGHT-WALL")
|
43
|
+
/\d+\slinkages
|
44
|
+
/\d+\snulls
|
45
|
+
>
|
46
|
+
}x
|
47
|
+
end
|
48
|
+
|
49
|
+
it "can return itself as a tokenized string" do
|
50
|
+
@sentence.to_s.should == "LEFT-WALL the cat runs . RIGHT-WALL"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
it "returns the linkage count as the result of parsing the sentence" do
|
55
|
+
@sentence.parse.should == 1
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
it "accepts parse options when parsing" do
|
60
|
+
@sentence.parse( :verbosity => 0 )
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
it "knows how many words are in it, including walls and punctuation" do
|
65
|
+
@sentence.length == 6
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
it "delegates linkage methods to its first linkage" do
|
70
|
+
@sentence.num_links.should == 5
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
it "knows whether or not it's been parsed" do
|
75
|
+
@sentence.parsed?.should be_false()
|
76
|
+
@sentence.parse
|
77
|
+
@sentence.parsed?.should be_true()
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
it "can return its linkages" do
|
82
|
+
@sentence.should have(1).linkages
|
83
|
+
@sentence.linkages.first.should be_an_instance_of( LinkParser::Linkage )
|
84
|
+
end
|
85
|
+
|
86
|
+
it "can return words at a specified position" do
|
87
|
+
@sentence.word( 0 ).should == 'LEFT-WALL'
|
88
|
+
@sentence[ -1 ].should == 'RIGHT-WALL'
|
89
|
+
end
|
90
|
+
|
91
|
+
it "can return an Array of all tokenized words" do
|
92
|
+
@sentence.words.should == [
|
93
|
+
'LEFT-WALL', 'the', 'cat', 'runs', '.', 'RIGHT-WALL'
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
it "knows that it doesn't have any superfluous words in it" do
|
99
|
+
@sentence.null_count == 0
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
describe "parsed from a sentence with a superfluous word in it" do
|
105
|
+
|
106
|
+
before( :each ) do
|
107
|
+
@sentence = @dict.parse( "This sentence contains a gravel superfluous word.")
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
it "knows how many null links it has" do
|
112
|
+
@sentence.null_count == 1
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Specification for the LinkParser library
|
4
|
+
# $Id: linkparser_spec.rb 48 2008-12-19 18:30:33Z deveiant $
|
5
|
+
#
|
6
|
+
# See the LICENSE file in the distribution for information about copyright and licensing.
|
7
|
+
#
|
8
|
+
|
9
|
+
BEGIN {
|
10
|
+
require 'pathname'
|
11
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent
|
12
|
+
|
13
|
+
libdir = basedir + 'lib'
|
14
|
+
extdir = basedir + 'ext'
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
17
|
+
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
|
18
|
+
}
|
19
|
+
|
20
|
+
require 'spec/runner'
|
21
|
+
require 'linkparser'
|
22
|
+
|
23
|
+
|
24
|
+
describe LinkParser do
|
25
|
+
|
26
|
+
it "knows what version of the link-grammar library it was built against" do
|
27
|
+
LinkParser.link_grammar_version.should =~ /link-grammar-\d+\.\d+\.\d+/i
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: linkparser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Granger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-20 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: text-format
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: termios
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rubyforge
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.8.1
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: libxml-ruby
|
67
|
+
type: :development
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.8.3
|
74
|
+
version:
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: ultraviolet
|
77
|
+
type: :development
|
78
|
+
version_requirement:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.10.2
|
84
|
+
version:
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: tmail
|
87
|
+
type: :development
|
88
|
+
version_requirement:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.2.3.1
|
94
|
+
version:
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: amatch
|
97
|
+
type: :development
|
98
|
+
version_requirement:
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.2.3
|
104
|
+
version:
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rcov
|
107
|
+
type: :development
|
108
|
+
version_requirement:
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: "0"
|
114
|
+
version:
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: RedCloth
|
117
|
+
type: :development
|
118
|
+
version_requirement:
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 4.0.3
|
124
|
+
version:
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rcodetools
|
127
|
+
type: :development
|
128
|
+
version_requirement:
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.7.0.0
|
134
|
+
version:
|
135
|
+
description: A Ruby binding for the link-grammar library, a syntactic parser of English. See http://www.link.cs.cmu.edu/link/ for more information about the Link Grammar, and http://www.abisource.org/projects/link-grammar/ for information about the link-grammar library.
|
136
|
+
email: ged@FaerieMUD.org
|
137
|
+
executables: []
|
138
|
+
|
139
|
+
extensions:
|
140
|
+
- ext/extconf.rb
|
141
|
+
extra_rdoc_files:
|
142
|
+
- ChangeLog
|
143
|
+
- README
|
144
|
+
- LICENSE
|
145
|
+
files:
|
146
|
+
- Rakefile
|
147
|
+
- ChangeLog
|
148
|
+
- README
|
149
|
+
- LICENSE
|
150
|
+
- spec/bugfixes_spec.rb
|
151
|
+
- spec/linkparser/dictionary_spec.rb
|
152
|
+
- spec/linkparser/linkage_spec.rb
|
153
|
+
- spec/linkparser/parseoptions_spec.rb
|
154
|
+
- spec/linkparser/sentence_spec.rb
|
155
|
+
- spec/linkparser_spec.rb
|
156
|
+
- lib/linkparser/linkage.rb
|
157
|
+
- lib/linkparser/sentence.rb
|
158
|
+
- lib/linkparser.rb
|
159
|
+
- ext/dictionary.c
|
160
|
+
- ext/linkage.c
|
161
|
+
- ext/linkparser.c
|
162
|
+
- ext/parseoptions.c
|
163
|
+
- ext/sentence.c
|
164
|
+
- ext/linkparser.h
|
165
|
+
- ext/extconf.rb
|
166
|
+
- rake/dependencies.rb
|
167
|
+
- rake/helpers.rb
|
168
|
+
- rake/manual.rb
|
169
|
+
- rake/packaging.rb
|
170
|
+
- rake/publishing.rb
|
171
|
+
- rake/rdoc.rb
|
172
|
+
- rake/style.rb
|
173
|
+
- rake/svn.rb
|
174
|
+
- rake/testing.rb
|
175
|
+
- rake/verifytask.rb
|
176
|
+
- Rakefile.local
|
177
|
+
has_rdoc: true
|
178
|
+
homepage: http://deveiate.org/projects/Ruby-LinkParser/
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options:
|
181
|
+
- -w
|
182
|
+
- "4"
|
183
|
+
- -SHN
|
184
|
+
- -i
|
185
|
+
- .
|
186
|
+
- -m
|
187
|
+
- README
|
188
|
+
- -t
|
189
|
+
- linkparser
|
190
|
+
- -W
|
191
|
+
- http://deveiate.org/projects/Ruby-LinkParser/browser/trunk/
|
192
|
+
require_paths:
|
193
|
+
- lib
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: "0"
|
199
|
+
version:
|
200
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: "0"
|
205
|
+
version:
|
206
|
+
requirements:
|
207
|
+
- link-grammar >= 4.4.1
|
208
|
+
rubyforge_project: linkparser
|
209
|
+
rubygems_version: 1.3.1
|
210
|
+
signing_key:
|
211
|
+
specification_version: 2
|
212
|
+
summary: a Ruby binding for the link-grammar library
|
213
|
+
test_files:
|
214
|
+
- spec/bugfixes_spec.rb
|
215
|
+
- spec/linkparser/dictionary_spec.rb
|
216
|
+
- spec/linkparser/linkage_spec.rb
|
217
|
+
- spec/linkparser/parseoptions_spec.rb
|
218
|
+
- spec/linkparser/sentence_spec.rb
|
219
|
+
- spec/linkparser_spec.rb
|