linkparser 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ext/linkparser.c ADDED
@@ -0,0 +1,120 @@
1
+ /*
2
+ * linkparser.c - Ruby LinkParser
3
+ * $Id: linkparser.c 48 2008-12-19 18:30:33Z deveiant $
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
+ * Globals
16
+ */
17
+
18
+ VALUE rlink_mLinkParser;
19
+
20
+ VALUE rlink_eLpError;
21
+
22
+ VALUE rlink_cDictionary;
23
+ VALUE rlink_cSentence;
24
+ VALUE rlink_cLinkage;
25
+ VALUE rlink_cParseOptions;
26
+
27
+ VALUE rlink_sLinkageCTree;
28
+
29
+
30
+ /* --------------------------------------------------
31
+ * Utility functions
32
+ * -------------------------------------------------- */
33
+
34
+ void
35
+ #ifdef HAVE_STDARG_PROTOTYPES
36
+ rlink_debug(const char *fmt, ...)
37
+ #else
38
+ rlink_debug(fmt, va_alist)
39
+ const char *fmt;
40
+ va_dcl
41
+ #endif
42
+ {
43
+ char buf[BUFSIZ], buf2[BUFSIZ];
44
+ va_list args;
45
+
46
+ if (!RTEST(ruby_debug)) return;
47
+
48
+ snprintf( buf, BUFSIZ, "LinkParser Debug>>> %s", fmt );
49
+
50
+ va_init_list( args, fmt );
51
+ vsnprintf( buf2, BUFSIZ, buf, args );
52
+ fputs( buf2, stderr );
53
+ fputs( "\n", stderr );
54
+ fflush( stderr );
55
+ va_end( args );
56
+ }
57
+
58
+
59
+ /*
60
+ * Raise a LinkParser::Error. The link-grammar library no longer supports fetching the actual
61
+ * error message, so this just raises an exception with "Unknown error" now. Hopefully the
62
+ * library will have printed out the actual problem to stderr, and stderr is pointed
63
+ * somewhere useful.
64
+ */
65
+ void
66
+ rlink_raise_lp_error() {
67
+ rb_raise( rlink_eLpError, "Unknown error" );
68
+ }
69
+
70
+
71
+ /* Make a Parse_Options after merging the specified default_options with any
72
+ new options given. */
73
+ VALUE
74
+ rlink_make_parse_options( VALUE default_options, VALUE options ) {
75
+ if ( NIL_P(options) ) options = rb_hash_new();
76
+ options = rb_funcall( default_options, rb_intern("merge"), 1, options );
77
+
78
+ return rb_class_new_instance( 1, &options, rlink_cParseOptions );
79
+ }
80
+
81
+
82
+ /*
83
+ * call-seq:
84
+ * LinkParser.link_grammar_version -> string
85
+ *
86
+ * Return the version of the link-grammar library the binding is linked against.
87
+ *
88
+ */
89
+ static VALUE
90
+ rlink_link_grammar_version( VALUE self ) {
91
+ #ifdef HAVE_LINKGRAMMAR_GET_VERSION
92
+ const char *version = linkgrammar_get_version();
93
+ return rb_str_new2( version );
94
+ #else
95
+ return rb_str_new2( "link-grammar-4.3.9-or-earlier" );
96
+ #endif /* HAVE_LINKGRAMMAR_GET_VERSION */
97
+ }
98
+
99
+
100
+ /*
101
+ * LinkParser extension init function
102
+ */
103
+ void
104
+ Init_linkparser_ext() {
105
+ rlink_mLinkParser = rb_define_module( "LinkParser" );
106
+
107
+ /* The exception class used for LinkParser errors */
108
+ rlink_eLpError = rb_define_class_under( rlink_mLinkParser, "Error", rb_eRuntimeError );
109
+
110
+ rb_define_singleton_method( rlink_mLinkParser, "link_grammar_version",
111
+ rlink_link_grammar_version, 0 );
112
+
113
+ setlocale( LC_ALL, "" );
114
+
115
+ rlink_init_dict();
116
+ rlink_init_sentence();
117
+ rlink_init_linkage();
118
+ rlink_init_parseoptions();
119
+ }
120
+
data/ext/linkparser.h ADDED
@@ -0,0 +1,112 @@
1
+ /*
2
+ * linkparser.h - Ruby-LinkParser Header
3
+ * $Id: linkparser.h 39 2008-11-18 16:18:11Z deveiant $
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
+
13
+ #ifndef _R_LINKPARSER_H
14
+ #define _R_LINKPARSER_H
15
+
16
+ #include <locale.h>
17
+ #include <stdlib.h>
18
+ #include <stdio.h>
19
+
20
+ #include <ruby.h>
21
+ #include <intern.h> /* For rb_dbl2big() */
22
+
23
+ #include <link-grammar/link-includes.h>
24
+
25
+
26
+
27
+ /* Debugging functions/macros */
28
+ #ifdef HAVE_STDARG_PROTOTYPES
29
+ #include <stdarg.h>
30
+ #define va_init_list(a,b) va_start(a,b)
31
+ extern void rlink_debug(const char *fmt, ...);
32
+ #else
33
+ #include <varargs.h>
34
+ #define va_init_list(a,b) va_start(a)
35
+ extern void rlink_debug(fmt, va_alist);
36
+ #endif
37
+
38
+ extern void rlink_raise_lp_error _(( void ));
39
+ extern VALUE rlink_make_parse_options _(( VALUE, VALUE ));
40
+
41
+
42
+ /* -------------------------------------------------------
43
+ * Globals
44
+ * ------------------------------------------------------- */
45
+
46
+ /*
47
+ * Modules
48
+ */
49
+ extern VALUE rlink_mLinkParser;
50
+
51
+ extern VALUE rlink_cDictionary;
52
+ extern VALUE rlink_cSentence;
53
+ extern VALUE rlink_cLinkage;
54
+ extern VALUE rlink_cParseOptions;
55
+ extern VALUE rlink_cPostProcessor;
56
+ extern VALUE rlink_cConstituentTree;
57
+
58
+ extern VALUE rlink_sLinkageCTree;
59
+
60
+ extern VALUE rlink_eLpError;
61
+
62
+
63
+ /*
64
+ * Structures
65
+ */
66
+ typedef struct {
67
+ Sentence sentence;
68
+ VALUE dictionary;
69
+ VALUE parsed_p;
70
+ VALUE options;
71
+ } rlink_SENTENCE;
72
+
73
+ typedef struct {
74
+ Linkage linkage;
75
+ VALUE sentence;
76
+ } rlink_LINKAGE;
77
+
78
+
79
+
80
+ /*
81
+ * Macros
82
+ */
83
+
84
+ /* Debugging macro */
85
+ #if DEBUG
86
+ # define debugMsg(f) rlink_debug f
87
+ #else /* ! DEBUG */
88
+ # define debugMsg(f)
89
+ #endif /* DEBUG */
90
+
91
+
92
+ #define IsDictionary( obj ) rb_obj_is_kind_of( (obj), rlink_cDictionary )
93
+ #define IsSentence( obj ) rb_obj_is_kind_of( (obj), rlink_cSentence )
94
+ #define IsLinkage( obj ) rb_obj_is_kind_of( (obj), rlink_cLinkage )
95
+ #define IsParseOptions( obj ) rb_obj_is_kind_of( (obj), rlink_cParseOptions )
96
+
97
+
98
+ /* -------------------------------------------------------
99
+ * Initializer functions
100
+ * ------------------------------------------------------- */
101
+ extern void rlink_init_dict _(( void ));
102
+ extern void rlink_init_sentence _(( void ));
103
+ extern void rlink_init_linkage _(( void ));
104
+ extern void rlink_init_parseoptions _(( void ));
105
+
106
+ /* Fetchers */
107
+ extern Dictionary rlink_get_dict _(( VALUE ));
108
+ extern rlink_SENTENCE *rlink_get_sentence _(( VALUE ));
109
+ extern Parse_Options rlink_get_parseopts _(( VALUE ));
110
+
111
+ #endif /* _R_LINKPARSER_H */
112
+
@@ -0,0 +1,1188 @@
1
+ /*
2
+ * parseoptions.c - Ruby LinkParser::ParseOptions class
3
+ * $Id: parseoptions.c 48 2008-12-19 18:30:33Z deveiant $
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(keystring)->len + 1 );
152
+ strncpy( method_name, RSTRING(keystring)->ptr, RSTRING(keystring)->len + 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
+ * call-seq:
977
+ * opts.timer_expired? -> +true+ or +false+
978
+ *
979
+ * Returns true if timer constraints were exceeded during parsing.
980
+ *
981
+ * sentence.parse
982
+ * if sentence.options.timer_expired?
983
+ * $stderr.puts "Parsing sentence #{sentence} timed out."
984
+ * end
985
+ */
986
+ static VALUE
987
+ rlink_parseopts_timer_expired_p( VALUE self ) {
988
+ Parse_Options opts = get_parseopts( self );
989
+ int rval;
990
+
991
+ rval = parse_options_timer_expired( opts );
992
+ return rval ? Qtrue : Qfalse;
993
+ }
994
+
995
+
996
+ /*
997
+ * call-seq:
998
+ * opts.memory_exhausted? -> +true+ or +false+
999
+ *
1000
+ * Returns true if memory constraints were exceeded during parsing.
1001
+ *
1002
+ * sentence.parse
1003
+ * if sentence.options.memory_exhausted?
1004
+ * $stderr.puts "Parsing sentence #{sentence} ran out of memory."
1005
+ * end
1006
+ */
1007
+ static VALUE
1008
+ rlink_parseopts_memory_exhausted_p( VALUE self ) {
1009
+ Parse_Options opts = get_parseopts( self );
1010
+ int rval;
1011
+
1012
+ rval = parse_options_memory_exhausted( opts );
1013
+ return rval ? Qtrue : Qfalse;
1014
+ }
1015
+
1016
+
1017
+ /*
1018
+ * call-seq:
1019
+ * opts.resources_exhausted? -> +true+ or +false+
1020
+ *
1021
+ * Returns true if the memory or timer constraints were exceeded during parsing.
1022
+ *
1023
+ * sentence.parse
1024
+ * if sentence.options.resources_exhausted?
1025
+ * $stderr.puts "Parsing sentence #{sentence} ran out of resources."
1026
+ * end
1027
+ */
1028
+ static VALUE
1029
+ rlink_parseopts_resources_exhausted_p( VALUE self ) {
1030
+ Parse_Options opts = get_parseopts( self );
1031
+ int rval;
1032
+
1033
+ rval = parse_options_resources_exhausted( opts );
1034
+ return rval ? Qtrue : Qfalse;
1035
+ }
1036
+
1037
+
1038
+ /*
1039
+ * call-seq:
1040
+ * opts.reset_resources
1041
+ *
1042
+ * Reset the timer- and memory-constraint flags.
1043
+ *
1044
+ */
1045
+ static VALUE
1046
+ rlink_parseopts_reset_resources( VALUE self ) {
1047
+ Parse_Options opts = get_parseopts( self );
1048
+
1049
+ parse_options_reset_resources( opts );
1050
+ return Qnil;
1051
+ }
1052
+
1053
+
1054
+
1055
+ /*
1056
+ * LinkParser parse options class. Instances of this class are used to specify the different
1057
+ * parameters that are used to parse sentences. Examples of the kinds of things that are
1058
+ * controlled by ParseOptions include maximum parsing time and memory, whether to use
1059
+ * null-links, and whether or not to use "panic" mode. This data structure is passed in to
1060
+ * the various parsing and printing routines along with the sentence.
1061
+ *
1062
+ */
1063
+ void
1064
+ rlink_init_parseoptions() {
1065
+ rlink_cParseOptions = rb_define_class_under( rlink_mLinkParser,
1066
+ "ParseOptions", rb_cObject );
1067
+
1068
+ rb_define_alloc_func( rlink_cParseOptions, rlink_parseopts_s_alloc );
1069
+ rb_define_method( rlink_cParseOptions, "initialize", rlink_parseopts_init, -1 );
1070
+ /*
1071
+ rb_define_method( rlink_cParseOptions, "merge", rlink_parseopts_merge, 1 );
1072
+ rb_define_method( rlink_cParseOptions, "merge!", rlink_parseopts_merge_bang, 1 );
1073
+ */
1074
+ rb_define_method( rlink_cParseOptions, "verbosity=",
1075
+ rlink_parseopts_set_verbosity, 1 );
1076
+ rb_define_method( rlink_cParseOptions, "verbosity",
1077
+ rlink_parseopts_get_verbosity, 0 );
1078
+ rb_define_method( rlink_cParseOptions, "linkage_limit=",
1079
+ rlink_parseopts_set_linkage_limit, 1 );
1080
+ rb_define_method( rlink_cParseOptions, "linkage_limit",
1081
+ rlink_parseopts_get_linkage_limit, 0 );
1082
+ rb_define_method( rlink_cParseOptions, "disjunct_cost=",
1083
+ rlink_parseopts_set_disjunct_cost, 1 );
1084
+ rb_define_method( rlink_cParseOptions, "disjunct_cost",
1085
+ rlink_parseopts_get_disjunct_cost, 0 );
1086
+ rb_define_method( rlink_cParseOptions, "min_null_count=",
1087
+ rlink_parseopts_set_min_null_count, 1 );
1088
+ rb_define_method( rlink_cParseOptions, "min_null_count",
1089
+ rlink_parseopts_get_min_null_count, 0 );
1090
+ rb_define_method( rlink_cParseOptions, "max_null_count=",
1091
+ rlink_parseopts_set_max_null_count, 1 );
1092
+ rb_define_method( rlink_cParseOptions, "max_null_count",
1093
+ rlink_parseopts_get_max_null_count, 0 );
1094
+ rb_define_method( rlink_cParseOptions, "null_block=",
1095
+ rlink_parseopts_set_null_block, 1 );
1096
+ rb_define_method( rlink_cParseOptions, "null_block",
1097
+ rlink_parseopts_get_null_block, 0 );
1098
+ rb_define_method( rlink_cParseOptions, "islands_ok=",
1099
+ rlink_parseopts_set_islands_ok, 1 );
1100
+ rb_define_method( rlink_cParseOptions, "islands_ok?",
1101
+ rlink_parseopts_get_islands_ok_p, 0 );
1102
+ rb_define_method( rlink_cParseOptions, "short_length=",
1103
+ rlink_parseopts_set_short_length, 1 );
1104
+ rb_define_method( rlink_cParseOptions, "short_length",
1105
+ rlink_parseopts_get_short_length, 0 );
1106
+ rb_define_method( rlink_cParseOptions, "max_memory=",
1107
+ rlink_parseopts_set_max_memory, 1 );
1108
+ rb_define_method( rlink_cParseOptions, "max_memory",
1109
+ rlink_parseopts_get_max_memory, 0 );
1110
+ rb_define_method( rlink_cParseOptions, "max_sentence_length=",
1111
+ rlink_parseopts_set_max_sentence_length, 1 );
1112
+ rb_define_method( rlink_cParseOptions, "max_sentence_length",
1113
+ rlink_parseopts_get_max_sentence_length, 0 );
1114
+ rb_define_method( rlink_cParseOptions, "max_parse_time=",
1115
+ rlink_parseopts_set_max_parse_time, 1 );
1116
+ rb_define_method( rlink_cParseOptions, "max_parse_time",
1117
+ rlink_parseopts_get_max_parse_time, 0 );
1118
+ rb_define_method( rlink_cParseOptions, "screen_width=",
1119
+ rlink_parseopts_set_screen_width, 1 );
1120
+ rb_define_method( rlink_cParseOptions, "screen_width",
1121
+ rlink_parseopts_get_screen_width, 0 );
1122
+ rb_define_method( rlink_cParseOptions, "allow_null=",
1123
+ rlink_parseopts_set_allow_null, 1 );
1124
+ rb_define_method( rlink_cParseOptions, "allow_null?",
1125
+ rlink_parseopts_get_allow_null_p, 0 );
1126
+ rb_define_method( rlink_cParseOptions, "display_walls=",
1127
+ rlink_parseopts_set_display_walls, 1 );
1128
+ rb_define_method( rlink_cParseOptions, "display_walls?",
1129
+ rlink_parseopts_get_display_walls_p, 0 );
1130
+ rb_define_method( rlink_cParseOptions, "all_short_connectors=",
1131
+ rlink_parseopts_set_all_short_connectors, 1 );
1132
+ rb_define_method( rlink_cParseOptions, "all_short_connectors?",
1133
+ rlink_parseopts_get_all_short_connectors_p, 0 );
1134
+ rb_define_method( rlink_cParseOptions, "cost_model_type=",
1135
+ rlink_parseopts_set_cost_model_type, 1 );
1136
+
1137
+ /* (No way to get the cost_model_type from the API)
1138
+
1139
+ rb_define_method( rlink_cParseOptions, "cost_model_type",
1140
+ rlink_parseopts_get_cost_model_type, 0 );
1141
+ */
1142
+ rb_define_method( rlink_cParseOptions, "batch_mode=",
1143
+ rlink_parseopts_set_batch_mode, 1 );
1144
+ rb_define_method( rlink_cParseOptions, "batch_mode?",
1145
+ rlink_parseopts_get_batch_mode_p, 0 );
1146
+ rb_define_method( rlink_cParseOptions, "panic_mode=",
1147
+ rlink_parseopts_set_panic_mode, 1 );
1148
+ rb_define_method( rlink_cParseOptions, "panic_mode?",
1149
+ rlink_parseopts_get_panic_mode_p, 0 );
1150
+ rb_define_method( rlink_cParseOptions, "display_on=",
1151
+ rlink_parseopts_set_display_on, 1 );
1152
+ rb_define_method( rlink_cParseOptions, "display_on?",
1153
+ rlink_parseopts_get_display_on_p, 0 );
1154
+ rb_define_method( rlink_cParseOptions, "display_postscript=",
1155
+ rlink_parseopts_set_display_postscript, 1 );
1156
+ rb_define_method( rlink_cParseOptions, "display_postscript?",
1157
+ rlink_parseopts_get_display_postscript_p, 0 );
1158
+ rb_define_method( rlink_cParseOptions, "display_constituents=",
1159
+ rlink_parseopts_set_display_constituents, 1 );
1160
+ rb_define_method( rlink_cParseOptions, "display_constituents?",
1161
+ rlink_parseopts_get_display_constituents_p, 0 );
1162
+ rb_define_method( rlink_cParseOptions, "display_bad=",
1163
+ rlink_parseopts_set_display_bad, 1 );
1164
+ rb_define_method( rlink_cParseOptions, "display_bad?",
1165
+ rlink_parseopts_get_display_bad_p, 0 );
1166
+ rb_define_method( rlink_cParseOptions, "display_links=",
1167
+ rlink_parseopts_set_display_links, 1 );
1168
+ rb_define_method( rlink_cParseOptions, "display_links?",
1169
+ rlink_parseopts_get_display_links_p, 0 );
1170
+ rb_define_method( rlink_cParseOptions, "display_union=",
1171
+ rlink_parseopts_set_display_union, 1 );
1172
+ rb_define_method( rlink_cParseOptions, "display_union?",
1173
+ rlink_parseopts_get_display_union_p, 0 );
1174
+ rb_define_method( rlink_cParseOptions, "echo_on=",
1175
+ rlink_parseopts_set_echo_on, 1 );
1176
+ rb_define_method( rlink_cParseOptions, "echo_on?",
1177
+ rlink_parseopts_get_echo_on_p, 0 );
1178
+
1179
+ rb_define_method( rlink_cParseOptions, "timer_expired?",
1180
+ rlink_parseopts_timer_expired_p, 0 );
1181
+ rb_define_method( rlink_cParseOptions, "memory_exhausted?",
1182
+ rlink_parseopts_memory_exhausted_p, 0 );
1183
+ rb_define_method( rlink_cParseOptions, "resources_exhausted?",
1184
+ rlink_parseopts_resources_exhausted_p, 0 );
1185
+ rb_define_method( rlink_cParseOptions, "reset_resources",
1186
+ rlink_parseopts_reset_resources, 0 );
1187
+ }
1188
+