Linguistics::EN::

LinkParser

module
Extended With
Linguistics::EN::LinkParser::SingletonMethods

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_linkparser?
# => true

# Diagram the first linkage for a test sentence
puts "he is a big dog".en.sentence.linkages.first.to_s
  +---O*---+
  | +--Ds--+
 +Ss+ |  +-A-+
 |  | |  |   |
he is a big dog

# Find the verb in the sentence
"he is a big dog".en.sentence.verb.to_s
# => "is"

# Combined infinitive + LinkParser: Find the infinitive form of the verb of the
given sentence.
"he is a big dog".en.sentence.verb.infinitive
# => "be"

# Find the direct object of the sentence
"he is a big dog".en.sentence.object.to_s
# => "dog"

# Combine WordNet + LinkParser to find the definition of the direct object of
# the sentence
"he is a big dog".en.sentence.object.gloss
# => "a member of the genus Canis (probably descended from the common wolf) that
has been domesticated by man since prehistoric times; occurs in many breeds;
\"the dog barked all night\""

Public Class Methods

anchor
lp_dict()

The instance of LinkParser used for all Linguistics LinkParser functions.

# File lib/linguistics/en/linkparser.rb, line 77
def self::lp_dict
        if !self.has_linkparser?
                raise NotImplementedError,
                        "LinkParser functions are not loaded: %s" %
                        self.linkparser_error.message
        end

        return @lp_dict ||= LinkParser::Dictionary.new( :verbosity => 0 )
end

Public Instance Methods

anchor
sentence()

Return a LinkParser::Sentence for the stringified obj.

# File lib/linguistics/en/linkparser.rb, line 97
def sentence
        return Linguistics::EN::LinkParser.lp_dict.parse( self.to_s )
end