Module: Linguistics::EN::LinkParser
- Extended by:
- SingletonMethods
- Defined in:
- lib/linguistics/en/linkparser.rb
Overview
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".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\""
Defined Under Namespace
Modules: SingletonMethods
Class Method Summary collapse
-
.lp_dict ⇒ Object
The instance of LinkParser used for all Linguistics LinkParser functions.
Instance Method Summary collapse
-
#sentence ⇒ Object
Return a LinkParser::Sentence for the stringified
obj
.
Methods included from SingletonMethods
has_linkparser?, linkparser_error
Class Method Details
.lp_dict ⇒ Object
The instance of LinkParser used for all Linguistics LinkParser functions.
77 78 79 80 81 82 83 84 85 |
# 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.lp_error. end return @lp_dict ||= LinkParser::Dictionary.new( :verbosity => 0 ) end |
Instance Method Details
#sentence ⇒ Object
Return a LinkParser::Sentence for the stringified obj
.
97 98 99 |
# File 'lib/linguistics/en/linkparser.rb', line 97 def sentence return Linguistics::EN::LinkParser.lp_dict.parse( self.to_s ) end |