Class: Termium::LanguageModule
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Termium::LanguageModule
- Defined in:
- lib/termium/language_module.rb
Overview
For
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
37 38 39 |
# File 'lib/termium/language_module.rb', line 37 def abbreviations entry_term.map(&:abbreviation).flatten end |
#definition ⇒ Object
21 22 23 |
# File 'lib/termium/language_module.rb', line 21 def definition definition_raw&.value_typed end |
#definition_raw ⇒ Object
17 18 19 |
# File 'lib/termium/language_module.rb', line 17 def definition_raw textual_support.detect(&:is_definition?) end |
#designations ⇒ Object
46 47 48 49 |
# File 'lib/termium/language_module.rb', line 46 def designations # NOTE: entry_term is a collection entry_term + abbreviations end |
#domain ⇒ Object
25 26 27 |
# File 'lib/termium/language_module.rb', line 25 def domain definition_raw&.domain end |
#examples ⇒ Object
33 34 35 |
# File 'lib/termium/language_module.rb', line 33 def examples textual_support.select(&:is_example?).map(&:value_typed) end |
#notes ⇒ Object
29 30 31 |
# File 'lib/termium/language_module.rb', line 29 def notes textual_support.select(&:is_note?).map(&:value_typed) end |
#to_concept(options = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/termium/language_module.rb', line 69 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 options[:date_accepted].inspect concept.date_accepted = [:date_accepted] end # puts concept.inspect end end |
#to_h ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/termium/language_module.rb', line 51 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 |