linkparser 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +47 -0
- data/LICENSE +1 -1
- data/README +4 -31
- data/Rakefile +5 -6
- data/Rakefile.local +5 -0
- data/ext/extconf.rb +2 -0
- data/ext/linkage.c +2 -2
- data/ext/parseoptions.c +49 -1
- data/ext/sentence.c +33 -3
- data/lib/linkparser.rb +4 -4
- data/lib/linkparser/sentence.rb +24 -18
- data/rake/191_compat.rb +26 -0
- data/rake/helpers.rb +60 -43
- data/rake/manual.rb +42 -15
- data/rake/packaging.rb +27 -6
- data/rake/publishing.rb +78 -65
- data/rake/rdoc.rb +5 -12
- data/rake/svn.rb +50 -12
- data/rake/testing.rb +2 -1
- data/rake/win32.rb +186 -0
- data/spec/linkparser/parseoptions_spec.rb +15 -1
- data/spec/linkparser/sentence_spec.rb +31 -6
- metadata +15 -6
data/ChangeLog
CHANGED
@@ -1,3 +1,50 @@
|
|
1
|
+
-- Tue, 09 Jun 2009 06:21:42 -0000 by deveiant (r55) -----
|
2
|
+
Changed: README
|
3
|
+
INSTALL
|
4
|
+
ChangeLog
|
5
|
+
|
6
|
+
* Updated versions of the link-grammar library referenced in the docs.
|
7
|
+
|
8
|
+
|
9
|
+
-- Wed, 03 Jun 2009 14:29:26 -0000 by deveiant (r54) -----
|
10
|
+
Deleted: link-grammar-4.4.3.tar.gz
|
11
|
+
|
12
|
+
Removing old link-grammar library
|
13
|
+
|
14
|
+
|
15
|
+
-- Wed, 03 Jun 2009 12:52:13 -0000 by deveiant (r53) -----
|
16
|
+
Added: link-grammar-4.5.6.tar.gz
|
17
|
+
-> renamed from /trunk/link-grammar-4.4.1.tar.gz@r51
|
18
|
+
Changed: lib/linkparser.rb
|
19
|
+
spec/linkparser/sentence_spec.rb
|
20
|
+
ext/sentence.c
|
21
|
+
lib/linkparser/sentence.rb
|
22
|
+
spec/linkparser/parseoptions_spec.rb
|
23
|
+
ChangeLog (and 5 other/s)
|
24
|
+
|
25
|
+
* Updated to link-grammar-4.5.6.
|
26
|
+
* Added support for ParseOptions#spell_guessing_enabled
|
27
|
+
* Fixed buggy sentence behavior when the underlying Sentence hadn't yet been parsed.
|
28
|
+
* Made the exception raised when a delegated linkage method is called on a Sentence
|
29
|
+
that doesn't have any linkages. Thanks to Michael Bisignani <mbisignani@gmail.com> for
|
30
|
+
bringing this problem to my attention.
|
31
|
+
* Fixed some type-qualifier warnings.
|
32
|
+
* Bumped version to 1.0.4.
|
33
|
+
|
34
|
+
|
35
|
+
-- Wed, 18 Mar 2009 21:51:03 -0000 by deveiant (r52) -----
|
36
|
+
Added: link-grammar-4.4.3.tar.gz
|
37
|
+
-> renamed from /trunk/link-grammar-4.4.1.tar.gz@r51
|
38
|
+
Changed: README
|
39
|
+
LICENSE
|
40
|
+
Rakefile
|
41
|
+
project.yml
|
42
|
+
Deleted: link-grammar-4.4.1.tar.gz
|
43
|
+
|
44
|
+
* Update license year.
|
45
|
+
* Updated build.
|
46
|
+
|
47
|
+
|
1
48
|
-- Sat, 20 Dec 2008 19:51:24 -0000 by deveiant (r49) -----
|
2
49
|
Changed: Rakefile
|
3
50
|
project.yml
|
data/LICENSE
CHANGED
data/README
CHANGED
@@ -12,7 +12,7 @@ of English.
|
|
12
12
|
== Requirements
|
13
13
|
|
14
14
|
* Ruby 1.8.6
|
15
|
-
* link-grammar (version 4.
|
15
|
+
* link-grammar (version 4.5.6 or later) from the AbiWord project
|
16
16
|
(http://www.abisource.com/projects/link-grammar/)
|
17
17
|
|
18
18
|
|
@@ -51,38 +51,11 @@ of English.
|
|
51
51
|
|
52
52
|
== Legal
|
53
53
|
|
54
|
+
For licensing information, see the LICENSE file.
|
55
|
+
|
54
56
|
For copyright and licensing information for link-grammar itself, see the
|
55
57
|
LICENSE file in that distribution.
|
56
58
|
|
57
|
-
|
58
|
-
All rights reserved.
|
59
|
-
|
60
|
-
Redistribution and use in source and binary forms, with or without
|
61
|
-
modification, are permitted provided that the following conditions are met:
|
62
|
-
|
63
|
-
* Redistributions of source code must retain the above copyright notice,
|
64
|
-
this list of conditions and the following disclaimer.
|
65
|
-
|
66
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
67
|
-
this list of conditions and the following disclaimer in the documentation
|
68
|
-
and/or other materials provided with the distribution.
|
69
|
-
|
70
|
-
* Neither the name of the author/s, nor the names of the project's
|
71
|
-
contributors may be used to endorse or promote products derived from this
|
72
|
-
software without specific prior written permission.
|
73
|
-
|
74
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
75
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
76
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
77
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
78
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
79
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
80
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
81
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
82
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
83
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
84
|
-
|
85
|
-
|
86
|
-
$Id: README 48 2008-12-19 18:30:33Z deveiant $
|
59
|
+
$Id: README 55 2009-06-09 06:21:42Z deveiant $
|
87
60
|
|
88
61
|
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Based on various other Rakefiles, especially one by Ben Bleything
|
6
6
|
#
|
7
|
-
# Copyright (c)
|
7
|
+
# Copyright (c) 2007-2009 The FaerieMUD Consortium
|
8
8
|
#
|
9
9
|
# Authors:
|
10
10
|
# * Michael Granger <ged@FaerieMUD.org>
|
@@ -21,15 +21,13 @@ BEGIN {
|
|
21
21
|
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
|
22
22
|
}
|
23
23
|
|
24
|
-
require 'rubygems'
|
25
|
-
gem 'rake', '>= 0.8.3'
|
26
|
-
|
27
24
|
require 'rbconfig'
|
28
25
|
require 'rake'
|
29
26
|
require 'rake/rdoctask'
|
30
27
|
require 'rake/testtask'
|
31
28
|
require 'rake/packagetask'
|
32
29
|
require 'rake/clean'
|
30
|
+
require 'rake/191_compat.rb'
|
33
31
|
|
34
32
|
$dryrun = false
|
35
33
|
|
@@ -174,7 +172,7 @@ DEVELOPMENT_DEPENDENCIES = {
|
|
174
172
|
|
175
173
|
# Non-gem requirements: packagename => version
|
176
174
|
REQUIREMENTS = {
|
177
|
-
'link-grammar' => '>= 4.4.
|
175
|
+
'link-grammar' => '>= 4.4.2',
|
178
176
|
}
|
179
177
|
|
180
178
|
# RubyGem specification
|
@@ -242,7 +240,8 @@ $dryrun = Rake.application.options.dryrun ? true : false
|
|
242
240
|
RAKE_TASKLIBS.each do |tasklib|
|
243
241
|
next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$}
|
244
242
|
begin
|
245
|
-
|
243
|
+
trace " loading tasklib %s" % [ tasklib ]
|
244
|
+
require tasklib.expand_path
|
246
245
|
rescue ScriptError => err
|
247
246
|
fail "Task library '%s' failed to load: %s: %s" %
|
248
247
|
[ tasklib, err.class.name, err.message ]
|
data/Rakefile.local
CHANGED
data/ext/extconf.rb
CHANGED
data/ext/linkage.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* linkage.c - Ruby LinkParser Linkage class
|
3
|
-
* $Id: linkage.c
|
3
|
+
* $Id: linkage.c 53 2009-06-03 12:52:13Z deveiant $
|
4
4
|
*
|
5
5
|
* Authors:
|
6
6
|
* * Michael Granger <ged@FaerieMUD.org>
|
@@ -470,7 +470,7 @@ rlink_linkage_get_link_num_domains( VALUE self, VALUE index ) {
|
|
470
470
|
static VALUE
|
471
471
|
rlink_linkage_get_link_domain_names( VALUE self, VALUE index ) {
|
472
472
|
rlink_LINKAGE *ptr = get_linkage( self );
|
473
|
-
char **names;
|
473
|
+
const char **names;
|
474
474
|
int i = NUM2INT( index );
|
475
475
|
int count;
|
476
476
|
VALUE names_ary;
|
data/ext/parseoptions.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* parseoptions.c - Ruby LinkParser::ParseOptions class
|
3
|
-
* $Id: parseoptions.c
|
3
|
+
* $Id: parseoptions.c 53 2009-06-03 12:52:13Z deveiant $
|
4
4
|
*
|
5
5
|
* Authors:
|
6
6
|
* * Michael Granger <ged@FaerieMUD.org>
|
@@ -972,6 +972,49 @@ rlink_parseopts_get_echo_on_p( VALUE self ) {
|
|
972
972
|
}
|
973
973
|
|
974
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
|
+
|
975
1018
|
/*
|
976
1019
|
* call-seq:
|
977
1020
|
* opts.timer_expired? -> +true+ or +false+
|
@@ -1175,6 +1218,10 @@ rlink_init_parseoptions() {
|
|
1175
1218
|
rlink_parseopts_set_echo_on, 1 );
|
1176
1219
|
rb_define_method( rlink_cParseOptions, "echo_on?",
|
1177
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 );
|
1178
1225
|
|
1179
1226
|
rb_define_method( rlink_cParseOptions, "timer_expired?",
|
1180
1227
|
rlink_parseopts_timer_expired_p, 0 );
|
@@ -1184,5 +1231,6 @@ rlink_init_parseoptions() {
|
|
1184
1231
|
rlink_parseopts_resources_exhausted_p, 0 );
|
1185
1232
|
rb_define_method( rlink_cParseOptions, "reset_resources",
|
1186
1233
|
rlink_parseopts_reset_resources, 0 );
|
1234
|
+
|
1187
1235
|
}
|
1188
1236
|
|
data/ext/sentence.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* sentence.c - Ruby LinkParser
|
3
|
-
* $Id: sentence.c
|
3
|
+
* $Id: sentence.c 53 2009-06-03 12:52:13Z deveiant $
|
4
4
|
*
|
5
5
|
* Authors:
|
6
6
|
* * Michael Granger <ged@FaerieMUD.org>
|
@@ -201,8 +201,11 @@ rlink_sentence_parse( int argc, VALUE *argv, VALUE self ) {
|
|
201
201
|
VALUE options = Qnil;
|
202
202
|
int link_count = 0;
|
203
203
|
|
204
|
+
/*
|
204
205
|
if ( RTEST(ptr->parsed_p) )
|
205
206
|
rb_raise( rlink_eLpError, "Can't reparse a sentence." );
|
207
|
+
*/
|
208
|
+
debugMsg(( "Parsing sentence <%p>", ptr ));
|
206
209
|
|
207
210
|
/* Merge the hash from this call with the one from the dict and build
|
208
211
|
Parse_Options from it. */
|
@@ -307,6 +310,10 @@ rlink_sentence_linkages( VALUE self ) {
|
|
307
310
|
static VALUE
|
308
311
|
rlink_sentence_length( VALUE self ) {
|
309
312
|
rlink_SENTENCE *ptr = get_sentence( self );
|
313
|
+
|
314
|
+
if ( !RTEST(ptr->parsed_p) )
|
315
|
+
rlink_sentence_parse( 0, 0, self );
|
316
|
+
|
310
317
|
return INT2FIX( sentence_length((Sentence)ptr->sentence) );
|
311
318
|
}
|
312
319
|
|
@@ -321,8 +328,11 @@ rlink_sentence_length( VALUE self ) {
|
|
321
328
|
static VALUE
|
322
329
|
rlink_sentence_word( VALUE self, VALUE n ) {
|
323
330
|
rlink_SENTENCE *ptr = get_sentence( self );
|
324
|
-
char *word;
|
331
|
+
const char *word;
|
325
332
|
|
333
|
+
if ( !RTEST(ptr->parsed_p) )
|
334
|
+
rlink_sentence_parse( 0, 0, self );
|
335
|
+
|
326
336
|
word = sentence_get_word( (Sentence)ptr->sentence, FIX2INT(n) );
|
327
337
|
return rb_str_new2( word );
|
328
338
|
}
|
@@ -340,13 +350,17 @@ rlink_sentence_word( VALUE self, VALUE n ) {
|
|
340
350
|
static VALUE
|
341
351
|
rlink_sentence_words( VALUE self ) {
|
342
352
|
rlink_SENTENCE *ptr = get_sentence( self );
|
343
|
-
char *word;
|
353
|
+
const char *word;
|
344
354
|
int i, length;
|
345
355
|
VALUE words = rb_ary_new();
|
346
356
|
|
357
|
+
if ( !RTEST(ptr->parsed_p) )
|
358
|
+
rlink_sentence_parse( 0, 0, self );
|
359
|
+
|
347
360
|
length = sentence_length( (Sentence)ptr->sentence );
|
348
361
|
for ( i = 0; i < length; i++ ) {
|
349
362
|
word = sentence_get_word( (Sentence)ptr->sentence, i );
|
363
|
+
debugMsg(( "Word %d: <%s>", i, word ));
|
350
364
|
rb_ary_push( words, rb_str_new2(word) );
|
351
365
|
}
|
352
366
|
|
@@ -395,6 +409,9 @@ rlink_sentence_null_count( VALUE self ) {
|
|
395
409
|
rlink_SENTENCE *ptr = get_sentence( self );
|
396
410
|
int count;
|
397
411
|
|
412
|
+
if ( !RTEST(ptr->parsed_p) )
|
413
|
+
rlink_sentence_parse( 0, 0, self );
|
414
|
+
|
398
415
|
count = sentence_null_count( (Sentence)ptr->sentence );
|
399
416
|
return INT2FIX( count );
|
400
417
|
}
|
@@ -414,6 +431,7 @@ rlink_sentence_num_linkages_found( VALUE self ) {
|
|
414
431
|
|
415
432
|
if ( !RTEST(ptr->parsed_p) )
|
416
433
|
rlink_sentence_parse( 0, 0, self );
|
434
|
+
|
417
435
|
i = sentence_num_linkages_found( (Sentence)ptr->sentence );
|
418
436
|
|
419
437
|
return INT2FIX( i );
|
@@ -431,6 +449,9 @@ rlink_sentence_num_valid_linkages( VALUE self ) {
|
|
431
449
|
rlink_SENTENCE *ptr = get_sentence( self );
|
432
450
|
int count;
|
433
451
|
|
452
|
+
if ( !RTEST(ptr->parsed_p) )
|
453
|
+
rlink_sentence_parse( 0, 0, self );
|
454
|
+
|
434
455
|
count = sentence_num_valid_linkages( (Sentence)ptr->sentence );
|
435
456
|
return INT2FIX( count );
|
436
457
|
}
|
@@ -448,6 +469,9 @@ rlink_sentence_num_linkages_post_processed( VALUE self ) {
|
|
448
469
|
rlink_SENTENCE *ptr = get_sentence( self );
|
449
470
|
int count;
|
450
471
|
|
472
|
+
if ( !RTEST(ptr->parsed_p) )
|
473
|
+
rlink_sentence_parse( 0, 0, self );
|
474
|
+
|
451
475
|
count = sentence_num_linkages_post_processed( (Sentence)ptr->sentence );
|
452
476
|
return INT2FIX( count );
|
453
477
|
}
|
@@ -465,6 +489,9 @@ rlink_sentence_num_violations( VALUE self, VALUE i ) {
|
|
465
489
|
rlink_SENTENCE *ptr = get_sentence( self );
|
466
490
|
int count;
|
467
491
|
|
492
|
+
if ( !RTEST(ptr->parsed_p) )
|
493
|
+
rlink_sentence_parse( 0, 0, self );
|
494
|
+
|
468
495
|
count = sentence_num_violations( (Sentence)ptr->sentence, FIX2INT(i) );
|
469
496
|
return INT2FIX( count );
|
470
497
|
}
|
@@ -481,6 +508,9 @@ rlink_sentence_disjunct_cost( VALUE self, VALUE i ) {
|
|
481
508
|
rlink_SENTENCE *ptr = get_sentence( self );
|
482
509
|
int count;
|
483
510
|
|
511
|
+
if ( !RTEST(ptr->parsed_p) )
|
512
|
+
rlink_sentence_parse( 0, 0, self );
|
513
|
+
|
484
514
|
count = sentence_disjunct_cost( (Sentence)ptr->sentence, FIX2INT(i) );
|
485
515
|
return INT2FIX( count );
|
486
516
|
}
|
data/lib/linkparser.rb
CHANGED
@@ -12,7 +12,7 @@ require 'linkparser_ext'
|
|
12
12
|
#
|
13
13
|
# == Version
|
14
14
|
#
|
15
|
-
# $Id: linkparser.rb
|
15
|
+
# $Id: linkparser.rb 53 2009-06-03 12:52:13Z deveiant $
|
16
16
|
#
|
17
17
|
# == License
|
18
18
|
#
|
@@ -26,13 +26,13 @@ module LinkParser
|
|
26
26
|
require 'linkparser/linkage'
|
27
27
|
|
28
28
|
# Release version
|
29
|
-
VERSION = '1.0.
|
29
|
+
VERSION = '1.0.4'
|
30
30
|
|
31
31
|
# SVN Revision
|
32
|
-
SVNRev = %q$Rev:
|
32
|
+
SVNRev = %q$Rev: 53 $
|
33
33
|
|
34
34
|
# SVN Id
|
35
|
-
SVNId = %q$Id: linkparser.rb
|
35
|
+
SVNId = %q$Id: linkparser.rb 53 2009-06-03 12:52:13Z deveiant $
|
36
36
|
|
37
37
|
end # class LinkParser
|
38
38
|
|
data/lib/linkparser/sentence.rb
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
#
|
34
34
|
# == Version
|
35
35
|
#
|
36
|
-
# $Id: sentence.rb
|
36
|
+
# $Id: sentence.rb 53 2009-06-03 12:52:13Z deveiant $
|
37
37
|
#
|
38
38
|
|
39
39
|
require 'linkparser'
|
@@ -42,10 +42,11 @@ require 'linkparser'
|
|
42
42
|
class LinkParser::Sentence
|
43
43
|
|
44
44
|
# SVN Revision
|
45
|
-
SVNRev = %q$Rev:
|
45
|
+
SVNRev = %q$Rev: 53 $
|
46
46
|
|
47
47
|
# SVN Id
|
48
|
-
SVNId = %q$Id: sentence.rb
|
48
|
+
SVNId = %q$Id: sentence.rb 53 2009-06-03 12:52:13Z deveiant $
|
49
|
+
|
49
50
|
|
50
51
|
|
51
52
|
######
|
@@ -54,25 +55,25 @@ class LinkParser::Sentence
|
|
54
55
|
|
55
56
|
### Return a human-readable representation of the Sentence object.
|
56
57
|
def inspect
|
57
|
-
|
58
|
+
contents = ''
|
59
|
+
if self.parsed?
|
60
|
+
contents = %{"%s"/%d linkages/%d nulls} % [
|
61
|
+
self.to_s,
|
62
|
+
self.num_linkages_found,
|
63
|
+
self.null_count,
|
64
|
+
]
|
65
|
+
else
|
66
|
+
contents = "(unparsed)"
|
67
|
+
end
|
68
|
+
|
69
|
+
return "#<%s:0x%x %s>" % [
|
58
70
|
self.class.name,
|
59
71
|
self.object_id / 2,
|
60
|
-
|
61
|
-
self.num_linkages_found,
|
62
|
-
self.null_count,
|
72
|
+
contents,
|
63
73
|
]
|
64
74
|
end
|
65
75
|
|
66
76
|
|
67
|
-
### Return the Array of words in the sentence as tokenized by the
|
68
|
-
### parser.
|
69
|
-
def words
|
70
|
-
(0...self.length).to_a.collect do |i|
|
71
|
-
self.word( i )
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
77
|
### Print out the sentence
|
77
78
|
def to_s
|
78
79
|
return self.words.join(" ")
|
@@ -91,8 +92,13 @@ class LinkParser::Sentence
|
|
91
92
|
|
92
93
|
### Proxy method -- auto-delegate calls to the first linkage.
|
93
94
|
def method_missing( sym, *args )
|
94
|
-
|
95
|
-
|
95
|
+
|
96
|
+
# Check both symbol and string for forward-compatibility with 1.9.x
|
97
|
+
return super unless
|
98
|
+
LinkParser::Linkage.instance_methods.include?( sym.to_s ) ||
|
99
|
+
LinkParser::Linkage.instance_methods.include?( sym )
|
100
|
+
|
101
|
+
linkage = self.linkages.first or raise LinkParser::Error, "sentence has no linkages"
|
96
102
|
|
97
103
|
meth = linkage.method( sym )
|
98
104
|
self.singleton_class.send( :define_method, sym, &meth )
|