Class: Camdict::Definition
- Inherits:
-
Object
- Object
- Camdict::Definition
- Includes:
- Common
- Defined in:
- lib/camdict/definition.rb
Overview
Parse an html definition to get explanations, word, IPA, prounciation, part of speech, etc.
Defined Under Namespace
Classes: IPA, Irregular, Link, Pronunciation
Instance Attribute Summary collapse
-
#explanations ⇒ Object
readonly
Get explanations for this definition.
-
#gc ⇒ Object
readonly
Grammar code.
-
#guided ⇒ Object
readonly
Get the guided word for this definition entry, which is usually just one word or a phrase.
-
#ipa ⇒ Object
readonly
Get the IPA.
-
#is_idiom ⇒ Object
readonly
Is the queried word/phrase an idiom?.
-
#part_of_speech ⇒ Object
readonly
Get part of speech of a word or phrase.
-
#pronunciation ⇒ Object
readonly
Get the pronunciation.
-
#region ⇒ Object
readonly
Get the region: UK or US.
-
#usage ⇒ Object
readonly
Get the short usage.
-
#verb ⇒ Object
readonly
Get the verb irregular form word.
Instance Method Summary collapse
-
#initialize(word, entry_html) ⇒ Definition
constructor
Input
word
andentry_html
are { entry ID => its html definition source }.
Constructor Details
#initialize(word, entry_html) ⇒ Definition
Input word
and entry_html
are { entry ID => its html definition source }
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/camdict/definition.rb', line 49 def initialize(word, entry_html) @word = word @entry_id, @html = entry_html.flatten @html = Nokogiri::HTML(@html) @title_word = title_word # String @derived_words = derived_words # String or [String] @spelling_variant = spell_variant # String @head_variant = get_head_variant # [String] @body_variant = get_body_variant # [String] @inflection = get_inflection # [String] @phrase = get_phrase # [String] @is_idiom = is_idiom? # True or False @part_of_speech = pos # String or [String] or [] @explanations = get_explanations # [Camdict::Explanation] @ipa = get_ipa # Struct uk:String,us:String,k:[],s:[] @pronunciation = get_pronunciation # Struct uk:Link, us:Link @region = get_region # String @usage = get_usage # String @gc = get_gc # String @plural = get_plural # String or [String] @guided = get_guided_word # String @verb = get_irregular # Struct Irregular end |
Instance Attribute Details
#explanations ⇒ Object (readonly)
Get explanations for this definition.
25 26 27 |
# File 'lib/camdict/definition.rb', line 25 def explanations @explanations end |
#gc ⇒ Object (readonly)
Grammar code. Like U, means uncountable noun.
37 38 39 |
# File 'lib/camdict/definition.rb', line 37 def gc @gc end |
#guided ⇒ Object (readonly)
Get the guided word for this definition entry, which is usually just one word or a phrase. This does not exist when there is only one definition. It is useful when there are many definitions for one word to distinguish them.
42 43 44 |
# File 'lib/camdict/definition.rb', line 42 def guided @guided end |
#ipa ⇒ Object (readonly)
Get the IPA
29 30 31 |
# File 'lib/camdict/definition.rb', line 29 def ipa @ipa end |
#is_idiom ⇒ Object (readonly)
Is the queried word/phrase an idiom?
27 28 29 |
# File 'lib/camdict/definition.rb', line 27 def is_idiom @is_idiom end |
#part_of_speech ⇒ Object (readonly)
Get part of speech of a word or phrase.
23 24 25 |
# File 'lib/camdict/definition.rb', line 23 def part_of_speech @part_of_speech end |
#pronunciation ⇒ Object (readonly)
Get the pronunciation
31 32 33 |
# File 'lib/camdict/definition.rb', line 31 def pronunciation @pronunciation end |
#region ⇒ Object (readonly)
Get the region: UK or US
33 34 35 |
# File 'lib/camdict/definition.rb', line 33 def region @region end |
#usage ⇒ Object (readonly)
Get the short usage
35 36 37 |
# File 'lib/camdict/definition.rb', line 35 def usage @usage end |
#verb ⇒ Object (readonly)
Get the verb irregular form word. word.verb.sp
gets the simple past tense of this verb.
45 46 47 |
# File 'lib/camdict/definition.rb', line 45 def verb @verb end |