Method: Stepmod::Utils::Concept.definition_designation

Defined in:
lib/stepmod/utils/concept.rb

.definition_designation(definition_xml) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/stepmod/utils/concept.rb', line 58

def definition_designation(definition_xml)
  # We take the <p> that is an alternative term (length<=20).
  # Add in the <synonym> elements.
  alts = definition_xml.xpath(".//synonym").map(&:text) +
    definition_xml.xpath(".//def/p").map(&:text).reject do |text|
      text.length > 20
    end

  term = Stepmod::Utils::Converters::Term
    .new
    .convert(
      definition_xml.xpath(".//term").first
    )

  # [4..-1] because we want to skip the initial `=== {title}`
  designations = [
    { "designation" => term[4..-1], "type" => "expression", "normative_status" => "preferred" },
  ]

  alts.each do |alt|
    designations << { "designation" => alt, "type" => "expression" }
  end

  designations
end