Class: Termium::EntryTerm

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Includes:
DesignationOperations
Defined in:
lib/termium/entry_term.rb

Overview

For

Constant Summary collapse

GEOGRAPHICAL_CODE_MAPPING =

attr_accessor :geographical_area, :deprecated, :plurality, :part_of_speech, :gender

{
  "USA" => "US",
  "CAN" => "CA",
  "GB" => "GB",
  "AUS" => "AU",
  "EUR" => "EU",
}.freeze

Constants included from DesignationOperations

DesignationOperations::GENDER_CODE_MAPPING, DesignationOperations::PART_OF_SPEECH_CODE_MAPPING

Instance Method Summary collapse

Methods included from DesignationOperations

#gender, #part_of_speech

Instance Method Details

#deprecatedObject



49
50
51
# File 'lib/termium/entry_term.rb', line 49

def deprecated
  parameter.map(&:abbreviation).include?("AE")
end

#geographical_areaObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/termium/entry_term.rb', line 36

def geographical_area
  keys = GEOGRAPHICAL_CODE_MAPPING.keys
  usage = parameter.select do |x|
    keys.include?(x.abbreviation)
  end

  return nil if usage.empty?

  usage.map do |x|
    GEOGRAPHICAL_CODE_MAPPING[x.abbreviation]
  end.join("; ")
end

#normative_statusObject



61
62
63
64
65
# File 'lib/termium/entry_term.rb', line 61

def normative_status
  return "deprecated" if deprecated

  order == 1 ? "preferred" : "admitted"
end

#pluralityObject



53
54
55
56
57
58
59
# File 'lib/termium/entry_term.rb', line 53

def plurality
  if parameter.map(&:abbreviation).include?("PL")
    "plural"
  else
    "singular"
  end
end

#to_hObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/termium/entry_term.rb', line 67

def to_h
  set = {
    "designation" => value,
    "type" => "expression",
    "normative_status" => normative_status,
  }

  set["geographical_area"] = geographical_area if geographical_area

  set["plurality"] = plurality if plurality

  set["gender"] = gender if gender

  set["part_of_speech"] = part_of_speech if part_of_speech

  set
end