linkparser 1.0.3

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/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2008, Michael Granger
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/README ADDED
@@ -0,0 +1,88 @@
1
+ = Ruby-LinkParser
2
+
3
+ This module is a Ruby binding for the link-grammar library, a syntactic parser
4
+ of English.
5
+
6
+ == Authors
7
+
8
+ * Michael Granger <ged@FaerieMUD.org>
9
+ * Martin Chase <stillflame@FaerieMUD.org>
10
+
11
+
12
+ == Requirements
13
+
14
+ * Ruby 1.8.6
15
+ * link-grammar (version 4.4.1 or later) from the AbiWord project
16
+ (http://www.abisource.com/projects/link-grammar/)
17
+
18
+
19
+ === Example Usage
20
+
21
+ require 'linkparser'
22
+
23
+ dict = LinkParser::Dictionary.new( :screen_width => 100 )
24
+ sent = dict.parse( "People use Ruby for all kinds of nifty things." )
25
+ # => #<LinkParser::Sentence:0xcf8eb "LEFT-WALL people use Ruby for all kinds
26
+ # of nifty things . RIGHT-WALL"/2 linkages/0 nulls>
27
+
28
+ sent.subject # => "people"
29
+ sent.verb # => "use"
30
+ sent.object # => "Ruby"
31
+
32
+ puts sent.constituent_tree_string
33
+ # =>
34
+ # (S (NP People)
35
+ # (VP use
36
+ # (NP Ruby)
37
+ # (PP for
38
+ # (NP (NP all kinds)
39
+ # (PP of
40
+ # (NP nifty things)))))
41
+ # .)
42
+
43
+ puts sent.diagram
44
+ # =>
45
+ # +-------------------------------Xp------------------------------+
46
+ # | +----MVp---+----Jp----+ +------Jp-----+ |
47
+ # +----Wd---+--Sp--+--Os-+ | +-Dmc-+--Mp-+ +----A---+ |
48
+ # | | | | | | | | | | |
49
+ # LEFT-WALL people.p use.v Ruby for.p all kinds.n of nifty.a things.n .
50
+
51
+
52
+ == Legal
53
+
54
+ For copyright and licensing information for link-grammar itself, see the
55
+ LICENSE file in that distribution.
56
+
57
+ Copyright (c) 2006-2008, Michael Granger
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 $
87
+
88
+
data/Rakefile ADDED
@@ -0,0 +1,315 @@
1
+ #!rake
2
+ #
3
+ # LinkParser rakefile
4
+ #
5
+ # Based on various other Rakefiles, especially one by Ben Bleything
6
+ #
7
+ # Copyright (c) 2008 The FaerieMUD Consortium
8
+ #
9
+ # Authors:
10
+ # * Michael Granger <ged@FaerieMUD.org>
11
+ #
12
+
13
+ BEGIN {
14
+ require 'pathname'
15
+ basedir = Pathname.new( __FILE__ ).dirname
16
+
17
+ libdir = basedir + "lib"
18
+ extdir = basedir + "ext"
19
+
20
+ $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
21
+ $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
22
+ }
23
+
24
+ require 'rubygems'
25
+ gem 'rake', '>= 0.8.3'
26
+
27
+ require 'rbconfig'
28
+ require 'rake'
29
+ require 'rake/rdoctask'
30
+ require 'rake/testtask'
31
+ require 'rake/packagetask'
32
+ require 'rake/clean'
33
+
34
+ $dryrun = false
35
+
36
+ ### Config constants
37
+ BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
38
+ BINDIR = BASEDIR + 'bin'
39
+ LIBDIR = BASEDIR + 'lib'
40
+ EXTDIR = BASEDIR + 'ext'
41
+ DOCSDIR = BASEDIR + 'docs'
42
+ PKGDIR = BASEDIR + 'pkg'
43
+ DATADIR = BASEDIR + 'data'
44
+
45
+ PROJECT_NAME = 'LinkParser'
46
+ PKG_NAME = PROJECT_NAME.downcase
47
+ PKG_SUMMARY = 'a Ruby binding for the link-grammar library'
48
+
49
+ VERSION_FILE = LIBDIR + 'linkparser.rb'
50
+ if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
51
+ PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
52
+ elsif VERSION_FILE.exist?
53
+ PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
54
+ else
55
+ PKG_VERSION = '0.0.0'
56
+ end
57
+
58
+ PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
59
+ GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
60
+
61
+ EXTCONF = EXTDIR + 'extconf.rb'
62
+
63
+ ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' )
64
+
65
+ TEXT_FILES = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename }
66
+ BIN_FILES = Pathname.glob( BINDIR + '*' ).delete_if {|item| item =~ /\.svn/ }
67
+ LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
68
+ EXT_FILES = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ }
69
+ DATA_FILES = Pathname.glob( DATADIR + '**/*' ).delete_if {|item| item =~ /\.svn/ }
70
+
71
+ SPECDIR = BASEDIR + 'spec'
72
+ SPECLIBDIR = SPECDIR + 'lib'
73
+ SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } +
74
+ Pathname.glob( SPECLIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
75
+
76
+ TESTDIR = BASEDIR + 'tests'
77
+ TEST_FILES = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ }
78
+
79
+ RAKE_TASKDIR = BASEDIR + 'rake'
80
+ RAKE_TASKLIBS = Pathname.glob( RAKE_TASKDIR + '*.rb' )
81
+
82
+ LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
83
+
84
+ EXTRA_PKGFILES = []
85
+
86
+ RELEASE_FILES = TEXT_FILES +
87
+ SPEC_FILES +
88
+ TEST_FILES +
89
+ BIN_FILES +
90
+ LIB_FILES +
91
+ EXT_FILES +
92
+ DATA_FILES +
93
+ RAKE_TASKLIBS +
94
+ EXTRA_PKGFILES
95
+
96
+ RELEASE_FILES << LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
97
+
98
+ COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
99
+ RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
100
+ RCOV_OPTS = [
101
+ '--exclude', RCOV_EXCLUDES,
102
+ '--xrefs',
103
+ '--save',
104
+ '--callsites',
105
+ #'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0
106
+ ]
107
+
108
+
109
+ # Subversion constants -- directory names for releases and tags
110
+ SVN_TRUNK_DIR = 'trunk'
111
+ SVN_RELEASES_DIR = 'releases'
112
+ SVN_BRANCHES_DIR = 'branches'
113
+ SVN_TAGS_DIR = 'tags'
114
+
115
+ SVN_DOTDIR = BASEDIR + '.svn'
116
+ SVN_ENTRIES = SVN_DOTDIR + 'entries'
117
+
118
+
119
+ ### Load some task libraries that need to be loaded early
120
+ require RAKE_TASKDIR + 'helpers.rb'
121
+ require RAKE_TASKDIR + 'svn.rb'
122
+ require RAKE_TASKDIR + 'verifytask.rb'
123
+
124
+ # Define some constants that depend on the 'svn' tasklib
125
+ PKG_BUILD = get_svn_rev( BASEDIR ) || 0
126
+ SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
127
+ SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
128
+
129
+ # Documentation constants
130
+ RDOCDIR = DOCSDIR + 'api'
131
+ RDOC_OPTIONS = [
132
+ '-w', '4',
133
+ '-SHN',
134
+ '-i', '.',
135
+ '-m', 'README',
136
+ '-t', PKG_NAME,
137
+ '-W', 'http://deveiate.org/projects/Ruby-LinkParser/browser/trunk/'
138
+ ]
139
+
140
+ # Release constants
141
+ SMTP_HOST = 'mail.faeriemud.org'
142
+ SMTP_PORT = 465 # SMTP + SSL
143
+
144
+ # Project constants
145
+ PROJECT_HOST = 'deveiate.org'
146
+ PROJECT_PUBDIR = '/usr/local/www/public/code'
147
+ PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
148
+ PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
149
+ PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
150
+
151
+ # Rubyforge stuff
152
+ RUBYFORGE_GROUP = 'deveiate'
153
+ RUBYFORGE_PROJECT = 'linkparser'
154
+
155
+ # Gem dependencies: gemname => version
156
+ DEPENDENCIES = {
157
+ }
158
+
159
+ # Developer Gem dependencies: gemname => version
160
+ DEVELOPMENT_DEPENDENCIES = {
161
+ 'amatch' => '>= 0.2.3',
162
+ 'rake' => '>= 0.8.1',
163
+ 'rcodetools' => '>= 0.7.0.0',
164
+ 'rcov' => '>= 0',
165
+ 'RedCloth' => '>= 4.0.3',
166
+ 'rspec' => '>= 0',
167
+ 'rubyforge' => '>= 0',
168
+ 'termios' => '>= 0',
169
+ 'text-format' => '>= 1.0.0',
170
+ 'tmail' => '>= 1.2.3.1',
171
+ 'ultraviolet' => '>= 0.10.2',
172
+ 'libxml-ruby' => '>= 0.8.3',
173
+ }
174
+
175
+ # Non-gem requirements: packagename => version
176
+ REQUIREMENTS = {
177
+ 'link-grammar' => '>= 4.4.1',
178
+ }
179
+
180
+ # RubyGem specification
181
+ GEMSPEC = Gem::Specification.new do |gem|
182
+ gem.name = PKG_NAME.downcase
183
+ gem.version = PKG_VERSION
184
+
185
+ gem.summary = PKG_SUMMARY
186
+ gem.description = [
187
+ "A Ruby binding for the link-grammar library, a syntactic parser",
188
+ "of English. See http://www.link.cs.cmu.edu/link/ for more",
189
+ "information about the Link Grammar, and",
190
+ "http://www.abisource.org/projects/link-grammar/ for information",
191
+ "about the link-grammar library.",
192
+ ].join( "\n" )
193
+
194
+ gem.authors = 'Michael Granger'
195
+ gem.email = 'ged@FaerieMUD.org'
196
+ gem.homepage = 'http://deveiate.org/projects/Ruby-LinkParser/'
197
+ gem.rubyforge_project = RUBYFORGE_PROJECT
198
+
199
+ gem.has_rdoc = true
200
+ gem.rdoc_options = RDOC_OPTIONS
201
+ gem.extra_rdoc_files = %w[ChangeLog README LICENSE]
202
+
203
+ gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
204
+ gem.executables = BIN_FILES.select {|pn| pn.executable? }.
205
+ collect {|pn| pn.relative_path_from(BINDIR).to_s }
206
+
207
+ if EXTCONF.exist?
208
+ gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
209
+ end
210
+
211
+ gem.files = RELEASE_FILES.
212
+ collect {|f| f.relative_path_from(BASEDIR).to_s }
213
+ gem.test_files = SPEC_FILES.
214
+ collect {|f| f.relative_path_from(BASEDIR).to_s }
215
+
216
+ DEPENDENCIES.each do |name, version|
217
+ version = '>= 0' if version.length.zero?
218
+ gem.add_runtime_dependency( name, version )
219
+ end
220
+
221
+ # Developmental dependencies don't work as of RubyGems 1.2.0
222
+ unless Gem::Version.new( Gem::RubyGemsVersion ) <= Gem::Version.new( "1.2.0" )
223
+ DEVELOPMENT_DEPENDENCIES.each do |name, version|
224
+ version = '>= 0' if version.length.zero?
225
+ gem.add_development_dependency( name, version )
226
+ end
227
+ end
228
+
229
+ REQUIREMENTS.each do |name, version|
230
+ gem.requirements << [ name, version ].compact.join(' ')
231
+ end
232
+ end
233
+
234
+ # Manual-generation config
235
+ MANUALDIR = DOCSDIR + 'manual'
236
+
237
+ $trace = Rake.application.options.trace ? true : false
238
+ $dryrun = Rake.application.options.dryrun ? true : false
239
+
240
+
241
+ # Load any remaining task libraries
242
+ RAKE_TASKLIBS.each do |tasklib|
243
+ next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$}
244
+ begin
245
+ require tasklib
246
+ rescue ScriptError => err
247
+ fail "Task library '%s' failed to load: %s: %s" %
248
+ [ tasklib, err.class.name, err.message ]
249
+ trace "Backtrace: \n " + err.backtrace.join( "\n " )
250
+ rescue => err
251
+ log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
252
+ [ tasklib, err.class.name, err.message ]
253
+ trace "Backtrace: \n " + err.backtrace.join( "\n " )
254
+ end
255
+ end
256
+
257
+ # Load any project-specific rules defined in 'Rakefile.local' if it exists
258
+ import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
259
+
260
+
261
+ #####################################################################
262
+ ### T A S K S
263
+ #####################################################################
264
+
265
+ ### Default task
266
+ task :default => [:clean, :local, :spec, :rdoc, :package]
267
+
268
+ ### Task the local Rakefile can append to -- no-op by default
269
+ task :local
270
+
271
+
272
+ ### Task: clean
273
+ CLEAN.include 'coverage'
274
+ CLOBBER.include 'artifacts', 'coverage.info', PKGDIR
275
+
276
+ # Target to hinge on ChangeLog updates
277
+ file SVN_ENTRIES
278
+
279
+ ### Task: changelog
280
+ file 'ChangeLog' => SVN_ENTRIES.to_s do |task|
281
+ log "Updating #{task.name}"
282
+
283
+ changelog = make_svn_changelog()
284
+ File.open( task.name, 'w' ) do |fh|
285
+ fh.print( changelog )
286
+ end
287
+ end
288
+
289
+
290
+ ### Task: cruise (Cruisecontrol task)
291
+ desc "Cruisecontrol build"
292
+ task :cruise => [:clean, 'spec:quiet', :package] do |task|
293
+ raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
294
+ artifact_dir = ARTIFACTS_DIR.cleanpath + ENV['CC_BUILD_LABEL']
295
+ artifact_dir.mkpath
296
+
297
+ coverage = BASEDIR + 'coverage'
298
+ if coverage.exist? && coverage.directory?
299
+ $stderr.puts "Copying coverage stats..."
300
+ FileUtils.cp_r( 'coverage', artifact_dir )
301
+ end
302
+
303
+ $stderr.puts "Copying packages..."
304
+ FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
305
+ end
306
+
307
+
308
+ desc "Update the build system to the latest version"
309
+ task :update_build do
310
+ log "Updating the build system"
311
+ sh 'svn', 'up', RAKE_TASKDIR
312
+ log "Updating the Rakefile"
313
+ sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
314
+ end
315
+
data/Rakefile.local ADDED
@@ -0,0 +1,60 @@
1
+ #!rake
2
+
3
+ # C extension constants
4
+ EXT_MAKEFILE = EXTDIR + 'Makefile'
5
+ EXT_SOURCES = FileList[ EXTDIR + '*.c' ]
6
+ EXT_SO = EXTDIR + "linkparser_ext.#{CONFIG['DLEXT']}"
7
+
8
+
9
+ #####################################################################
10
+ ### T A S K S
11
+ #####################################################################
12
+
13
+ # Make both the default task and the spec task depend on building the extension
14
+ task :local => :build
15
+ task :spec => :build
16
+ namespace :spec do
17
+ task :doc => [ :build ]
18
+ task :quiet => [ :build ]
19
+ task :html => [ :build ]
20
+ task :text => [ :build ]
21
+ end
22
+
23
+ desc "Make the Makefile for the C extension"
24
+ file EXT_MAKEFILE.to_s => EXT_SOURCES do
25
+ log "Configuring linkparser C extension"
26
+ in_subdirectory( EXTDIR ) do
27
+ ruby 'extconf.rb'
28
+ end
29
+ end
30
+ CLOBBER.include( EXTDIR + 'mkmf.log', EXT_SO )
31
+
32
+ desc "Build the C extension"
33
+ task :build => [ EXT_MAKEFILE.to_s, *EXT_SOURCES ] do
34
+ in_subdirectory( EXTDIR ) do
35
+ sh 'make'
36
+ end
37
+ end
38
+
39
+
40
+ desc "Rebuild the C extension"
41
+ task :rebuild => [ :clean, :build ]
42
+
43
+
44
+ task :clean do
45
+ if EXT_MAKEFILE.exist?
46
+ in_subdirectory( EXTDIR ) do
47
+ sh 'make clean'
48
+ end
49
+ end
50
+ end
51
+
52
+ task :clobber do
53
+ if EXT_MAKEFILE.exist?
54
+ in_subdirectory( EXTDIR ) do
55
+ sh 'make distclean'
56
+ end
57
+ end
58
+ end
59
+ CLOBBER.include( EXT_MAKEFILE )
60
+