Class: Termium::LanguageModule
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Termium::LanguageModule
- Defined in:
- lib/termium/language_module.rb
Overview
For <languageModule>
Constant Summary collapse
- LANGUAGE_CODE_MAPPING =
{ "en" => "eng", "fr" => "fre", }.freeze
Instance Method Summary collapse
- #abbreviations ⇒ Object
- #definition ⇒ Object
- #definition_raw ⇒ Object
- #designations ⇒ Object
- #domain ⇒ Object
- #examples ⇒ Object
- #notes ⇒ Object
- #to_concept(options = {}) ⇒ Object
- #to_h ⇒ Object
Instance Method Details
#abbreviations ⇒ Object
39 40 41 |
# File 'lib/termium/language_module.rb', line 39 def abbreviations entry_term.map(&:abbreviation).flatten end |
#definition ⇒ Object
23 24 25 |
# File 'lib/termium/language_module.rb', line 23 def definition definition_raw&.value_typed end |
#definition_raw ⇒ Object
19 20 21 |
# File 'lib/termium/language_module.rb', line 19 def definition_raw textual_support.detect(&:is_definition?) end |
#designations ⇒ Object
48 49 50 51 |
# File 'lib/termium/language_module.rb', line 48 def designations # NOTE: entry_term is a collection entry_term + abbreviations end |
#domain ⇒ Object
27 28 29 |
# File 'lib/termium/language_module.rb', line 27 def domain definition_raw&.domain end |
#examples ⇒ Object
35 36 37 |
# File 'lib/termium/language_module.rb', line 35 def examples textual_support.select(&:is_example?).map(&:value_typed) end |
#notes ⇒ Object
31 32 33 |
# File 'lib/termium/language_module.rb', line 31 def notes textual_support.select(&:is_note?).map(&:value_typed) end |
#to_concept(options = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/termium/language_module.rb', line 71 def to_concept( = {}) x = to_h return nil unless x Glossarist::LocalizedConcept.new(x).tap do |concept| # Fill in register parameters if [:date_accepted] puts [:date_accepted].inspect concept.date_accepted = [:date_accepted] end puts concept.inspect end end |
#to_h ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/termium/language_module.rb', line 53 def to_h # TODO: This is needed to skip the empty french entries of 10031781 and 10031778 return nil unless definition src = { "language_code" => LANGUAGE_CODE_MAPPING[language.downcase], "terms" => designations.map(&:to_h), "definition" => [{ content: definition }], "notes" => notes, "examples" => examples, "entry_status" => "valid", } src["domain"] = domain if domain src end |