Class: PROIEL::Dictionary

Inherits:
TreebankObject show all
Defined in:
lib/proiel/dictionary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TreebankObject

#inspect

Constructor Details

#initialize(parent, export_time, language, dialect, xml = nil) ⇒ Dictionary

Creates a new dictionary object.

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/proiel/dictionary.rb', line 30

def initialize(parent, export_time, language, dialect, xml = nil)
  @treebank = parent

  raise ArgumentError, 'string or nil expected' unless export_time.nil? or export_time.is_a?(String)
  @export_time = export_time.nil? ? nil : DateTime.parse(export_time).freeze

  @language = language.freeze
  @dialect = dialect ? dialect.freeze : nil

  @lemmata = {}
  @sources = {}
  @n = 0

  from_xml(xml) if xml
end

Instance Attribute Details

#dialectString (readonly)

Returns dialect of the source.

Returns:

  • (String)

    dialect of the source



15
16
17
# File 'lib/proiel/dictionary.rb', line 15

def dialect
  @dialect
end

#export_timeDateTime (readonly)

Returns export time for the dictionary.

Returns:

  • (DateTime)

    export time for the dictionary



18
19
20
# File 'lib/proiel/dictionary.rb', line 18

def export_time
  @export_time
end

#languageString (readonly)

Returns language of the source as an ISO 639-3 language tag.

Returns:

  • (String)

    language of the source as an ISO 639-3 language tag



12
13
14
# File 'lib/proiel/dictionary.rb', line 12

def language
  @language
end

#lemmataHash (readonly)

Returns all lemmata in the dictionary.

Returns:

  • (Hash)

    all lemmata in the dictionary



21
22
23
# File 'lib/proiel/dictionary.rb', line 21

def lemmata
  @lemmata
end

#nInteger (readonly)

Returns number of lemmata in the dictionary.

Returns:

  • (Integer)

    number of lemmata in the dictionary



24
25
26
# File 'lib/proiel/dictionary.rb', line 24

def n
  @n
end

#sourcesHash (readonly)

Returns all sources in the dictionary.

Returns:

  • (Hash)

    all sources in the dictionary



27
28
29
# File 'lib/proiel/dictionary.rb', line 27

def sources
  @sources
end

#treebankTreebank (readonly)

Returns treebank that this source belongs to.

Returns:

  • (Treebank)

    treebank that this source belongs to



9
10
11
# File 'lib/proiel/dictionary.rb', line 9

def treebank
  @treebank
end

Instance Method Details

#idObject

FIXME



47
48
49
# File 'lib/proiel/dictionary.rb', line 47

def id
  @language
end