Class: Termium::EntryTerm

Inherits:
Shale::Mapper
  • Object
show all
Includes:
DesignationOperations
Defined in:
lib/termium/entry_term.rb

Overview

For <entryTerm>

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



53
54
55
# File 'lib/termium/entry_term.rb', line 53

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

#geographical_areaObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/termium/entry_term.rb', line 40

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



65
66
67
68
69
# File 'lib/termium/entry_term.rb', line 65

def normative_status
  return "deprecated" if deprecated

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

#pluralityObject



57
58
59
60
61
62
63
# File 'lib/termium/entry_term.rb', line 57

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

#to_hObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/termium/entry_term.rb', line 71

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