class PROIEL::Dictionary
Attributes
dialect[R]
@return [String] dialect of the source
export_time[R]
@return [DateTime] export time for the dictionary
language[R]
@return [String] language of the source as an ISO 639-3 language tag
lemmata[R]
@return [Hash] all lemmata in the dictionary
n[R]
@return [Integer] number of lemmata in the dictionary
sources[R]
@return [Hash] all sources in the dictionary
treebank[R]
@return [Treebank] treebank that this source belongs to
Public Class Methods
new(parent, export_time, language, dialect, xml = nil)
click to toggle source
Creates a new dictionary object.
# 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
Public Instance Methods
id()
click to toggle source
FIXME
# File lib/proiel/dictionary.rb, line 47 def id @language end
Private Instance Methods
from_xml(xml)
click to toggle source
# File lib/proiel/dictionary.rb, line 53 def from_xml(xml) xml.sources.each do |s| @sources[s.idref] = { license: nullify(s.license), n: nullify(s.n, :int) } end xml.lemmata.each do |l| @lemmata[l.lemma] ||= {} @lemmata[l.lemma][l.part_of_speech] = Lemma.new(self, l) @n += 1 end end
nullify(s, type = nil)
click to toggle source
# File lib/proiel/dictionary.rb, line 65 def nullify(s, type = nil) case s when NilClass, /^\s*$/ nil else case type when :int s.to_i else s.to_s end end end