linguistics 1.0.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gemtest +0 -0
  3. data/ChangeLog +849 -342
  4. data/History.rdoc +11 -0
  5. data/LICENSE +9 -9
  6. data/Manifest.txt +44 -0
  7. data/README.rdoc +226 -0
  8. data/Rakefile +32 -349
  9. data/examples/endocs.rb +272 -0
  10. data/examples/generalize_sentence.rb +2 -1
  11. data/examples/klingon.rb +22 -0
  12. data/lib/linguistics.rb +130 -292
  13. data/lib/linguistics/en.rb +337 -1628
  14. data/lib/linguistics/en/articles.rb +138 -0
  15. data/lib/linguistics/en/conjugation.rb +2245 -0
  16. data/lib/linguistics/en/conjunctions.rb +202 -0
  17. data/lib/linguistics/en/{infinitive.rb → infinitives.rb} +41 -55
  18. data/lib/linguistics/en/linkparser.rb +41 -49
  19. data/lib/linguistics/en/numbers.rb +483 -0
  20. data/lib/linguistics/en/participles.rb +33 -0
  21. data/lib/linguistics/en/pluralization.rb +810 -0
  22. data/lib/linguistics/en/stemmer.rb +75 -0
  23. data/lib/linguistics/en/titlecase.rb +121 -0
  24. data/lib/linguistics/en/wordnet.rb +63 -97
  25. data/lib/linguistics/inflector.rb +89 -0
  26. data/lib/linguistics/iso639.rb +534 -448
  27. data/lib/linguistics/languagebehavior.rb +36 -0
  28. data/lib/linguistics/monkeypatches.rb +42 -0
  29. data/spec/lib/constants.rb +15 -0
  30. data/spec/lib/helpers.rb +38 -0
  31. data/spec/linguistics/en/articles_spec.rb +797 -0
  32. data/spec/linguistics/en/conjugation_spec.rb +2083 -0
  33. data/spec/linguistics/en/conjunctions_spec.rb +154 -0
  34. data/spec/linguistics/en/infinitives_spec.rb +518 -0
  35. data/spec/linguistics/en/linkparser_spec.rb +66 -0
  36. data/spec/linguistics/en/numbers_spec.rb +1295 -0
  37. data/spec/linguistics/en/participles_spec.rb +55 -0
  38. data/spec/linguistics/en/pluralization_spec.rb +4636 -0
  39. data/spec/linguistics/en/stemmer_spec.rb +72 -0
  40. data/spec/linguistics/en/titlecase_spec.rb +841 -0
  41. data/spec/linguistics/en/wordnet_spec.rb +85 -0
  42. data/spec/linguistics/en_spec.rb +45 -167
  43. data/spec/linguistics/inflector_spec.rb +40 -0
  44. data/spec/linguistics/iso639_spec.rb +49 -53
  45. data/spec/linguistics/monkeypatches_spec.rb +40 -0
  46. data/spec/linguistics_spec.rb +46 -76
  47. metadata +241 -113
  48. metadata.gz.sig +0 -0
  49. data/README +0 -166
  50. data/README.english +0 -245
  51. data/rake/191_compat.rb +0 -26
  52. data/rake/dependencies.rb +0 -76
  53. data/rake/documentation.rb +0 -123
  54. data/rake/helpers.rb +0 -502
  55. data/rake/hg.rb +0 -318
  56. data/rake/manual.rb +0 -787
  57. data/rake/packaging.rb +0 -129
  58. data/rake/publishing.rb +0 -341
  59. data/rake/style.rb +0 -62
  60. data/rake/svn.rb +0 -668
  61. data/rake/testing.rb +0 -152
  62. data/rake/verifytask.rb +0 -64
  63. data/tests/en/infinitive.tests.rb +0 -207
  64. data/tests/en/inflect.tests.rb +0 -1389
  65. data/tests/en/lafcadio.tests.rb +0 -77
  66. data/tests/en/linkparser.tests.rb +0 -42
  67. data/tests/en/lprintf.tests.rb +0 -77
  68. data/tests/en/titlecase.tests.rb +0 -73
  69. data/tests/en/wordnet.tests.rb +0 -95
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'linguistics/en' unless defined?( Linguistics::EN )
4
+
5
+ # Conjunction methods for the English-language Linguistics module.
6
+ module Linguistics::EN::Conjunctions
7
+
8
+ # Register this module to the list of modules to include
9
+ Linguistics::EN.register_extension( self )
10
+
11
+ # :stopdoc:
12
+
13
+ # Default configuration arguments for the #conjunction (junction, what's
14
+ # your) function.
15
+ CONJUNCTION_DEFAULTS = {
16
+ :separator => ', ',
17
+ :altsep => '; ',
18
+ :penultimate => true,
19
+ :conjunctive => 'and',
20
+ :combine => true,
21
+ :casefold => true,
22
+ :generalize => false,
23
+ :quantsort => true,
24
+ }
25
+
26
+
27
+ # :TODO: Needs refactoring
28
+
29
+ ### Return the specified +obj+ (which must support the <tt>#collect</tt>
30
+ ### method) as a conjunction. Each item is converted to a String if it is
31
+ ### not already (using #to_s) unless a block is given, in which case it is
32
+ ### called once for each object in the array, and the stringified return
33
+ ### value from the block is used instead. Returning +nil+ causes that
34
+ ### particular element to be omitted from the resulting conjunction. The
35
+ ### following options can be used to control the makeup of the returned
36
+ ### conjunction String:
37
+ ###
38
+ ### [<b>:separator</b>]
39
+ ### Specify one or more characters to separate items in the resulting
40
+ ### list. Defaults to <tt>', '</tt>.
41
+ ### [<b>:altsep</b>]
42
+ ### An alternate separator to use if any of the resulting conjunction's
43
+ ### clauses contain the <tt>:separator</tt> character/s. Defaults to <tt>'; '</tt>.
44
+ ### [<b>:penultimate</b>]
45
+ ### Flag that indicates whether or not to join the last clause onto the
46
+ ### rest of the conjunction using a penultimate <tt>:separator</tt>. E.g.,
47
+ ### %w{duck, cow, dog}.en.conjunction
48
+ ### # => "a duck, a cow, and a dog"
49
+ ### %w{duck cow dog}.en.conjunction( :penultimate => false )
50
+ ### "a duck, a cow and a dog"
51
+ ### Default to <tt>true</tt>.
52
+ ### [<b>:conjunctive</b>]
53
+ ### Sets the word used as the conjunctive (separating word) of the
54
+ ### resulting string. Default to <tt>'and'</tt>.
55
+ ### [<b>:combine</b>]
56
+ ### If set to <tt>true</tt> (the default), items which are indentical (after
57
+ ### surrounding spaces are stripped) will be combined in the resulting
58
+ ### conjunction. E.g.,
59
+ ### %w{goose cow goose dog}.en.conjunction
60
+ ### # => "two geese, a cow, and a dog"
61
+ ### %w{goose cow goose dog}.en.conjunction( :combine => false )
62
+ ### # => "a goose, a cow, a goose, and a dog"
63
+ ### [<b>:casefold</b>]
64
+ ### If set to <tt>true</tt> (the default), then items are compared
65
+ ### case-insensitively when combining them. This has no effect if
66
+ ### <tt>:combine</tt> is <tt>false</tt>.
67
+ ### [<b>:generalize</b>]
68
+ ### If set to <tt>true</tt>, then quantities of combined items are turned into
69
+ ### general descriptions instead of exact amounts.
70
+ ### ary = %w{goose pig dog horse goose reindeer goose dog horse}
71
+ ### ary.en.conjunction
72
+ ### # => "three geese, two dogs, two horses, a pig, and a reindeer"
73
+ ### ary.en.conjunction( :generalize => true )
74
+ ### # => "several geese, several dogs, several horses, a pig, and a reindeer"
75
+ ### See the #quantify method for specifics on how quantities are
76
+ ### generalized. Generalization defaults to <tt>false</tt>, and has no effect if
77
+ ### :combine is <tt>false</tt>.
78
+ ### [<b>:quantsort</b>]
79
+ ### If set to <tt>true</tt> (the default), items which are combined in the
80
+ ### resulting conjunction will be listed in order of amount, with greater
81
+ ### quantities sorted first. If <tt>:quantsort</tt> is <tt>false</tt>, combined items
82
+ ### will appear where the first instance of them occurred in the
83
+ ### list. This sort is also the fallback for indentical quantities (ie.,
84
+ ### items of the same quantity will be listed in the order they appeared
85
+ ### in the source list).
86
+ ###
87
+ def conjunction( args={} )
88
+ config = CONJUNCTION_DEFAULTS.merge( args )
89
+
90
+ # Transform items in the obj to phrases
91
+ phrases = if block_given?
92
+ self.log.debug " collecting with a block"
93
+ self.collect {|item| yield(item) }.compact
94
+ else
95
+ self.log.debug " collecting without a block"
96
+ rval = self.collect( &:to_s )
97
+ self.log.debug " collected: %p" % [ rval ]
98
+ rval
99
+ end
100
+
101
+ self.log.debug " phrases is: %p" % [ phrases ]
102
+
103
+ # No need for a conjunction if there's only one thing
104
+ return phrases[0].en.a if phrases.length < 2
105
+
106
+ # Set up a Proc to derive a collector key from a phrase depending on the
107
+ # configuration
108
+ keyfunc =
109
+ if config[:casefold]
110
+ proc {|key| key.downcase.strip}
111
+ else
112
+ proc {|key| key.strip}
113
+ end
114
+
115
+ # Count and delete phrases that hash the same when the keyfunc munges
116
+ # them into the same thing if we're combining (:combine => true).
117
+ collector = {}
118
+ if config[:combine]
119
+
120
+ phrases.each_index do |i|
121
+ # Stop when reaching the end of a truncated list
122
+ break if phrases[i].nil?
123
+
124
+ # Make the key using the configured key function
125
+ phrase = keyfunc[ phrases[i] ]
126
+
127
+ # If the collector already has this key, increment its count,
128
+ # eliminate the duplicate from the phrase list, and redo the loop.
129
+ if collector.key?( phrase )
130
+ collector[ phrase ] += 1
131
+ phrases.delete_at( i )
132
+ redo
133
+ end
134
+
135
+ collector[ phrase ] = 1
136
+ end
137
+ else
138
+ # If we're not combining, just make everything have a count of 1.
139
+ phrases.uniq.each {|key| collector[ keyfunc[key] ] = 1}
140
+ end
141
+
142
+ # If sort-by-quantity is turned on, sort the phrases first by how many
143
+ # there are (most-first), and then by the order they were specified in.
144
+ if config[:quantsort] && config[:combine]
145
+ origorder = {}
146
+ phrases.each_with_index {|phrase,i| origorder[ keyfunc[phrase] ] ||= i }
147
+ phrases.sort! {|a,b|
148
+ (collector[ keyfunc[b] ] <=> collector[ keyfunc[a] ]).nonzero? ||
149
+ (origorder[ keyfunc[a] ] <=> origorder[ keyfunc[b] ])
150
+ }
151
+ end
152
+
153
+ # Set up a filtering function that adds either an indefinite article, an
154
+ # indefinite quantifier, or a definite quantifier to each phrase
155
+ # depending on the configuration and the count of phrases in the
156
+ # collector.
157
+ filter =
158
+ if config[:generalize]
159
+ proc {|phrase, count| phrase.en.quantify(count) }
160
+ else
161
+ proc do |phrase, count|
162
+ if count > 1
163
+ "%s %s" % [
164
+ # :TODO: Make this threshold settable
165
+ count < 10 ? count.en.numwords : count.to_s,
166
+ phrase.en.plural( count )
167
+ ]
168
+ else
169
+ phrase.en.a
170
+ end
171
+ end
172
+ end
173
+
174
+ # Now use the configured filter to turn each phrase into its final
175
+ # form. Hmmm... square-bracket Lisp?
176
+ phrases.collect! {|phrase| filter[phrase, collector[ keyfunc[phrase] ]] }
177
+
178
+ # Prepend the conjunctive to the last element unless it's empty or
179
+ # there's only one element
180
+ phrases[-1].insert( 0, config[:conjunctive] + " " ) unless
181
+ config[:conjunctive].strip.empty? or
182
+ phrases.length < 2
183
+
184
+ # Concatenate the last two elements if there's no penultimate separator,
185
+ # and pick a separator based on how many phrases there are and whether
186
+ # or not there's already an instance of it in the phrases.
187
+ phrase_count = phrases.length
188
+ phrases[-2] << " " << phrases.pop unless config[:penultimate]
189
+ sep = config[:separator]
190
+ if phrase_count <= 2
191
+ sep = ' '
192
+ elsif phrases.find {|str| str.include?(config[:separator]) }
193
+ sep = config[:altsep]
194
+ end
195
+
196
+ return phrases.join( sep )
197
+ end
198
+ Linguistics::EN.register_lprintf_formatter :CONJUNCT, :conjunction
199
+
200
+
201
+ end # module Linguistics::EN::Conjunctions
202
+
@@ -1,38 +1,18 @@
1
1
  #!/usr/bin/ruby
2
- #
3
- # This file contains functions for deriving the infinitive forms of conjugated
4
- # English words. Requiring this file adds functions and constants to the
5
- # Linguistics::EN module.
6
- #
7
- # == Authors
8
- #
9
- # * Michael Granger <ged@FaerieMUD.org>
10
- #
11
- # == Acknowledgments
12
- #
13
- # This code was ported from the excellent 'Lingua::EN::Infinitive' Perl module
14
- # by Ron Savage, which is distributed under the following license:
15
- #
16
- # Australian copyright (c) 1999-2002 Ron Savage.
17
- #
18
- # All Programs of mine are 'OSI Certified Open Source Software';
19
- # you can redistribute them and/or modify them under the terms of
20
- # The Artistic License, a copy of which is available at:
21
- # http://www.opensource.org/licenses/index.html
22
- #
23
- #
24
- # :include: LICENSE
25
- #
26
- #--
27
- #
28
- # Please see the file LICENSE in the base directory for licensing details.
29
- #
30
- module Linguistics::EN
2
+
3
+ require 'linguistics/en' unless defined?( Linguistics::EN )
4
+
5
+ # Methods for deriving the infinitive forms of conjugated words for
6
+ # the English-language Linguistics module.
7
+ module Linguistics::EN::Infinitives
8
+
9
+ # Register this module to the list of modules to include
10
+ Linguistics::EN.register_extension( self )
31
11
 
32
12
  # :stopdoc:
33
13
 
34
14
  # Irregular words => infinitive forms
35
- IrregularInfinitives = {
15
+ IRREGULAR_INFINITIVES = {
36
16
  'abided' => 'abide',
37
17
  'abode' => 'abide',
38
18
  'am' => 'be',
@@ -543,7 +523,7 @@ module Linguistics::EN
543
523
  }
544
524
 
545
525
  # Mapping of word suffixes to infinitive rules.
546
- InfSuffixRules = {
526
+ INF_SUFFIX_RULES = {
547
527
  # '<suffix>' => {
548
528
  # :order => <sort order>,
549
529
  # :rule => <rule number>,
@@ -1008,7 +988,7 @@ module Linguistics::EN
1008
988
  :suffix2 => '',
1009
989
  },
1010
990
  }
1011
- InfSuffixRuleOrder = InfSuffixRules.keys.sort_by {|rule| InfSuffixRules[rule][:order]}
991
+ INF_SUFFIX_RULE_ORDER = INF_SUFFIX_RULES.keys.sort_by {|rule| INF_SUFFIX_RULES[rule][:order]}
1012
992
 
1013
993
  # :startdoc:
1014
994
 
@@ -1037,20 +1017,26 @@ module Linguistics::EN
1037
1017
 
1038
1018
  # The rule used
1039
1019
  attr_reader :rule
1020
+
1021
+ ### Equality operator: returns +true+ if +other+ is == to either of the receiver's words.
1022
+ def ==( other )
1023
+ return super(other) || @word2 == other
1024
+ end
1025
+
1040
1026
  end
1041
1027
 
1042
1028
 
1043
- ###############
1044
- module_function
1045
- ###############
1029
+ ######
1030
+ public
1031
+ ######
1046
1032
 
1047
1033
  ### Return the infinitive form of the given word
1048
- def infinitive( word )
1049
- word = word.to_s
1034
+ def infinitive
1035
+ word = self.to_s
1050
1036
  word1 = word2 = suffix = rule = newword = ''
1051
1037
 
1052
- if IrregularInfinitives.key?( word )
1053
- word1 = IrregularInfinitives[ word ]
1038
+ if IRREGULAR_INFINITIVES.key?( word )
1039
+ word1 = IRREGULAR_INFINITIVES[ word ]
1054
1040
  rule = 'irregular'
1055
1041
  else
1056
1042
  # Build up $prefix{$suffix} as an array of prefixes, from longest to shortest.
@@ -1068,49 +1054,49 @@ module Linguistics::EN
1068
1054
  }
1069
1055
  }
1070
1056
 
1071
- $stderr.puts "prefixes: %p" % prefixes if $DEBUG
1057
+ self.log.debug "prefixes: %p" % [ prefixes ]
1072
1058
 
1073
1059
  # Now check for rules covering the prefixes for this word, picking
1074
1060
  # the first one if one was found.
1075
- if (( suffix = ((InfSuffixRuleOrder & prefixes.keys).first) ))
1076
- rule = InfSuffixRules[ suffix ][:rule]
1077
- shortestPrefix = InfSuffixRules[ suffix ][:word1]
1078
- $stderr.puts "Using rule %p (%p) for suffix %p" %
1061
+ if (( suffix = ((INF_SUFFIX_RULE_ORDER & prefixes.keys).first) ))
1062
+ rule = INF_SUFFIX_RULES[ suffix ][:rule]
1063
+ shortestPrefix = INF_SUFFIX_RULES[ suffix ][:word1]
1064
+ self.log.debug "Using rule %p (%p) for suffix %p" %
1079
1065
  [ rule, shortestPrefix, suffix ] if $DEBUG
1080
1066
 
1081
1067
  case shortestPrefix
1082
1068
  when 0
1083
1069
  word1 = prefixes[ suffix ][ 0 ]
1084
1070
  word2 = prefixes[ suffix ][ 1 ]
1085
- $stderr.puts "For sp = 0: word1: %p, word2: %p" %
1071
+ self.log.debug "For sp = 0: word1: %p, word2: %p" %
1086
1072
  [ word1, word2 ] if $DEBUG
1087
1073
 
1088
1074
  when -1
1089
1075
  word1 = prefixes[ suffix ].last +
1090
- InfSuffixRules[ suffix ][:suffix1]
1076
+ INF_SUFFIX_RULES[ suffix ][:suffix1]
1091
1077
  word2 = ''
1092
- $stderr.puts "For sp = -1: word1: %p, word2: %p" %
1078
+ self.log.debug "For sp = -1: word1: %p, word2: %p" %
1093
1079
  [ word1, word2 ] if $DEBUG
1094
1080
 
1095
1081
  when -2
1096
1082
  word1 = prefixes[ suffix ].last +
1097
- InfSuffixRules[ suffix ][:suffix1]
1083
+ INF_SUFFIX_RULES[ suffix ][:suffix1]
1098
1084
  word2 = prefixes[ suffix ].last
1099
- $stderr.puts "For sp = -2: word1: %p, word2: %p" %
1085
+ self.log.debug "For sp = -2: word1: %p, word2: %p" %
1100
1086
  [ word1, word2 ] if $DEBUG
1101
1087
 
1102
1088
  when -3
1103
1089
  word1 = prefixes[ suffix ].last +
1104
- InfSuffixRules[ suffix ][:suffix1]
1090
+ INF_SUFFIX_RULES[ suffix ][:suffix1]
1105
1091
  word2 = prefixes[ suffix ].last +
1106
- InfSuffixRules[ suffix ][:suffix2]
1107
- $stderr.puts "For sp = -3: word1: %p, word2: %p" %
1092
+ INF_SUFFIX_RULES[ suffix ][:suffix2]
1093
+ self.log.debug "For sp = -3: word1: %p, word2: %p" %
1108
1094
  [ word1, word2 ] if $DEBUG
1109
1095
 
1110
1096
  when -4
1111
1097
  word1 = word
1112
1098
  word2 = ''
1113
- $stderr.puts "For sp = -4: word1: %p, word2: %p" %
1099
+ self.log.debug "For sp = -4: word1: %p, word2: %p" %
1114
1100
  [ word1, word2 ] if $DEBUG
1115
1101
 
1116
1102
  else
@@ -1128,7 +1114,7 @@ module Linguistics::EN
1128
1114
  # Eg: tipped => tipp?
1129
1115
  # Then return tip and tipp.
1130
1116
  # Eg: swimming => swimm?
1131
- # Then return tipswim and swimm.
1117
+ # Then return swim and swimm.
1132
1118
 
1133
1119
  if /^([^aeiou]*[aeiou]+)([^wx])\2$/ =~ word2
1134
1120
  word1 = $1 + $2
@@ -1138,7 +1124,7 @@ module Linguistics::EN
1138
1124
  end
1139
1125
  end
1140
1126
 
1141
- return Infinitive::new( word1, word2, suffix, rule )
1127
+ return Infinitive.new( word1, word2, suffix, rule )
1142
1128
  end
1143
1129
 
1144
1130
  end # module EN::Linguistics
@@ -1,20 +1,16 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require 'linguistics/en'
3
+ require 'linguistics/en' unless defined?( Linguistics::EN )
4
4
 
5
- #
6
- # This file contains the extensions to the Linguistics::EN module which provide
7
- # support for the Ruby LinkParser module. LinkParser enables grammatic queries
8
- # of English language sentences.
9
- #
10
- # == Synopsis
5
+ # LinkParser support for the English-language Linguistics module.
6
+ # LinkParser enables grammatic queries of English language sentences.
11
7
  #
12
8
  # # Test to see whether or not the link parser is loaded.
13
9
  # Linguistics::EN.has_link_parser?
14
10
  # # => true
15
11
  #
16
12
  # # Diagram the first linkage for a test sentence
17
- # puts "he is a big dog".sentence.linkages.first.to_s
13
+ # puts "he is a big dog".en.sentence.linkages.first.to_s
18
14
  # +---O*---+
19
15
  # | +--Ds--+
20
16
  # +Ss+ | +-A-+
@@ -41,54 +37,51 @@ require 'linguistics/en'
41
37
  # has been domesticated by man since prehistoric times; occurs in many breeds;
42
38
  # \"the dog barked all night\""
43
39
  #
44
- # == Authors
45
- #
46
- # * Martin Chase <stillflame@FaerieMUD.org>
47
- # * Michael Granger <ged@FaerieMUD.org>
48
- #
49
- # :include: LICENSE
50
- #
51
- #--
52
- #
53
- # Please see the file LICENSE in the base directory for licensing details.
54
- #
55
- module Linguistics::EN
40
+ module Linguistics::EN::LinkParser
56
41
 
57
- @has_link_parser = false
58
- @lp_dict = nil
59
- @lp_error = nil
42
+ @has_linkparser = false
43
+ @lp_dict = nil
44
+ @lp_error = nil
60
45
 
61
46
  begin
62
47
  require "linkparser"
63
- @has_link_parser = true
48
+ @has_linkparser = true
64
49
  rescue LoadError => err
65
50
  @lp_error = err
66
51
  end
67
52
 
68
53
 
69
- #################################################################
70
- ### M O D U L E M E T H O D S
71
- #################################################################
72
- class << self
54
+ # Container for methods intended to extend the EN module as singleton methods.
55
+ module SingletonMethods
56
+
57
+ ### Returns +true+ if WordNet was loaded okay
58
+ def has_linkparser? ; @has_linkparser; end
59
+
60
+ ### If #has_linkparser? returns +false+, this can be called to fetch the
61
+ ### exception which was raised when WordNet was loaded.
62
+ def linkparser_error ; @lp_error; end
63
+
64
+ end # module SingletonMethods
65
+ extend SingletonMethods
73
66
 
74
- ### Returns +true+ if LinkParser was loaded okay
75
- def has_link_parser? ; @has_link_parser ; end
76
67
 
77
- ### If #has_link_parser? returns +false+, this can be called to fetch the
78
- ### exception which was raised when trying to load LinkParser.
79
- def lp_error ; @lp_error ; end
68
+ # Register this module to the list of modules to include
69
+ Linguistics::EN.register_extension( self )
80
70
 
81
- ### The instance of LinkParser used for all Linguistics LinkParser
82
- ### functions.
83
- def lp_dict
84
- if @lp_error
85
- raise NotImplementedError,
86
- "LinkParser functions are not loaded: %s" %
87
- @lp_error.message
88
- end
71
+ #################################################################
72
+ ### M O D U L E M E T H O D S
73
+ #################################################################
89
74
 
90
- return @lp_dict ||= LinkParser::Dictionary.new( :verbosity => 0 )
75
+ ### The instance of LinkParser used for all Linguistics LinkParser
76
+ ### functions.
77
+ def self::lp_dict
78
+ if !self.has_linkparser?
79
+ raise NotImplementedError,
80
+ "LinkParser functions are not loaded: %s" %
81
+ self.lp_error.message
91
82
  end
83
+
84
+ return @lp_dict ||= LinkParser::Dictionary.new( :verbosity => 0 )
92
85
  end
93
86
 
94
87
 
@@ -96,14 +89,13 @@ module Linguistics::EN
96
89
  ### L I N K P A R S E R I N T E R F A C E
97
90
  #################################################################
98
91
 
99
- ###############
100
- module_function
101
- ###############
92
+ ######
93
+ public
94
+ ######
102
95
 
103
96
  ### Return a LinkParser::Sentence for the stringified +obj+.
104
- def sentence( obj )
105
- return Linguistics::EN::lp_dict.parse( obj.to_s )
97
+ def sentence
98
+ return Linguistics::EN::LinkParser.lp_dict.parse( self.to_s )
106
99
  end
107
- module_function :sentence
108
100
 
109
- end
101
+ end # class Linguistics::EN::LinkParser