linkparser 1.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.md +68 -3
- data/README.md +66 -47
- data/ext/{dictionary.c → linkparser_ext/dictionary.c} +61 -66
- data/ext/{extconf.rb → linkparser_ext/extconf.rb} +10 -3
- data/ext/{linkage.c → linkparser_ext/linkage.c} +121 -358
- data/ext/{linkparser.c → linkparser_ext/linkparser.c} +79 -28
- data/ext/{linkparser.h → linkparser_ext/linkparser.h} +14 -16
- data/ext/linkparser_ext/parseoptions.c +776 -0
- data/ext/{sentence.c → linkparser_ext/sentence.c} +65 -151
- data/lib/linkparser.rb +14 -6
- data/lib/linkparser/dictionary.rb +13 -0
- data/lib/linkparser/linkage.rb +271 -166
- data/lib/linkparser/mixins.rb +2 -3
- data/lib/linkparser/parseoptions.rb +58 -0
- data/lib/linkparser/sentence.rb +21 -38
- data/spec/bugfixes_spec.rb +23 -36
- data/spec/helpers.rb +39 -0
- data/spec/linkparser/dictionary_spec.rb +29 -48
- data/spec/linkparser/linkage_spec.rb +212 -276
- data/spec/linkparser/mixins_spec.rb +9 -24
- data/spec/linkparser/parseoptions_spec.rb +47 -59
- data/spec/linkparser/sentence_spec.rb +36 -56
- data/spec/linkparser_spec.rb +11 -25
- metadata +134 -174
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
- data/ChangeLog +0 -670
- data/LICENSE +0 -27
- data/Rakefile +0 -91
- data/ext/parseoptions.c +0 -1236
data/LICENSE
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
Copyright (c) 2006-2011, The FaerieMUD Consortium
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
6
|
-
|
7
|
-
* Redistributions of source code must retain the above copyright notice,
|
8
|
-
this list of conditions and the following disclaimer.
|
9
|
-
|
10
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
this list of conditions and the following disclaimer in the documentation
|
12
|
-
and/or other materials provided with the distribution.
|
13
|
-
|
14
|
-
* Neither the name of the author/s, nor the names of the project's
|
15
|
-
contributors may be used to endorse or promote products derived from this
|
16
|
-
software without specific prior written permission.
|
17
|
-
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
22
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
|
3
|
-
require 'rbconfig'
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'hoe'
|
8
|
-
rescue LoadError => err
|
9
|
-
abort "This Rakefile requires 'hoe' (gem install hoe)."
|
10
|
-
end
|
11
|
-
|
12
|
-
begin
|
13
|
-
require 'rake/extensiontask'
|
14
|
-
rescue LoadError => err
|
15
|
-
abort "This Rakefile requires 'rake-compiler' (gem install rake-compiler)"
|
16
|
-
end
|
17
|
-
|
18
|
-
# Build constants
|
19
|
-
BASEDIR = Pathname( __FILE__ ).dirname.relative_path_from( Pathname.pwd )
|
20
|
-
SPECDIR = BASEDIR + 'spec'
|
21
|
-
EXTDIR = BASEDIR + 'ext'
|
22
|
-
LIBDIR = BASEDIR + 'lib'
|
23
|
-
|
24
|
-
DLEXT = Config::CONFIG['DLEXT']
|
25
|
-
|
26
|
-
EXTCONF = EXTDIR + 'extconf.rb'
|
27
|
-
EXT = LIBDIR + "linkparser_ext.#{DLEXT}"
|
28
|
-
|
29
|
-
# Hoe plugins
|
30
|
-
Hoe.plugin :mercurial
|
31
|
-
Hoe.plugin :signing
|
32
|
-
|
33
|
-
Hoe.plugins.delete :rubyforge
|
34
|
-
|
35
|
-
# Main gem configuration
|
36
|
-
hoespec = Hoe.spec 'linkparser' do
|
37
|
-
self.readme_file = 'README.md'
|
38
|
-
self.history_file = 'History.md'
|
39
|
-
|
40
|
-
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
41
|
-
self.developer 'Martin Chase', 'stillflame@FaerieMUD.org'
|
42
|
-
|
43
|
-
self.dependency 'rake-compiler', '~> 0.7'
|
44
|
-
self.dependency 'rspec', '~> 2.4', :development
|
45
|
-
self.dependency 'hoe-deveiate', '~> 0.0.6', :development
|
46
|
-
|
47
|
-
self.spec_extras[:licenses] = ["BSD"]
|
48
|
-
self.spec_extras[:extensions] = [ EXTCONF.to_s ]
|
49
|
-
|
50
|
-
self.require_ruby_version( '>=1.8.7' )
|
51
|
-
|
52
|
-
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
53
|
-
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
54
|
-
end
|
55
|
-
|
56
|
-
ENV['VERSION'] ||= hoespec.spec.version.to_s
|
57
|
-
|
58
|
-
# Running the tests depends on compilation
|
59
|
-
# Need to (re)compile before running specs
|
60
|
-
task :spec => :compile
|
61
|
-
|
62
|
-
# gem-testers support
|
63
|
-
task :test do
|
64
|
-
# rake-compiler always wants to copy the compiled extension into lib/, but
|
65
|
-
# we don't want testers to have to re-compile, especially since that
|
66
|
-
# often fails because they can't (and shouldn't have to) write to tmp/ in
|
67
|
-
# the installed gem dir. So we clear the task rake-compiler set up
|
68
|
-
# to break the dependency between :spec and :compile when running under
|
69
|
-
# rubygems-test, and then run :spec.
|
70
|
-
Rake::Task[ EXT.to_s ].clear
|
71
|
-
Rake::Task[ :spec ].execute
|
72
|
-
end
|
73
|
-
|
74
|
-
desc "Turn on warnings and debugging in the build."
|
75
|
-
task :maint do
|
76
|
-
ENV['MAINTAINER_MODE'] = 'yes'
|
77
|
-
end
|
78
|
-
|
79
|
-
ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2'
|
80
|
-
|
81
|
-
# Rake-compiler task
|
82
|
-
Rake::ExtensionTask.new do |ext|
|
83
|
-
ext.gem_spec = hoespec.spec
|
84
|
-
ext.name = 'linkparser_ext'
|
85
|
-
ext.ext_dir = 'ext'
|
86
|
-
ext.lib_dir = 'lib'
|
87
|
-
ext.source_pattern = "*.{c,h}"
|
88
|
-
ext.cross_compile = true
|
89
|
-
ext.cross_platform = %w[i386-mswin32 i386-mingw32]
|
90
|
-
end
|
91
|
-
|
data/ext/parseoptions.c
DELETED
@@ -1,1236 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* parseoptions.c - Ruby LinkParser::ParseOptions class
|
3
|
-
* $Id: parseoptions.c,v 21df914cedb1 2010/10/12 15:45:26 ged $
|
4
|
-
*
|
5
|
-
* Authors:
|
6
|
-
* * Michael Granger <ged@FaerieMUD.org>
|
7
|
-
*
|
8
|
-
* Please see the LICENSE file at the top of the distribution for licensing
|
9
|
-
* information.
|
10
|
-
*/
|
11
|
-
|
12
|
-
#include "linkparser.h"
|
13
|
-
|
14
|
-
|
15
|
-
/* --------------------------------------------------
|
16
|
-
* Forward declarations
|
17
|
-
* -------------------------------------------------- */
|
18
|
-
|
19
|
-
static VALUE rlink_parseopts_each_opthash_i _(( VALUE, VALUE ));
|
20
|
-
|
21
|
-
|
22
|
-
/* --------------------------------------------------
|
23
|
-
* Macros and constants
|
24
|
-
* -------------------------------------------------- */
|
25
|
-
|
26
|
-
|
27
|
-
/* --------------------------------------------------
|
28
|
-
* Memory-management functions
|
29
|
-
* -------------------------------------------------- */
|
30
|
-
|
31
|
-
/*
|
32
|
-
* Free function
|
33
|
-
*/
|
34
|
-
static void
|
35
|
-
rlink_parseopts_gc_free( Parse_Options parseopts ) {
|
36
|
-
if ( parseopts ) parse_options_delete( parseopts );
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
/*
|
41
|
-
* Object validity checker. Returns the data pointer.
|
42
|
-
*/
|
43
|
-
static Parse_Options
|
44
|
-
check_parseopts( VALUE self ) {
|
45
|
-
Check_Type( self, T_DATA );
|
46
|
-
|
47
|
-
if ( !IsParseOptions(self) ) {
|
48
|
-
rb_raise( rb_eTypeError, "wrong argument type %s (expected LinkParser::ParseOptions)",
|
49
|
-
rb_class2name(CLASS_OF( self )) );
|
50
|
-
}
|
51
|
-
|
52
|
-
return DATA_PTR( self );
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
/*
|
57
|
-
* Fetch the data pointer and check it for sanity.
|
58
|
-
*/
|
59
|
-
static Parse_Options
|
60
|
-
get_parseopts( VALUE self ) {
|
61
|
-
Parse_Options parseopts = check_parseopts( self );
|
62
|
-
|
63
|
-
if ( !parseopts )
|
64
|
-
rb_raise( rb_eRuntimeError, "uninitialized ParseOptions" );
|
65
|
-
|
66
|
-
return parseopts;
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
/*
|
71
|
-
* Get the Parse_Options struct behind the LinkParser::ParseOptions +object+
|
72
|
-
* specified.
|
73
|
-
*/
|
74
|
-
Parse_Options
|
75
|
-
rlink_get_parseopts( VALUE obj ) {
|
76
|
-
return get_parseopts( obj );
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
/* --------------------------------------------------
|
81
|
-
* Class Methods
|
82
|
-
* -------------------------------------------------- */
|
83
|
-
|
84
|
-
/*
|
85
|
-
* call-seq:
|
86
|
-
* LinkParser::ParseOptions.allocate -> obj
|
87
|
-
*
|
88
|
-
* Allocate a new LinkParser::ParseOptions object.
|
89
|
-
*/
|
90
|
-
static VALUE
|
91
|
-
rlink_parseopts_s_alloc( VALUE klass ) {
|
92
|
-
debugMsg(( "Wrapping an uninitialized ParseOptions pointer." ));
|
93
|
-
return Data_Wrap_Struct( klass, 0, rlink_parseopts_gc_free, 0 );
|
94
|
-
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
/* ---------------------------------------------------
|
99
|
-
* Instance Methods
|
100
|
-
* --------------------------------------------------- */
|
101
|
-
|
102
|
-
|
103
|
-
/*
|
104
|
-
* call-seq:
|
105
|
-
* LinkParser::ParseOptions.new( opthash ) -> obj
|
106
|
-
*
|
107
|
-
* Create a new ParseOptions object and set values from opthash.
|
108
|
-
*
|
109
|
-
* po = LinkParser::ParseOptions.new( :allow_null => true, :batch_mode => true )
|
110
|
-
*
|
111
|
-
*/
|
112
|
-
static VALUE
|
113
|
-
rlink_parseopts_init( int argc, VALUE *argv, VALUE self ) {
|
114
|
-
if ( ! check_parseopts(self) ) {
|
115
|
-
Parse_Options opts;
|
116
|
-
VALUE opthash = Qnil;
|
117
|
-
|
118
|
-
debugMsg(( "Initializing a ParseOptions: %p", self ));
|
119
|
-
DATA_PTR( self ) = opts = parse_options_create();
|
120
|
-
|
121
|
-
rb_scan_args( argc, argv, "01", &opthash );
|
122
|
-
if ( RTEST(opthash) ) {
|
123
|
-
debugMsg(( "Setting options from an opthash." ));
|
124
|
-
rb_iterate( rb_each, opthash, rlink_parseopts_each_opthash_i, self );
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
else {
|
129
|
-
rb_raise( rb_eRuntimeError, "Cannot re-initialize a Dictionary object." );
|
130
|
-
}
|
131
|
-
|
132
|
-
return self;
|
133
|
-
}
|
134
|
-
|
135
|
-
|
136
|
-
/*
|
137
|
-
* Iterator function for rlink_parseopts_init() -- for each element of the hash passed
|
138
|
-
* to the constructor, call the corresponding accessor in the new object.
|
139
|
-
*/
|
140
|
-
static VALUE
|
141
|
-
rlink_parseopts_each_opthash_i( VALUE pair, VALUE self ) {
|
142
|
-
VALUE key, val, keystring;
|
143
|
-
char *method_name;
|
144
|
-
ID method;
|
145
|
-
|
146
|
-
key = rb_ary_entry( pair, 0 );
|
147
|
-
val = rb_ary_entry( pair, 1 );
|
148
|
-
|
149
|
-
keystring = rb_obj_as_string( key );
|
150
|
-
|
151
|
-
method_name = ALLOCA_N( char, RSTRING_LEN(keystring) + 1 );
|
152
|
-
strncpy( method_name, RSTRING_PTR(keystring), RSTRING_LEN(keystring) + 1 );
|
153
|
-
strncat( method_name, "=", 1 );
|
154
|
-
|
155
|
-
debugMsg(( "Calling method %s", method_name ));
|
156
|
-
method = rb_intern( method_name );
|
157
|
-
|
158
|
-
return rb_funcall( self, method, 1, val );
|
159
|
-
}
|
160
|
-
|
161
|
-
|
162
|
-
/*
|
163
|
-
* call-seq:
|
164
|
-
* merge( other ) -> parseopts
|
165
|
-
*
|
166
|
-
* Merge the receiving parse options with the given +other+ object, which can
|
167
|
-
* be either another LinkParser::ParseOptions object or a Hash of options.
|
168
|
-
*/
|
169
|
-
/*static VALUE
|
170
|
-
rlink_parseopts_merge( VALUE self, other ) {
|
171
|
-
|
172
|
-
}
|
173
|
-
*/
|
174
|
-
|
175
|
-
|
176
|
-
/*
|
177
|
-
* call-seq:
|
178
|
-
* opts.verbosity= fixnum
|
179
|
-
*
|
180
|
-
* This sets the level of description printed to stderr/stdout about the
|
181
|
-
* parsing process.
|
182
|
-
*/
|
183
|
-
static VALUE
|
184
|
-
rlink_parseopts_set_verbosity( VALUE self, VALUE verbosity ) {
|
185
|
-
Parse_Options opts = get_parseopts( self );
|
186
|
-
parse_options_set_verbosity( opts, NUM2INT(verbosity) );
|
187
|
-
return verbosity;
|
188
|
-
}
|
189
|
-
|
190
|
-
|
191
|
-
/*
|
192
|
-
* call-seq:
|
193
|
-
* opts.verbosity -> fixnum
|
194
|
-
*
|
195
|
-
* This gets the level of description printed to stderr/stdout about the
|
196
|
-
* parsing process.
|
197
|
-
*/
|
198
|
-
static VALUE
|
199
|
-
rlink_parseopts_get_verbosity( VALUE self ) {
|
200
|
-
Parse_Options opts = get_parseopts( self );
|
201
|
-
int rval;
|
202
|
-
|
203
|
-
rval = parse_options_get_verbosity( opts );
|
204
|
-
return INT2FIX( rval );
|
205
|
-
}
|
206
|
-
|
207
|
-
|
208
|
-
/*
|
209
|
-
* call-seq:
|
210
|
-
* opts.linkage_limit= fixnum
|
211
|
-
*
|
212
|
-
* This parameter determines the maximum number of linkages that are
|
213
|
-
* considered in post-processing. If more than +linkage_limit+ linkages are found,
|
214
|
-
* then a random sample of +linkage_limit+ is chosen for post-processing. When
|
215
|
-
* this happen a warning is displayed at verbosity levels greater than 1.
|
216
|
-
*/
|
217
|
-
static VALUE
|
218
|
-
rlink_parseopts_set_linkage_limit( VALUE self, VALUE linkage_limit ) {
|
219
|
-
Parse_Options opts = get_parseopts( self );
|
220
|
-
parse_options_set_linkage_limit( opts, NUM2INT(linkage_limit) );
|
221
|
-
return linkage_limit;
|
222
|
-
}
|
223
|
-
|
224
|
-
|
225
|
-
/*
|
226
|
-
* call-seq:
|
227
|
-
* opts.linkage_limit -> fixnum
|
228
|
-
*
|
229
|
-
* This parameter determines the maximum number of linkages that are
|
230
|
-
* considered in post-processing. If more than +linkage_limit+ linkages are found,
|
231
|
-
* then a random sample of +linkage_limit+ is chosen for post-processing. When
|
232
|
-
* this happen a warning is displayed at verbosity levels greater than 1.
|
233
|
-
*/
|
234
|
-
static VALUE
|
235
|
-
rlink_parseopts_get_linkage_limit( VALUE self ) {
|
236
|
-
Parse_Options opts = get_parseopts( self );
|
237
|
-
int rval;
|
238
|
-
|
239
|
-
rval = parse_options_get_linkage_limit( opts );
|
240
|
-
return INT2FIX( rval );
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
/*
|
245
|
-
* call-seq:
|
246
|
-
* opts.disjunct_cost= fixnum
|
247
|
-
*
|
248
|
-
* Determines the maximum disjunct cost used during parsing, where the cost
|
249
|
-
* of a disjunct is equal to the maximum cost of all of its connectors. The
|
250
|
-
* default is that all disjuncts, no matter what their cost, are considered.
|
251
|
-
*/
|
252
|
-
static VALUE
|
253
|
-
rlink_parseopts_set_disjunct_cost( VALUE self, VALUE disjunct_cost ) {
|
254
|
-
Parse_Options opts = get_parseopts( self );
|
255
|
-
parse_options_set_disjunct_cost( opts, NUM2INT(disjunct_cost) );
|
256
|
-
return disjunct_cost;
|
257
|
-
}
|
258
|
-
|
259
|
-
|
260
|
-
/*
|
261
|
-
* call-seq:
|
262
|
-
* opts.disjunct_cost -> fixnum
|
263
|
-
*
|
264
|
-
* Get the maximum disjunct cost used during parsing.
|
265
|
-
*/
|
266
|
-
static VALUE
|
267
|
-
rlink_parseopts_get_disjunct_cost( VALUE self ) {
|
268
|
-
Parse_Options opts = get_parseopts( self );
|
269
|
-
int rval;
|
270
|
-
|
271
|
-
rval = parse_options_get_disjunct_cost( opts );
|
272
|
-
return INT2FIX( rval );
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
/*
|
277
|
-
* call-seq:
|
278
|
-
* opts.min_null_count= fixnum -> fixnum
|
279
|
-
*
|
280
|
-
* Set the minimum of null links that a parse can have. A call to
|
281
|
-
* LinkParser::Sentence#parse will find all linkages having the minimum
|
282
|
-
* number of null links within the range specified by this parameter.
|
283
|
-
*/
|
284
|
-
static VALUE
|
285
|
-
rlink_parseopts_set_min_null_count( VALUE self, VALUE null_count ) {
|
286
|
-
Parse_Options opts = get_parseopts( self );
|
287
|
-
parse_options_set_min_null_count( opts, NUM2INT(null_count) );
|
288
|
-
return null_count;
|
289
|
-
}
|
290
|
-
|
291
|
-
|
292
|
-
/*
|
293
|
-
* call-seq:
|
294
|
-
* opts.min_null_count -> fixnum
|
295
|
-
*
|
296
|
-
* Get the minimum of null links that a parse can have.
|
297
|
-
*/
|
298
|
-
static VALUE
|
299
|
-
rlink_parseopts_get_min_null_count( VALUE self ) {
|
300
|
-
Parse_Options opts = get_parseopts( self );
|
301
|
-
int rval;
|
302
|
-
|
303
|
-
rval = parse_options_get_min_null_count( opts );
|
304
|
-
return INT2FIX( rval );
|
305
|
-
}
|
306
|
-
|
307
|
-
|
308
|
-
/*
|
309
|
-
* call-seq:
|
310
|
-
* opts.max_null_count= fixnum
|
311
|
-
*
|
312
|
-
* Set the maximum number of null links allowed in a parse.
|
313
|
-
*/
|
314
|
-
static VALUE
|
315
|
-
rlink_parseopts_set_max_null_count( VALUE self, VALUE null_count ) {
|
316
|
-
Parse_Options opts = get_parseopts( self );
|
317
|
-
parse_options_set_max_null_count( opts, NUM2INT(null_count) );
|
318
|
-
return null_count;
|
319
|
-
}
|
320
|
-
|
321
|
-
|
322
|
-
/*
|
323
|
-
* call-seq:
|
324
|
-
* opts.max_null_count -> fixnum
|
325
|
-
*
|
326
|
-
* Get the maximum number of null links allowed in a parse.
|
327
|
-
*/
|
328
|
-
static VALUE
|
329
|
-
rlink_parseopts_get_max_null_count( VALUE self ) {
|
330
|
-
Parse_Options opts = get_parseopts( self );
|
331
|
-
int rval;
|
332
|
-
|
333
|
-
rval = parse_options_get_max_null_count( opts );
|
334
|
-
return INT2FIX( rval );
|
335
|
-
}
|
336
|
-
|
337
|
-
|
338
|
-
/*
|
339
|
-
* call-seq:
|
340
|
-
* opts.null_block= null_block
|
341
|
-
*
|
342
|
-
* Set the null_block option to the specified value. The null_block option
|
343
|
-
* allows null links to be counted in "bunches." For example, if null_block
|
344
|
-
* is 4, then a linkage with 1,2,3 or 4 null links has a null cost of 1, a
|
345
|
-
* linkage with 5,6,7 or 8 null links has a null cost of 2, etc.
|
346
|
-
*/
|
347
|
-
static VALUE
|
348
|
-
rlink_parseopts_set_null_block( VALUE self, VALUE null_block ) {
|
349
|
-
Parse_Options opts = get_parseopts( self );
|
350
|
-
parse_options_set_null_block( opts, NUM2INT(null_block) );
|
351
|
-
return null_block;
|
352
|
-
}
|
353
|
-
|
354
|
-
|
355
|
-
/*
|
356
|
-
* call-seq:
|
357
|
-
* opts.null_block -> fixnum
|
358
|
-
*
|
359
|
-
* Get the value of the null_block option.
|
360
|
-
*/
|
361
|
-
static VALUE
|
362
|
-
rlink_parseopts_get_null_block( VALUE self ) {
|
363
|
-
Parse_Options opts = get_parseopts( self );
|
364
|
-
int rval;
|
365
|
-
|
366
|
-
rval = parse_options_get_null_block( opts );
|
367
|
-
return INT2FIX( rval );
|
368
|
-
}
|
369
|
-
|
370
|
-
|
371
|
-
/*
|
372
|
-
* call-seq:
|
373
|
-
* opts.islands_ok= boolean
|
374
|
-
*
|
375
|
-
* This option determines whether or not "islands" of links are allowed. For
|
376
|
-
* example, the following linkage has an island:
|
377
|
-
*
|
378
|
-
* +------Wd-----+
|
379
|
-
* | +--Dsu--+---Ss--+-Paf-+ +--Dsu--+---Ss--+--Pa-+
|
380
|
-
* | | | | | | | | |
|
381
|
-
* ///// this sentence.n is.v false.a this sentence.n is.v true.a
|
382
|
-
*/
|
383
|
-
static VALUE
|
384
|
-
rlink_parseopts_set_islands_ok( VALUE self, VALUE islands_ok ) {
|
385
|
-
Parse_Options opts = get_parseopts( self );
|
386
|
-
parse_options_set_islands_ok( opts, RTEST(islands_ok) );
|
387
|
-
return islands_ok;
|
388
|
-
}
|
389
|
-
|
390
|
-
|
391
|
-
/*
|
392
|
-
* call-seq:
|
393
|
-
* opts.islands_ok? -> true or false
|
394
|
-
*
|
395
|
-
* Get the value of the islands_ok option.
|
396
|
-
*/
|
397
|
-
static VALUE
|
398
|
-
rlink_parseopts_get_islands_ok_p( VALUE self ) {
|
399
|
-
Parse_Options opts = get_parseopts( self );
|
400
|
-
int rval;
|
401
|
-
|
402
|
-
rval = parse_options_get_islands_ok( opts );
|
403
|
-
return rval ? Qtrue : Qfalse;
|
404
|
-
}
|
405
|
-
|
406
|
-
|
407
|
-
/*
|
408
|
-
* call-seq:
|
409
|
-
* opts.short_length= fixnum
|
410
|
-
*
|
411
|
-
* The short_length parameter determines how long the links are allowed to
|
412
|
-
* be. The intended use of this is to speed up parsing by not considering
|
413
|
-
* very long links for most connectors, since they are very rarely used in a
|
414
|
-
* correct parse. An entry for UNLIMITED-CONNECTORS in the dictionary will
|
415
|
-
* specify which connectors are exempt from the length limit.
|
416
|
-
*/
|
417
|
-
static VALUE
|
418
|
-
rlink_parseopts_set_short_length( VALUE self, VALUE short_length ) {
|
419
|
-
Parse_Options opts = get_parseopts( self );
|
420
|
-
parse_options_set_short_length( opts, NUM2INT(short_length) );
|
421
|
-
return short_length;
|
422
|
-
}
|
423
|
-
|
424
|
-
|
425
|
-
/*
|
426
|
-
* call-seq:
|
427
|
-
* opts.short_length -> fixnum
|
428
|
-
*
|
429
|
-
* Get the value of the short_length option.
|
430
|
-
*/
|
431
|
-
static VALUE
|
432
|
-
rlink_parseopts_get_short_length( VALUE self ) {
|
433
|
-
Parse_Options opts = get_parseopts( self );
|
434
|
-
int rval;
|
435
|
-
|
436
|
-
rval = parse_options_get_short_length( opts );
|
437
|
-
return INT2FIX( rval );
|
438
|
-
}
|
439
|
-
|
440
|
-
|
441
|
-
/*
|
442
|
-
* call-seq:
|
443
|
-
* opts.max_memory= fixnum
|
444
|
-
*
|
445
|
-
* Determines the maximum memory allowed during parsing. This is used just as
|
446
|
-
* max_parse_time is, so that the parsing process is terminated as quickly as
|
447
|
-
* possible after the total memory (including that allocated to all
|
448
|
-
* dictionaries, etc.) exceeds the maximum allowed.
|
449
|
-
*/
|
450
|
-
static VALUE
|
451
|
-
rlink_parseopts_set_max_memory( VALUE self, VALUE mem ) {
|
452
|
-
Parse_Options opts = get_parseopts( self );
|
453
|
-
parse_options_set_max_memory( opts, NUM2INT(mem) );
|
454
|
-
return mem;
|
455
|
-
}
|
456
|
-
|
457
|
-
|
458
|
-
/*
|
459
|
-
* call-seq:
|
460
|
-
* opts.max_memory -> fixnum
|
461
|
-
*
|
462
|
-
* Get the value of the max_memory option.
|
463
|
-
*/
|
464
|
-
static VALUE
|
465
|
-
rlink_parseopts_get_max_memory( VALUE self ) {
|
466
|
-
Parse_Options opts = get_parseopts( self );
|
467
|
-
int rval;
|
468
|
-
|
469
|
-
rval = parse_options_get_max_memory( opts );
|
470
|
-
return INT2FIX( rval );
|
471
|
-
}
|
472
|
-
|
473
|
-
|
474
|
-
/*
|
475
|
-
* call-seq:
|
476
|
-
* opts.max_sentence_length= fixnum
|
477
|
-
*
|
478
|
-
* Determines the maximum length of a parsed sentence.
|
479
|
-
*/
|
480
|
-
static VALUE
|
481
|
-
rlink_parseopts_set_max_sentence_length( VALUE self, VALUE len ) {
|
482
|
-
Parse_Options opts = get_parseopts( self );
|
483
|
-
parse_options_set_max_sentence_length( opts, NUM2INT(len) );
|
484
|
-
return len;
|
485
|
-
}
|
486
|
-
|
487
|
-
|
488
|
-
/*
|
489
|
-
* call-seq:
|
490
|
-
* opts.max_sentence_length -> fixnum
|
491
|
-
*
|
492
|
-
* Get the value of the max_sentence_length option.
|
493
|
-
*/
|
494
|
-
static VALUE
|
495
|
-
rlink_parseopts_get_max_sentence_length( VALUE self ) {
|
496
|
-
Parse_Options opts = get_parseopts( self );
|
497
|
-
int rval;
|
498
|
-
|
499
|
-
rval = parse_options_get_max_sentence_length( opts );
|
500
|
-
return INT2FIX( rval );
|
501
|
-
}
|
502
|
-
|
503
|
-
|
504
|
-
/*
|
505
|
-
* call-seq:
|
506
|
-
* opts.max_parse_time= seconds
|
507
|
-
*
|
508
|
-
* Determines the approximate maximum time that parsing is allowed to take.
|
509
|
-
* The way it works is that after this time has expired, the parsing process
|
510
|
-
* is artificially forced to complete quickly by pretending that no further
|
511
|
-
* solutions (entries in the hash table) can be constructed. The actual
|
512
|
-
* parsing time might be slightly longer.
|
513
|
-
*/
|
514
|
-
static VALUE
|
515
|
-
rlink_parseopts_set_max_parse_time( VALUE self, VALUE secs ) {
|
516
|
-
Parse_Options opts = get_parseopts( self );
|
517
|
-
parse_options_set_max_parse_time( opts, NUM2INT(secs) );
|
518
|
-
return secs;
|
519
|
-
}
|
520
|
-
|
521
|
-
|
522
|
-
/*
|
523
|
-
* call-seq:
|
524
|
-
* opts.max_parse_time -> fixnum
|
525
|
-
*
|
526
|
-
* Get the number of seconds of the max_parse_time option.
|
527
|
-
*/
|
528
|
-
static VALUE
|
529
|
-
rlink_parseopts_get_max_parse_time( VALUE self ) {
|
530
|
-
Parse_Options opts = get_parseopts( self );
|
531
|
-
int rval;
|
532
|
-
|
533
|
-
rval = parse_options_get_max_parse_time( opts );
|
534
|
-
return INT2FIX( rval );
|
535
|
-
}
|
536
|
-
|
537
|
-
|
538
|
-
/*
|
539
|
-
* call-seq:
|
540
|
-
* opts.screen_width= columns
|
541
|
-
*
|
542
|
-
* Set the screen width assumed by the diagramming functions.
|
543
|
-
*/
|
544
|
-
static VALUE
|
545
|
-
rlink_parseopts_set_screen_width( VALUE self, VALUE val ) {
|
546
|
-
Parse_Options opts = get_parseopts( self );
|
547
|
-
parse_options_set_screen_width( opts, NUM2INT(val) );
|
548
|
-
return val;
|
549
|
-
}
|
550
|
-
|
551
|
-
|
552
|
-
/*
|
553
|
-
* call-seq:
|
554
|
-
* opts.screen_width -> fixnum
|
555
|
-
*
|
556
|
-
* Get the screen width assumed by the diagramming functions.
|
557
|
-
*/
|
558
|
-
static VALUE
|
559
|
-
rlink_parseopts_get_screen_width( VALUE self ) {
|
560
|
-
Parse_Options opts = get_parseopts( self );
|
561
|
-
int rval;
|
562
|
-
|
563
|
-
rval = parse_options_get_screen_width( opts );
|
564
|
-
return INT2FIX( rval );
|
565
|
-
}
|
566
|
-
|
567
|
-
|
568
|
-
/*
|
569
|
-
* call-seq:
|
570
|
-
* opts.allow_null= boolean
|
571
|
-
*
|
572
|
-
* Indicates whether or not linkages are allowed to have null links.
|
573
|
-
*/
|
574
|
-
static VALUE
|
575
|
-
rlink_parseopts_set_allow_null( VALUE self, VALUE val ) {
|
576
|
-
Parse_Options opts = get_parseopts( self );
|
577
|
-
parse_options_set_allow_null( opts, RTEST(val) );
|
578
|
-
return val;
|
579
|
-
}
|
580
|
-
|
581
|
-
|
582
|
-
/*
|
583
|
-
* call-seq:
|
584
|
-
* opts.allow_null? -> true or false
|
585
|
-
*
|
586
|
-
* Get the value of the allow_null option.
|
587
|
-
*/
|
588
|
-
static VALUE
|
589
|
-
rlink_parseopts_get_allow_null_p( VALUE self ) {
|
590
|
-
Parse_Options opts = get_parseopts( self );
|
591
|
-
int rval;
|
592
|
-
|
593
|
-
rval = parse_options_get_allow_null( opts );
|
594
|
-
return rval ? Qtrue : Qfalse;
|
595
|
-
}
|
596
|
-
|
597
|
-
|
598
|
-
/*
|
599
|
-
* call-seq:
|
600
|
-
* opts.display_walls= boolean
|
601
|
-
*
|
602
|
-
* Whether or not to show the wall word(s) when a linkage diagram is printed.
|
603
|
-
*/
|
604
|
-
static VALUE
|
605
|
-
rlink_parseopts_set_display_walls( VALUE self, VALUE val ) {
|
606
|
-
Parse_Options opts = get_parseopts( self );
|
607
|
-
parse_options_set_display_walls( opts, RTEST(val) );
|
608
|
-
return val;
|
609
|
-
}
|
610
|
-
|
611
|
-
|
612
|
-
/*
|
613
|
-
* call-seq:
|
614
|
-
* opts.display_walls? -> true or false
|
615
|
-
*
|
616
|
-
* Whether or not to show the wall word(s) when a linkage diagram is printed.
|
617
|
-
*/
|
618
|
-
static VALUE
|
619
|
-
rlink_parseopts_get_display_walls_p( VALUE self ) {
|
620
|
-
Parse_Options opts = get_parseopts( self );
|
621
|
-
int rval;
|
622
|
-
|
623
|
-
rval = parse_options_get_display_walls( opts );
|
624
|
-
return rval ? Qtrue : Qfalse;
|
625
|
-
}
|
626
|
-
|
627
|
-
|
628
|
-
/*
|
629
|
-
* call-seq:
|
630
|
-
* opts.all_short_connectors= boolean
|
631
|
-
*
|
632
|
-
* If true, then all connectors have length restrictions imposed on them --
|
633
|
-
* they can be no farther than short_length apart. This is used when parsing
|
634
|
-
* in "panic" mode, for example.
|
635
|
-
*/
|
636
|
-
static VALUE
|
637
|
-
rlink_parseopts_set_all_short_connectors( VALUE self, VALUE val ) {
|
638
|
-
Parse_Options opts = get_parseopts( self );
|
639
|
-
parse_options_set_all_short_connectors( opts, RTEST(val) );
|
640
|
-
return val;
|
641
|
-
}
|
642
|
-
|
643
|
-
|
644
|
-
/*
|
645
|
-
* call-seq:
|
646
|
-
* opts.all_short_connectors? -> true or false
|
647
|
-
*
|
648
|
-
* Get the value of the all_short_connectors option.
|
649
|
-
*/
|
650
|
-
static VALUE
|
651
|
-
rlink_parseopts_get_all_short_connectors_p( VALUE self ) {
|
652
|
-
Parse_Options opts = get_parseopts( self );
|
653
|
-
int rval;
|
654
|
-
|
655
|
-
rval = parse_options_get_all_short_connectors( opts );
|
656
|
-
return rval ? Qtrue : Qfalse;
|
657
|
-
}
|
658
|
-
|
659
|
-
|
660
|
-
/*
|
661
|
-
* call-seq:
|
662
|
-
* opts.cost_model_type=
|
663
|
-
*
|
664
|
-
* The cost model type for ranking linkages, which is an index into an array
|
665
|
-
* of function pointers. The current code only has a single entry, but others
|
666
|
-
* could easily be added.
|
667
|
-
*/
|
668
|
-
static VALUE
|
669
|
-
rlink_parseopts_set_cost_model_type( VALUE self, VALUE cm ) {
|
670
|
-
Parse_Options opts = get_parseopts( self );
|
671
|
-
parse_options_set_cost_model_type( opts, NUM2INT(cm) );
|
672
|
-
return cm;
|
673
|
-
}
|
674
|
-
|
675
|
-
|
676
|
-
/*
|
677
|
-
* call-seq:
|
678
|
-
* opts.cost_model_type -> fixnum
|
679
|
-
*
|
680
|
-
* Get the cost model type for ranking linkages.
|
681
|
-
*/
|
682
|
-
/*
|
683
|
-
|
684
|
-
There's no actual API function for getting the cost_model_type. I guess if
|
685
|
-
there's ever more than one model type defined there will be.
|
686
|
-
|
687
|
-
static VALUE
|
688
|
-
rlink_parseopts_get_cost_model_type( VALUE self ) {
|
689
|
-
Parse_Options opts = get_parseopts( self );
|
690
|
-
int rval;
|
691
|
-
|
692
|
-
rval = parse_options_get_cost_model_type( opts );
|
693
|
-
return INT2FIX( rval );
|
694
|
-
}
|
695
|
-
*/
|
696
|
-
|
697
|
-
|
698
|
-
/*
|
699
|
-
* call-seq:
|
700
|
-
* opts.batch_mode= boolean
|
701
|
-
*
|
702
|
-
* Enable or disable "batch mode."
|
703
|
-
*
|
704
|
-
* :TODO: Figure out what batch mode is.
|
705
|
-
*/
|
706
|
-
static VALUE
|
707
|
-
rlink_parseopts_set_batch_mode( VALUE self, VALUE val ) {
|
708
|
-
Parse_Options opts = get_parseopts( self );
|
709
|
-
parse_options_set_batch_mode( opts, RTEST(val) );
|
710
|
-
return val;
|
711
|
-
}
|
712
|
-
|
713
|
-
|
714
|
-
/*
|
715
|
-
* call-seq:
|
716
|
-
* opts.batch_mode? -> true or false
|
717
|
-
*
|
718
|
-
* Returns +true+ if batch mode is enabled.
|
719
|
-
*/
|
720
|
-
static VALUE
|
721
|
-
rlink_parseopts_get_batch_mode_p( VALUE self ) {
|
722
|
-
Parse_Options opts = get_parseopts( self );
|
723
|
-
int rval;
|
724
|
-
|
725
|
-
rval = parse_options_get_batch_mode( opts );
|
726
|
-
return rval ? Qtrue : Qfalse;
|
727
|
-
}
|
728
|
-
|
729
|
-
/*
|
730
|
-
* call-seq:
|
731
|
-
* opts.panic_mode= boolean
|
732
|
-
*
|
733
|
-
* Enable or disable "panic mode."
|
734
|
-
*
|
735
|
-
* :TODO: Figure out what enabling this option does. I only know about panic
|
736
|
-
* mode in the parser -- does this allow/disallow the parser from entering it?
|
737
|
-
*/
|
738
|
-
static VALUE
|
739
|
-
rlink_parseopts_set_panic_mode( VALUE self, VALUE val ) {
|
740
|
-
Parse_Options opts = get_parseopts( self );
|
741
|
-
parse_options_set_panic_mode( opts, RTEST(val) );
|
742
|
-
return val;
|
743
|
-
}
|
744
|
-
|
745
|
-
|
746
|
-
/*
|
747
|
-
* call-seq:
|
748
|
-
* opts.panic_mode? -> true or false
|
749
|
-
*
|
750
|
-
* Returns +true+ if panic mode is enabled.
|
751
|
-
*/
|
752
|
-
static VALUE
|
753
|
-
rlink_parseopts_get_panic_mode_p( VALUE self ) {
|
754
|
-
Parse_Options opts = get_parseopts( self );
|
755
|
-
int rval;
|
756
|
-
|
757
|
-
rval = parse_options_get_panic_mode( opts );
|
758
|
-
return rval ? Qtrue : Qfalse;
|
759
|
-
}
|
760
|
-
|
761
|
-
|
762
|
-
/*
|
763
|
-
* call-seq:
|
764
|
-
* opts.display_on= boolean
|
765
|
-
*
|
766
|
-
* Enable/disable display.
|
767
|
-
*
|
768
|
-
* :TODO: Figure out what this setting does.
|
769
|
-
*
|
770
|
-
*/
|
771
|
-
static VALUE
|
772
|
-
rlink_parseopts_set_display_on( VALUE self, VALUE val ) {
|
773
|
-
Parse_Options opts = get_parseopts( self );
|
774
|
-
parse_options_set_display_on( opts, RTEST(val) );
|
775
|
-
return val;
|
776
|
-
}
|
777
|
-
|
778
|
-
|
779
|
-
/*
|
780
|
-
* call-seq:
|
781
|
-
* opts.display_on? -> true or false
|
782
|
-
*
|
783
|
-
* Returns +true+ if ...?
|
784
|
-
*/
|
785
|
-
static VALUE
|
786
|
-
rlink_parseopts_get_display_on_p( VALUE self ) {
|
787
|
-
Parse_Options opts = get_parseopts( self );
|
788
|
-
int rval;
|
789
|
-
|
790
|
-
rval = parse_options_get_display_on( opts );
|
791
|
-
return rval ? Qtrue : Qfalse;
|
792
|
-
}
|
793
|
-
|
794
|
-
|
795
|
-
/*
|
796
|
-
* call-seq:
|
797
|
-
* opts.display_postscript= boolean
|
798
|
-
*
|
799
|
-
* Enable/disable display using Postscript.
|
800
|
-
*/
|
801
|
-
static VALUE
|
802
|
-
rlink_parseopts_set_display_postscript( VALUE self, VALUE val ) {
|
803
|
-
Parse_Options opts = get_parseopts( self );
|
804
|
-
parse_options_set_display_postscript( opts, RTEST(val) );
|
805
|
-
return val;
|
806
|
-
}
|
807
|
-
|
808
|
-
|
809
|
-
/*
|
810
|
-
* call-seq:
|
811
|
-
* opts.display_postscript? -> true or false
|
812
|
-
*
|
813
|
-
* Returns +true+ if display should use Postscript instead of plain text.
|
814
|
-
*/
|
815
|
-
static VALUE
|
816
|
-
rlink_parseopts_get_display_postscript_p( VALUE self ) {
|
817
|
-
Parse_Options opts = get_parseopts( self );
|
818
|
-
int rval;
|
819
|
-
|
820
|
-
rval = parse_options_get_display_postscript( opts );
|
821
|
-
return rval ? Qtrue : Qfalse;
|
822
|
-
}
|
823
|
-
|
824
|
-
|
825
|
-
/*
|
826
|
-
* call-seq:
|
827
|
-
* opts.display_constituents= boolean
|
828
|
-
*
|
829
|
-
* Set the display_constituents option to the specified value.
|
830
|
-
*/
|
831
|
-
static VALUE
|
832
|
-
rlink_parseopts_set_display_constituents( VALUE self, VALUE val ) {
|
833
|
-
Parse_Options opts = get_parseopts( self );
|
834
|
-
parse_options_set_display_constituents( opts, RTEST(val) );
|
835
|
-
return val;
|
836
|
-
}
|
837
|
-
|
838
|
-
|
839
|
-
/*
|
840
|
-
* call-seq:
|
841
|
-
* opts.display_constituents? -> true or false
|
842
|
-
*
|
843
|
-
* Get the value of the display_constituents option.
|
844
|
-
*/
|
845
|
-
static VALUE
|
846
|
-
rlink_parseopts_get_display_constituents_p( VALUE self ) {
|
847
|
-
Parse_Options opts = get_parseopts( self );
|
848
|
-
int rval;
|
849
|
-
|
850
|
-
rval = parse_options_get_display_constituents( opts );
|
851
|
-
return rval ? Qtrue : Qfalse;
|
852
|
-
}
|
853
|
-
|
854
|
-
|
855
|
-
/*
|
856
|
-
* call-seq:
|
857
|
-
* opts.display_bad= boolean
|
858
|
-
*
|
859
|
-
* Set the display_bad option to the specified value.
|
860
|
-
*/
|
861
|
-
static VALUE
|
862
|
-
rlink_parseopts_set_display_bad( VALUE self, VALUE val ) {
|
863
|
-
Parse_Options opts = get_parseopts( self );
|
864
|
-
parse_options_set_display_bad( opts, RTEST(val) );
|
865
|
-
return val;
|
866
|
-
}
|
867
|
-
|
868
|
-
|
869
|
-
/*
|
870
|
-
* call-seq:
|
871
|
-
* opts.display_bad? -> true or false
|
872
|
-
*
|
873
|
-
* Get the value of the display_bad option.
|
874
|
-
*/
|
875
|
-
static VALUE
|
876
|
-
rlink_parseopts_get_display_bad_p( VALUE self ) {
|
877
|
-
Parse_Options opts = get_parseopts( self );
|
878
|
-
int rval;
|
879
|
-
|
880
|
-
rval = parse_options_get_display_bad( opts );
|
881
|
-
return rval ? Qtrue : Qfalse;
|
882
|
-
}
|
883
|
-
|
884
|
-
|
885
|
-
/*
|
886
|
-
* call-seq:
|
887
|
-
* opts.display_links= boolean
|
888
|
-
*
|
889
|
-
* Set the display_links option to the specified value.
|
890
|
-
*/
|
891
|
-
static VALUE
|
892
|
-
rlink_parseopts_set_display_links( VALUE self, VALUE val ) {
|
893
|
-
Parse_Options opts = get_parseopts( self );
|
894
|
-
parse_options_set_display_links( opts, RTEST(val) );
|
895
|
-
return val;
|
896
|
-
}
|
897
|
-
|
898
|
-
|
899
|
-
/*
|
900
|
-
* call-seq:
|
901
|
-
* opts.display_links? -> true or false
|
902
|
-
*
|
903
|
-
* Get the value of the display_links option.
|
904
|
-
*/
|
905
|
-
static VALUE
|
906
|
-
rlink_parseopts_get_display_links_p( VALUE self ) {
|
907
|
-
Parse_Options opts = get_parseopts( self );
|
908
|
-
int rval;
|
909
|
-
|
910
|
-
rval = parse_options_get_display_links( opts );
|
911
|
-
return rval ? Qtrue : Qfalse;
|
912
|
-
}
|
913
|
-
|
914
|
-
|
915
|
-
/*
|
916
|
-
* call-seq:
|
917
|
-
* opts.display_union= boolean
|
918
|
-
*
|
919
|
-
* Set the display_union option to the specified value.
|
920
|
-
*/
|
921
|
-
static VALUE
|
922
|
-
rlink_parseopts_set_display_union( VALUE self, VALUE val ) {
|
923
|
-
Parse_Options opts = get_parseopts( self );
|
924
|
-
parse_options_set_display_union( opts, RTEST(val) );
|
925
|
-
return val;
|
926
|
-
}
|
927
|
-
|
928
|
-
|
929
|
-
/*
|
930
|
-
* call-seq:
|
931
|
-
* opts.display_union? -> true or false
|
932
|
-
*
|
933
|
-
* Get the value of the display_union option.
|
934
|
-
*/
|
935
|
-
static VALUE
|
936
|
-
rlink_parseopts_get_display_union_p( VALUE self ) {
|
937
|
-
Parse_Options opts = get_parseopts( self );
|
938
|
-
int rval;
|
939
|
-
|
940
|
-
rval = parse_options_get_display_union( opts );
|
941
|
-
return rval ? Qtrue : Qfalse;
|
942
|
-
}
|
943
|
-
|
944
|
-
|
945
|
-
/*
|
946
|
-
* call-seq:
|
947
|
-
* opts.echo_on= boolean
|
948
|
-
*
|
949
|
-
* Set the echo_on option to the specified value.
|
950
|
-
*/
|
951
|
-
static VALUE
|
952
|
-
rlink_parseopts_set_echo_on( VALUE self, VALUE val ) {
|
953
|
-
Parse_Options opts = get_parseopts( self );
|
954
|
-
parse_options_set_echo_on( opts, RTEST(val) );
|
955
|
-
return val;
|
956
|
-
}
|
957
|
-
|
958
|
-
|
959
|
-
/*
|
960
|
-
* call-seq:
|
961
|
-
* opts.echo_on? -> true or false
|
962
|
-
*
|
963
|
-
* Get the value of the echo_on option.
|
964
|
-
*/
|
965
|
-
static VALUE
|
966
|
-
rlink_parseopts_get_echo_on_p( VALUE self ) {
|
967
|
-
Parse_Options opts = get_parseopts( self );
|
968
|
-
int rval;
|
969
|
-
|
970
|
-
rval = parse_options_get_echo_on( opts );
|
971
|
-
return rval ? Qtrue : Qfalse;
|
972
|
-
}
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
/*
|
978
|
-
* call-seq:
|
979
|
-
* opts.spell_guessing_enabled= boolean
|
980
|
-
*
|
981
|
-
* Enable/disable spell-guessing if it's supported.
|
982
|
-
*/
|
983
|
-
static VALUE
|
984
|
-
rlink_parseopts_set_spell_guess( VALUE self, VALUE val ) {
|
985
|
-
#ifdef HAVE_PARSE_OPTIONS_GET_SPELL_GUESS
|
986
|
-
Parse_Options opts = get_parseopts( self );
|
987
|
-
parse_options_set_spell_guess( opts, RTEST(val) );
|
988
|
-
return val;
|
989
|
-
#else
|
990
|
-
rb_notimplement();
|
991
|
-
return Qnil;
|
992
|
-
#endif /* HAVE_PARSE_OPTIONS_GET_SPELL_GUESS */
|
993
|
-
}
|
994
|
-
|
995
|
-
|
996
|
-
/*
|
997
|
-
* call-seq:
|
998
|
-
* opts.spell_guessing_enabled? -> true or false
|
999
|
-
*
|
1000
|
-
* Returns +true+ if spell-guessing is enabled. Note that a +true+ return value doesn't
|
1001
|
-
* mean that it's supported, only that it will be used if it is.
|
1002
|
-
*/
|
1003
|
-
static VALUE
|
1004
|
-
rlink_parseopts_get_spell_guess_p( VALUE self ) {
|
1005
|
-
#ifdef HAVE_PARSE_OPTIONS_GET_SPELL_GUESS
|
1006
|
-
Parse_Options opts = get_parseopts( self );
|
1007
|
-
int rval;
|
1008
|
-
|
1009
|
-
rval = parse_options_get_spell_guess( opts );
|
1010
|
-
return rval ? Qtrue : Qfalse;
|
1011
|
-
#else
|
1012
|
-
rb_notimplement();
|
1013
|
-
return Qnil;
|
1014
|
-
#endif /* HAVE_PARSE_OPTIONS_GET_SPELL_GUESS */
|
1015
|
-
}
|
1016
|
-
|
1017
|
-
|
1018
|
-
/*
|
1019
|
-
* call-seq:
|
1020
|
-
* opts.timer_expired? -> +true+ or +false+
|
1021
|
-
*
|
1022
|
-
* Returns true if timer constraints were exceeded during parsing.
|
1023
|
-
*
|
1024
|
-
* sentence.parse
|
1025
|
-
* if sentence.options.timer_expired?
|
1026
|
-
* $stderr.puts "Parsing sentence #{sentence} timed out."
|
1027
|
-
* end
|
1028
|
-
*/
|
1029
|
-
static VALUE
|
1030
|
-
rlink_parseopts_timer_expired_p( VALUE self ) {
|
1031
|
-
Parse_Options opts = get_parseopts( self );
|
1032
|
-
int rval;
|
1033
|
-
|
1034
|
-
rval = parse_options_timer_expired( opts );
|
1035
|
-
return rval ? Qtrue : Qfalse;
|
1036
|
-
}
|
1037
|
-
|
1038
|
-
|
1039
|
-
/*
|
1040
|
-
* call-seq:
|
1041
|
-
* opts.memory_exhausted? -> +true+ or +false+
|
1042
|
-
*
|
1043
|
-
* Returns true if memory constraints were exceeded during parsing.
|
1044
|
-
*
|
1045
|
-
* sentence.parse
|
1046
|
-
* if sentence.options.memory_exhausted?
|
1047
|
-
* $stderr.puts "Parsing sentence #{sentence} ran out of memory."
|
1048
|
-
* end
|
1049
|
-
*/
|
1050
|
-
static VALUE
|
1051
|
-
rlink_parseopts_memory_exhausted_p( VALUE self ) {
|
1052
|
-
Parse_Options opts = get_parseopts( self );
|
1053
|
-
int rval;
|
1054
|
-
|
1055
|
-
rval = parse_options_memory_exhausted( opts );
|
1056
|
-
return rval ? Qtrue : Qfalse;
|
1057
|
-
}
|
1058
|
-
|
1059
|
-
|
1060
|
-
/*
|
1061
|
-
* call-seq:
|
1062
|
-
* opts.resources_exhausted? -> +true+ or +false+
|
1063
|
-
*
|
1064
|
-
* Returns true if the memory or timer constraints were exceeded during parsing.
|
1065
|
-
*
|
1066
|
-
* sentence.parse
|
1067
|
-
* if sentence.options.resources_exhausted?
|
1068
|
-
* $stderr.puts "Parsing sentence #{sentence} ran out of resources."
|
1069
|
-
* end
|
1070
|
-
*/
|
1071
|
-
static VALUE
|
1072
|
-
rlink_parseopts_resources_exhausted_p( VALUE self ) {
|
1073
|
-
Parse_Options opts = get_parseopts( self );
|
1074
|
-
int rval;
|
1075
|
-
|
1076
|
-
rval = parse_options_resources_exhausted( opts );
|
1077
|
-
return rval ? Qtrue : Qfalse;
|
1078
|
-
}
|
1079
|
-
|
1080
|
-
|
1081
|
-
/*
|
1082
|
-
* call-seq:
|
1083
|
-
* opts.reset_resources
|
1084
|
-
*
|
1085
|
-
* Reset the timer- and memory-constraint flags.
|
1086
|
-
*
|
1087
|
-
*/
|
1088
|
-
static VALUE
|
1089
|
-
rlink_parseopts_reset_resources( VALUE self ) {
|
1090
|
-
Parse_Options opts = get_parseopts( self );
|
1091
|
-
|
1092
|
-
parse_options_reset_resources( opts );
|
1093
|
-
return Qnil;
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
/*
|
1099
|
-
* LinkParser parse options class. Instances of this class are used to specify the different
|
1100
|
-
* parameters that are used to parse sentences. Examples of the kinds of things that are
|
1101
|
-
* controlled by ParseOptions include maximum parsing time and memory, whether to use
|
1102
|
-
* null-links, and whether or not to use "panic" mode. This data structure is passed in to
|
1103
|
-
* the various parsing and printing routines along with the sentence.
|
1104
|
-
*
|
1105
|
-
*/
|
1106
|
-
void
|
1107
|
-
rlink_init_parseoptions() {
|
1108
|
-
rlink_cParseOptions = rb_define_class_under( rlink_mLinkParser,
|
1109
|
-
"ParseOptions", rb_cObject );
|
1110
|
-
|
1111
|
-
rb_define_alloc_func( rlink_cParseOptions, rlink_parseopts_s_alloc );
|
1112
|
-
rb_define_method( rlink_cParseOptions, "initialize", rlink_parseopts_init, -1 );
|
1113
|
-
/*
|
1114
|
-
rb_define_method( rlink_cParseOptions, "merge", rlink_parseopts_merge, 1 );
|
1115
|
-
rb_define_method( rlink_cParseOptions, "merge!", rlink_parseopts_merge_bang, 1 );
|
1116
|
-
*/
|
1117
|
-
rb_define_method( rlink_cParseOptions, "verbosity=",
|
1118
|
-
rlink_parseopts_set_verbosity, 1 );
|
1119
|
-
rb_define_method( rlink_cParseOptions, "verbosity",
|
1120
|
-
rlink_parseopts_get_verbosity, 0 );
|
1121
|
-
rb_define_method( rlink_cParseOptions, "linkage_limit=",
|
1122
|
-
rlink_parseopts_set_linkage_limit, 1 );
|
1123
|
-
rb_define_method( rlink_cParseOptions, "linkage_limit",
|
1124
|
-
rlink_parseopts_get_linkage_limit, 0 );
|
1125
|
-
rb_define_method( rlink_cParseOptions, "disjunct_cost=",
|
1126
|
-
rlink_parseopts_set_disjunct_cost, 1 );
|
1127
|
-
rb_define_method( rlink_cParseOptions, "disjunct_cost",
|
1128
|
-
rlink_parseopts_get_disjunct_cost, 0 );
|
1129
|
-
rb_define_method( rlink_cParseOptions, "min_null_count=",
|
1130
|
-
rlink_parseopts_set_min_null_count, 1 );
|
1131
|
-
rb_define_method( rlink_cParseOptions, "min_null_count",
|
1132
|
-
rlink_parseopts_get_min_null_count, 0 );
|
1133
|
-
rb_define_method( rlink_cParseOptions, "max_null_count=",
|
1134
|
-
rlink_parseopts_set_max_null_count, 1 );
|
1135
|
-
rb_define_method( rlink_cParseOptions, "max_null_count",
|
1136
|
-
rlink_parseopts_get_max_null_count, 0 );
|
1137
|
-
rb_define_method( rlink_cParseOptions, "null_block=",
|
1138
|
-
rlink_parseopts_set_null_block, 1 );
|
1139
|
-
rb_define_method( rlink_cParseOptions, "null_block",
|
1140
|
-
rlink_parseopts_get_null_block, 0 );
|
1141
|
-
rb_define_method( rlink_cParseOptions, "islands_ok=",
|
1142
|
-
rlink_parseopts_set_islands_ok, 1 );
|
1143
|
-
rb_define_method( rlink_cParseOptions, "islands_ok?",
|
1144
|
-
rlink_parseopts_get_islands_ok_p, 0 );
|
1145
|
-
rb_define_method( rlink_cParseOptions, "short_length=",
|
1146
|
-
rlink_parseopts_set_short_length, 1 );
|
1147
|
-
rb_define_method( rlink_cParseOptions, "short_length",
|
1148
|
-
rlink_parseopts_get_short_length, 0 );
|
1149
|
-
rb_define_method( rlink_cParseOptions, "max_memory=",
|
1150
|
-
rlink_parseopts_set_max_memory, 1 );
|
1151
|
-
rb_define_method( rlink_cParseOptions, "max_memory",
|
1152
|
-
rlink_parseopts_get_max_memory, 0 );
|
1153
|
-
rb_define_method( rlink_cParseOptions, "max_sentence_length=",
|
1154
|
-
rlink_parseopts_set_max_sentence_length, 1 );
|
1155
|
-
rb_define_method( rlink_cParseOptions, "max_sentence_length",
|
1156
|
-
rlink_parseopts_get_max_sentence_length, 0 );
|
1157
|
-
rb_define_method( rlink_cParseOptions, "max_parse_time=",
|
1158
|
-
rlink_parseopts_set_max_parse_time, 1 );
|
1159
|
-
rb_define_method( rlink_cParseOptions, "max_parse_time",
|
1160
|
-
rlink_parseopts_get_max_parse_time, 0 );
|
1161
|
-
rb_define_method( rlink_cParseOptions, "screen_width=",
|
1162
|
-
rlink_parseopts_set_screen_width, 1 );
|
1163
|
-
rb_define_method( rlink_cParseOptions, "screen_width",
|
1164
|
-
rlink_parseopts_get_screen_width, 0 );
|
1165
|
-
rb_define_method( rlink_cParseOptions, "allow_null=",
|
1166
|
-
rlink_parseopts_set_allow_null, 1 );
|
1167
|
-
rb_define_method( rlink_cParseOptions, "allow_null?",
|
1168
|
-
rlink_parseopts_get_allow_null_p, 0 );
|
1169
|
-
rb_define_method( rlink_cParseOptions, "display_walls=",
|
1170
|
-
rlink_parseopts_set_display_walls, 1 );
|
1171
|
-
rb_define_method( rlink_cParseOptions, "display_walls?",
|
1172
|
-
rlink_parseopts_get_display_walls_p, 0 );
|
1173
|
-
rb_define_method( rlink_cParseOptions, "all_short_connectors=",
|
1174
|
-
rlink_parseopts_set_all_short_connectors, 1 );
|
1175
|
-
rb_define_method( rlink_cParseOptions, "all_short_connectors?",
|
1176
|
-
rlink_parseopts_get_all_short_connectors_p, 0 );
|
1177
|
-
rb_define_method( rlink_cParseOptions, "cost_model_type=",
|
1178
|
-
rlink_parseopts_set_cost_model_type, 1 );
|
1179
|
-
|
1180
|
-
/* (No way to get the cost_model_type from the API)
|
1181
|
-
|
1182
|
-
rb_define_method( rlink_cParseOptions, "cost_model_type",
|
1183
|
-
rlink_parseopts_get_cost_model_type, 0 );
|
1184
|
-
*/
|
1185
|
-
rb_define_method( rlink_cParseOptions, "batch_mode=",
|
1186
|
-
rlink_parseopts_set_batch_mode, 1 );
|
1187
|
-
rb_define_method( rlink_cParseOptions, "batch_mode?",
|
1188
|
-
rlink_parseopts_get_batch_mode_p, 0 );
|
1189
|
-
rb_define_method( rlink_cParseOptions, "panic_mode=",
|
1190
|
-
rlink_parseopts_set_panic_mode, 1 );
|
1191
|
-
rb_define_method( rlink_cParseOptions, "panic_mode?",
|
1192
|
-
rlink_parseopts_get_panic_mode_p, 0 );
|
1193
|
-
rb_define_method( rlink_cParseOptions, "display_on=",
|
1194
|
-
rlink_parseopts_set_display_on, 1 );
|
1195
|
-
rb_define_method( rlink_cParseOptions, "display_on?",
|
1196
|
-
rlink_parseopts_get_display_on_p, 0 );
|
1197
|
-
rb_define_method( rlink_cParseOptions, "display_postscript=",
|
1198
|
-
rlink_parseopts_set_display_postscript, 1 );
|
1199
|
-
rb_define_method( rlink_cParseOptions, "display_postscript?",
|
1200
|
-
rlink_parseopts_get_display_postscript_p, 0 );
|
1201
|
-
rb_define_method( rlink_cParseOptions, "display_constituents=",
|
1202
|
-
rlink_parseopts_set_display_constituents, 1 );
|
1203
|
-
rb_define_method( rlink_cParseOptions, "display_constituents?",
|
1204
|
-
rlink_parseopts_get_display_constituents_p, 0 );
|
1205
|
-
rb_define_method( rlink_cParseOptions, "display_bad=",
|
1206
|
-
rlink_parseopts_set_display_bad, 1 );
|
1207
|
-
rb_define_method( rlink_cParseOptions, "display_bad?",
|
1208
|
-
rlink_parseopts_get_display_bad_p, 0 );
|
1209
|
-
rb_define_method( rlink_cParseOptions, "display_links=",
|
1210
|
-
rlink_parseopts_set_display_links, 1 );
|
1211
|
-
rb_define_method( rlink_cParseOptions, "display_links?",
|
1212
|
-
rlink_parseopts_get_display_links_p, 0 );
|
1213
|
-
rb_define_method( rlink_cParseOptions, "display_union=",
|
1214
|
-
rlink_parseopts_set_display_union, 1 );
|
1215
|
-
rb_define_method( rlink_cParseOptions, "display_union?",
|
1216
|
-
rlink_parseopts_get_display_union_p, 0 );
|
1217
|
-
rb_define_method( rlink_cParseOptions, "echo_on=",
|
1218
|
-
rlink_parseopts_set_echo_on, 1 );
|
1219
|
-
rb_define_method( rlink_cParseOptions, "echo_on?",
|
1220
|
-
rlink_parseopts_get_echo_on_p, 0 );
|
1221
|
-
rb_define_method( rlink_cParseOptions, "spell_guessing_enabled=",
|
1222
|
-
rlink_parseopts_set_spell_guess, 1 );
|
1223
|
-
rb_define_method( rlink_cParseOptions, "spell_guessing_enabled?",
|
1224
|
-
rlink_parseopts_get_spell_guess_p, 0 );
|
1225
|
-
|
1226
|
-
rb_define_method( rlink_cParseOptions, "timer_expired?",
|
1227
|
-
rlink_parseopts_timer_expired_p, 0 );
|
1228
|
-
rb_define_method( rlink_cParseOptions, "memory_exhausted?",
|
1229
|
-
rlink_parseopts_memory_exhausted_p, 0 );
|
1230
|
-
rb_define_method( rlink_cParseOptions, "resources_exhausted?",
|
1231
|
-
rlink_parseopts_resources_exhausted_p, 0 );
|
1232
|
-
rb_define_method( rlink_cParseOptions, "reset_resources",
|
1233
|
-
rlink_parseopts_reset_resources, 0 );
|
1234
|
-
|
1235
|
-
}
|
1236
|
-
|