Class: LLT::Stem::VerbPack

Inherits:
Pack
  • Object
show all
Defined in:
lib/llt/stem/verb_pack.rb

Constant Summary collapse

STEMS =
%i{ praesens perfectum ppp }

Instance Attribute Summary collapse

Attributes inherited from Pack

#lemma, #lemma_key, #stems, #type

Instance Method Summary collapse

Methods inherited from Pack

#lemma_with_key, #to_s

Constructor Details

#initialize(type, args, source, extension = true) ⇒ VerbPack

Returns a new instance of VerbPack.



6
7
8
9
10
# File 'lib/llt/stem/verb_pack.rb', line 6

def initialize(type, args, source, extension = true)
  super
  extract_valencies(args)

end

Instance Attribute Details

#direct_objectsObject (readonly)

Returns the value of attribute direct_objects.



4
5
6
# File 'lib/llt/stem/verb_pack.rb', line 4

def direct_objects
  @direct_objects
end

#indirect_objectsObject (readonly)

Returns the value of attribute indirect_objects.



4
5
6
# File 'lib/llt/stem/verb_pack.rb', line 4

def indirect_objects
  @indirect_objects
end

Instance Method Details

#convert_valencies(val) ⇒ Object



34
35
36
37
38
39
# File 'lib/llt/stem/verb_pack.rb', line 34

def convert_valencies(val)
  val.split.map do |val_string|
    meth = (val_string.match(/^\d$/) ? :to_i : :to_sym)
    val_string.send(meth)
  end
end

#extended_stems(args) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/llt/stem/verb_pack.rb', line 42

def extended_stems(args)
  STEMS.map do |type|
    new_type = args[t.send(type, :abbr)]
    next unless new_type
    args[:stem] = new_type
    create_stem(type, args)
  end.compact
end

#extract_valencies(args) ⇒ Object



19
20
21
22
23
24
# File 'lib/llt/stem/verb_pack.rb', line 19

def extract_valencies(args)
  d = args[:dir_objs]
  i = args[:indir_objs]

  @direct_objects, @indirect_objects = parse_valencies(d, i)
end

#parse_valencies(d, i) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/llt/stem/verb_pack.rb', line 26

def parse_valencies(d, i)
  if d.nil? || d == "not_set"
    [[4, :aci, :infinitive], [3]]
  else
    [d, i].map { |val| convert_valencies(val)}
  end
end

#to_hash(use = nil, options = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/llt/stem/verb_pack.rb', line 12

def to_hash(use = nil, options = {})
  if use
    stem = @stems.find { |st| st.type == use }
    stem.to_hash.merge(options: options)
  end
end