Class: Opener::PolarityTagger::LexiconMap
- Inherits:
-
Object
- Object
- Opener::PolarityTagger::LexiconMap
- Defined in:
- lib/opener/polarity_tagger/lexicon_map.rb
Constant Summary collapse
- POS_ORDER =
'ONRVGA'
- DEFAULT_POS =
'O'
- POS_SHORT_MAP =
{ adj: 'G', adv: 'A', noun: 'N', propernoun: 'N', prep: 'P', verb: 'V', other: DEFAULT_POS, nil => DEFAULT_POS, multi_word_expression: DEFAULT_POS, }
Instance Attribute Summary collapse
-
#intensifiers ⇒ Object
readonly
Returns the value of attribute intensifiers.
-
#negators ⇒ Object
readonly
Returns the value of attribute negators.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#with_polarity ⇒ Object
readonly
Returns the value of attribute with_polarity.
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #by_intensifier(lemma) ⇒ Object
- #by_negator(lemma) ⇒ Object
- #by_polarity(lemma, identified_short_pos) ⇒ Object
-
#initialize(lang:, lexicons:) ⇒ LexiconMap
constructor
A new instance of LexiconMap.
Constructor Details
#initialize(lang:, lexicons:) ⇒ LexiconMap
Returns a new instance of LexiconMap.
24 25 26 27 28 29 30 31 32 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 24 def initialize lang:, lexicons: @lang = lang @lexicons = lexicons @negators = {} @intensifiers = {} @with_polarity = {} map lexicons end |
Instance Attribute Details
#intensifiers ⇒ Object (readonly)
Returns the value of attribute intensifiers.
7 8 9 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 7 def intensifiers @intensifiers end |
#negators ⇒ Object (readonly)
Returns the value of attribute negators.
6 7 8 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 6 def negators @negators end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
5 6 7 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 5 def resource @resource end |
#with_polarity ⇒ Object (readonly)
Returns the value of attribute with_polarity.
8 9 10 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 8 def with_polarity @with_polarity end |
Instance Method Details
#blank? ⇒ Boolean
34 35 36 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 34 def blank? @lexicons.blank? end |
#by_intensifier(lemma) ⇒ Object
42 43 44 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 42 def by_intensifier lemma @intensifiers[lemma] end |
#by_negator(lemma) ⇒ Object
38 39 40 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 38 def by_negator lemma @negators[lemma] end |
#by_polarity(lemma, identified_short_pos) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/opener/polarity_tagger/lexicon_map.rb', line 46 def by_polarity lemma, identified_short_pos hash = Hashie::Mash.new multi: (@with_polarity[lemma] || []) if identified_short_pos and lexicon = @with_polarity[lemma+identified_short_pos] hash[:single] = lexicon return [hash, identified_short_pos] end POS_ORDER.chars.each do |short_pos| if lexicon = @with_polarity[lemma+short_pos] hash[:single] = lexicon return [hash, identified_short_pos] end end [hash, 'unknown'] end |