Commits

Michael Granger committed 5d7f373

Prepping for release

Comments (0)

Files changed (15)

+== v2.0.0 [2011-11-01] Michael Granger  <ged@FaerieMUD.org>
+ 
+Rewritten to be more modular, easier to extend and maintain, and to work under
+1.9.
+ 
 
-## 2.0.0 [2010-12-15] Michael Granger  <ged@FaerieMUD.org>
+=== v1.0.9 [2011-09-01] Michael Granger  <ged@FaerieMUD.org>
 
-Rewritten to be more modular, easier to extend and maintain, and to work under 1.9.
+- Bugfix for Linguistics::EN.ordinate.
 
+
-Copyright (c) 2003-2009, Michael Granger
+Copyright (c) 2003-20011, Michael Granger
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 ChangeLog
-History.md
+History.rdoc
 LICENSE
-README.md
+Manifest.txt
+README.rdoc
 Rakefile
 examples/generalize_sentence.rb
 examples/klingon.rb
 lib/linguistics.rb
 lib/linguistics/en.rb
 lib/linguistics/en/articles.rb
+lib/linguistics/en/conjugation.rb
 lib/linguistics/en/conjunctions.rb
 lib/linguistics/en/infinitives.rb
 lib/linguistics/en/linkparser.rb
 spec/lib/constants.rb
 spec/lib/helpers.rb
 spec/linguistics/en/articles_spec.rb
+spec/linguistics/en/conjugation_spec.rb
 spec/linguistics/en/conjunctions_spec.rb
 spec/linguistics/en/infinitives_spec.rb
 spec/linguistics/en/linkparser_spec.rb

lib/linguistics/en.rb

 # 
 # == WordNet® Integration
 # 
-# If you have the Ruby-WordNet module installed, you can look up 
-# WordNet synsets using the Linguistics interface:
+# If you have the 'wordnet' gem installed, you can look up WordNet synsets using 
+# the Linguistics interface:
 # 
 #    # Test to be sure the WordNet module loaded okay.
 #    Linguistics::EN.has_wordnet?
 # 
 # == LinkParser Integration
 # 
-# Another new feature in version 0.02 is integration with the Ruby version of the
-# CMU Link Grammar Parser by Martin Chase. If you have the LinkParser module
-# installed, you can create linkages from English sentences that let you query for
-# parts of speech:
+# If you have the 'linkparser' gem installed, you can create linkages
+# from English sentences that let you query for parts of speech:
 # 
 #    # Test to see whether or not the link parser is loaded.
 #    Linguistics::EN.has_link_parser?
 		MODULES.push( mod )
 		Linguistics.log.debug "Registered English extension %p" % [ mod ]
 		include( mod )
+		if mod.const_defined?( :SingletonMethods )
+			smod = mod.const_get(:SingletonMethods)
+			Linguistics.log.debug "  and its singleton methods %p" % [ smod ]
+			extend( smod )
+			ivars = mod.instance_variables
+			Linguistics.log.debug "  and instance variables %p" % [ ivars ]
+			ivars.each do |ivar|
+				instance_variable_set( ivar, mod.instance_variable_get(ivar) )
+			end
+		end
 	end
 
 

lib/linguistics/en/articles.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# This file contains functions for prepending articles to nouns or noun phrases.
-# 
-# == Version
-#
-#  $Id$
-# 
-# == Authors
-# 
-# * Michael Granger <ged@FaerieMUD.org>
-#    
-# :include: LICENSE
-# 
-#---
-#
-# Please see the file LICENSE in the base directory for licensing details for the 
-# Ruby port.
-#
+# Indefinite article methods for the English-language Linguistics module.
 module Linguistics::EN::Articles
 
 	# Register this module to the list of modules to include

lib/linguistics/en/conjugation.rb

 # == Authors
 # 
 # * Robert Berry <berrydigital@gmail.com>
+# * Michael Granger <ged@FaerieMUD.org>
 # 
 # == Copyright
 #    

lib/linguistics/en/conjunctions.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# This file contains functions for constructing conjunctions out of Enumerable 
-# objects. Requiring this file adds functions and constants to the Linguistics::EN 
-# module.
-# 
-# == Version
-#
-#  $Id$
-# 
-# == Authors
-# 
-# * Michael Granger <ged@FaerieMUD.org>
-#    
-# :include: LICENSE
-# 
-#---
-#
-# Please see the file LICENSE in the base directory for licensing details for the 
-# Ruby port.
-#
+# Conjunction methods for the English-language Linguistics module.
 module Linguistics::EN::Conjunctions
 
 	# Register this module to the list of modules to include

lib/linguistics/en/infinitives.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# 
-# This file contains functions for deriving the infinitive forms of conjugated
-# English words. Requiring this file adds functions and constants to the
-# Linguistics::EN module.
-# 
-# == Version
-#
-#  $Id$
-# 
-# == Authors
-# 
-# * Michael Granger <ged@FaerieMUD.org>
-#    
-# :include: LICENSE
-# 
-#---
-#
-# Please see the file LICENSE in the base directory for licensing details for the 
-# Ruby port.
-#
+# Methods for deriving the infinitive forms of conjugated words for
+# the English-language Linguistics module.
 module Linguistics::EN::Infinitives
 
 	# Register this module to the list of modules to include

lib/linguistics/en/linkparser.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# This file contains the extensions to the Linguistics::EN module which provide
-# support for the Ruby LinkParser module. LinkParser enables grammatic queries
-# of English language sentences.
-#
-# == Synopsis
+# LinkParser support for the English-language Linguistics module.
+# LinkParser enables grammatic queries of English language sentences.
 #
 #   # Test to see whether or not the link parser is loaded.
 #   Linguistics::EN.has_link_parser?
 #   # => true
 # 
 #   # Diagram the first linkage for a test sentence
-#   puts "he is a big dog".sentence.linkages.first.to_s
+#   puts "he is a big dog".en.sentence.linkages.first.to_s
 # 	  +---O*---+ 
 # 	  | +--Ds--+ 
 #    +Ss+ |  +-A-+ 
 #   has been domesticated by man since prehistoric times; occurs in many breeds;
 #   \"the dog barked all night\""
 # 
-# == Version
-#
-#  $Id$
-# 
-# == Authors
-# 
-# * Martin Chase <stillflame@FaerieMUD.org>
-# * Michael Granger <ged@FaerieMUD.org>
-# 
-# :include: LICENSE
-#
-#--
-#
-# Please see the file LICENSE in the base directory for licensing details.
-#
 module Linguistics::EN::LinkParser
 
-	# Register this module to the list of modules to include
-	Linguistics::EN.register_extension( self )
-
-	@lp_dict  = nil
-	@lp_error = nil
+	@has_linkparser = false
+	@lp_dict        = nil
+	@lp_error       = nil
 
 	begin
 		require "linkparser"
+		@has_linkparser = true
 	rescue LoadError => err
 		@lp_error = err
 	end
 
 
+	# Container for methods intended to extend the EN module as singleton methods.
+	module SingletonMethods
+
+		### Returns +true+ if WordNet was loaded okay
+		def has_linkparser? ; @has_linkparser; end
+
+		### If #has_linkparser? returns +false+, this can be called to fetch the
+		### exception which was raised when WordNet was loaded.
+		def linkparser_error ; @lp_error; end
+
+	end # module SingletonMethods
+	extend SingletonMethods
+
+
+	# Register this module to the list of modules to include
+	Linguistics::EN.register_extension( self )
+
 	#################################################################
 	###	M O D U L E   M E T H O D S
 	#################################################################
 
-	### If #has_link_parser? returns +false+, this will be the
-	### Exception which was raised when trying to load LinkParser.
-	### @return [LoadError] the exception that was raised
-	class << self; attr_accessor :lp_error; end
-
-
-	### Returns +true+ if LinkParser was loaded okay
-	def self::has_link_parser?
-		return self.lp_error ? false : true
-	end
-
-
 	### The instance of LinkParser used for all Linguistics LinkParser
 	### functions.
 	def self::lp_dict
-		if !self.has_link_parser?
+		if !self.has_linkparser?
 			raise NotImplementedError,
 				"LinkParser functions are not loaded: %s" %
 				self.lp_error.message

lib/linguistics/en/numbers.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# This file contains functions for constructing words out of numbers.
-# 
-# == Version
-#
-#  $Id$
-# 
-# == Authors
-# 
-# * Michael Granger <ged@FaerieMUD.org>
-#    
-# :include: LICENSE
-# 
-#---
-#
-# Please see the file LICENSE in the base directory for licensing details for the 
-# Ruby port.
-#
+# Numeric methods for the English-language Linguistics module.
 module Linguistics::EN::Numbers
 
 	# Register this module to the list of modules to include

lib/linguistics/en/participles.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# This file contains functions for deriving present participles.
-# 
-# == Version
-#
-#  $Id$
-# 
-# == Authors
-# 
-# * Michael Granger <ged@FaerieMUD.org>
-#    
-# :include: LICENSE
-# 
-#---
-#
-# Please see the file LICENSE in the base directory for licensing details for the 
-# Ruby port.
-#
+# Methods for deriving present participles for the English-language
+# Linguistics module.
 module Linguistics::EN::Participles
 
 	# Register this module to the list of modules to include

lib/linguistics/en/pluralization.rb

 
 require 'linguistics/en' unless defined?( Linguistics )
 
-# This module contains plural inflections for the English-language
-# module of the Linguistics library.
+# Plural inflection methods for the English-language Linguistics module.
 # 
 # It provides conversion of plural forms of all nouns, most verbs,
 # and some adjectives. It also provides "classical" variants (for
 # example: "brother" -> "brethren", "dogma" -> "dogmata", etc.) where
 # appropriate.
-# 
-# These can be accessed via the #plural, #plural_noun, #plural_verb,
-# and #plural_adjective methods.
-# 
-# == Version
-#
-#  $Id$
-# 
-# == Authors
-# 
-# * Martin Chase <stillflame@FaerieMUD.org>
-# * Michael Granger <ged@FaerieMUD.org>
-# 
-# :include: LICENSE
-#
-#--
-#
-# Please see the file LICENSE in the base directory for licensing details.
-#
 module Linguistics::EN::Pluralization
 
 	# Register this module to the list of modules to include

lib/linguistics/en/titlecase.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# This file contains functions for capitalizing a sentence as a title and nouns as
-# proper nouns, as well as functions for turning a sentence into its equivalent
-# CamelCaseSentence and vice-versa.
+# Methods for capitalizing a sentence as a title, nouns as proper
+# nouns, and for turning a sentence into its equivalent CamelCaseSentence
+# and vice-versa. It's part of the English-language Linguistics module.
 module Linguistics::EN::TitleCase
 
 	# Register this module to the list of modules to include

lib/linguistics/en/wordnet.rb

 
 require 'linguistics/en' unless defined?( Linguistics::EN )
 
-# This file contains functions for finding relations for English words. It
-# requires the Ruby-WordNet module to be installed; if it is not installed,
-# calling the functions defined by this file will raise NotImplemented
-# exceptions if called. Requiring this file adds functions and constants to the
-# Linguistics::EN module.
-#
-# == Synopsis
+# WordNet support for the English-language Linguistics module. It
+# requires the Ruby-WordNet module to be installed; if it is not
+# installed, calling the functions defined by this file will raise
+# NotImplementedErrors.
 #
 #   # Test to be sure the WordNet module loaded okay.
 #   Linguistics::EN.has_wordnet?
 #   instrument", "sonograph", "surveying instrument", "surveyor's instrument",
 #   "tracer", "weapon", "arm", "weapon system", "whip"]
 # 
-# 
-# == Authors
-# 
-# * Michael Granger <ged@FaerieMUD.org>
-# 
-# :include: LICENSE
-# 
-# == Version
-#
-#  $Id$
-# 
 module Linguistics::EN::WordNet
 
-	# Register this module to the list of modules to include
-	Linguistics::EN.register_extension( self )
-
 	@has_wordnet	= false
 	@wn_error		= nil
 	@wn_lexicon		= nil
 	# Load WordNet if possible, saving the error that occurs if anything goes wrong.
 	begin
 		require 'wordnet'
+		WordNet.logger = Linguistics.logger
 		@has_wordnet = true
 	rescue LoadError => err
 		@wn_error = err
 	end
 
 
+	# Container for methods intended to extend the EN module as singleton methods.
+	module SingletonMethods
+
+		### Returns +true+ if WordNet was loaded okay
+		def has_wordnet? ; @has_wordnet; end
+
+		### If #has_wordnet? returns +false+, this can be called to fetch the
+		### exception which was raised when WordNet was loaded.
+		def wn_error ; @wn_error; end
+
+	end # module SingletonMethods
+	extend SingletonMethods
+
+
+	# Register this module to the list of modules to include
+	Linguistics::EN.register_extension( self )
+
 	#################################################################
 	###	M O D U L E   M E T H O D S
 	#################################################################
 
-	### Returns +true+ if WordNet was loaded okay
-	def self::has_wordnet? ; @has_wordnet; end
-
-	### If #has_wordnet? returns +false+, this can be called to fetch the
-	### exception which was raised when WordNet was loaded.
-	def self::wn_error ; @wn_error; end
-
 	### The instance of the WordNet::Lexicon used for all Linguistics WordNet
 	### functions.
 	def self::wn_lexicon
 		@wn_lexicon ||= WordNet::Lexicon::new
 	end
 
+
 	### Make a function that calls the method +meth+ on the synset of an input
 	### word.
 	def self::def_synset_function( name )

spec/linguistics/en/wordnet_spec.rb

 
 
 describe Linguistics::EN::WordNet do
-	include Linguistics::SpecHelpers
 
 	before( :all ) do
-		setup_logging( :fatal )
+		setup_logging( :debug )
 		Linguistics.use( :en )
 	end
 
 
 		before( :each ) do
 			pending "installation of the wordnet library" unless
-				Linguistics::EN::WordNet.has_wordnet?
+				Linguistics::EN.has_wordnet?
 		end
 
 		it "can create a WordNet::Synset from a word" do
 	describe "on a system that doesn't have the 'wordnet' library" do
 		before( :all ) do
 			# If the system *does* have wordnet support, pretend it doesn't.
-			if Linguistics::EN::WordNet.has_wordnet?
+			if Linguistics::EN.has_wordnet?
 				error = LoadError.new( "no such file to load -- wordnet" )
 				Linguistics::EN::WordNet.instance_variable_set( :@has_wordnet, false )
 				Linguistics::EN::WordNet.instance_variable_set( :@wn_error, error )