Class: Termium::TextualSupport
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Termium::TextualSupport
- Defined in:
- lib/termium/textual_support.rb
Overview
For <textualSupport>
Constant Summary collapse
- EXAMPLE_REGEX =
/\AEx[ea]mples?\s*:\s*/.freeze
- DEFINITION_REGEX =
/\A<(.+?)>\s*/.freeze
Instance Method Summary collapse
- #domain ⇒ Object
- #has_domain? ⇒ Boolean
- #is_definition? ⇒ Boolean
- #is_example? ⇒ Boolean
- #is_note? ⇒ Boolean
- #is_observation? ⇒ Boolean
-
#source_from_note ⇒ Object
This is an attempt to extract the textual reference within the note.
- #value_cleaned ⇒ Object
- #value_definition ⇒ Object
- #value_example ⇒ Object
- #value_typed ⇒ Object
Instance Method Details
#domain ⇒ Object
66 67 68 69 70 |
# File 'lib/termium/textual_support.rb', line 66 def domain return unless has_domain? value_cleaned.match(DEFINITION_REGEX)[1] end |
#has_domain? ⇒ Boolean
62 63 64 |
# File 'lib/termium/textual_support.rb', line 62 def has_domain? !value_cleaned.match(DEFINITION_REGEX).nil? end |
#is_definition? ⇒ Boolean
40 41 42 |
# File 'lib/termium/textual_support.rb', line 40 def is_definition? type == "DEF" end |
#is_example? ⇒ Boolean
36 37 38 |
# File 'lib/termium/textual_support.rb', line 36 def is_example? value_cleaned.match(EXAMPLE_REGEX) end |
#is_note? ⇒ Boolean
44 45 46 |
# File 'lib/termium/textual_support.rb', line 44 def is_note? !is_definition? && !is_example? end |
#is_observation? ⇒ Boolean
48 49 50 |
# File 'lib/termium/textual_support.rb', line 48 def is_observation? type == "OBS" end |
#source_from_note ⇒ Object
This is an attempt to extract the textual reference within the note. TODO: Use this to correlate the actual term with the source reference, i.e from the following note, the terms “abduction; inférence abductive” come from “ISO-IEC-2382-28-1995”. NOTE: abduction; inférence abductive : termes et définition normalisés par l’ISO/CEI [<<ISO-IEC-2382-28-1995>>].
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/termium/textual_support.rb', line 77 def source_from_note x = note.match(/\[.*\]/) return nil if x.nil? ref = x.match(/\[.*\]/).to_s.gsub(/[\[\]]/, "") # "[ISO/IEC 2382-13:1996; ISO/IEC 2382-24:1995]" if ref.include?(";") ref.split("; ") else [ref] end end |
#value_cleaned ⇒ Object
20 21 22 |
# File 'lib/termium/textual_support.rb', line 20 def value_cleaned value.gsub(/\n\s+/, " ") end |
#value_definition ⇒ Object
58 59 60 |
# File 'lib/termium/textual_support.rb', line 58 def value_definition value_cleaned.gsub(DEFINITION_REGEX, "") end |
#value_example ⇒ Object
52 53 54 |
# File 'lib/termium/textual_support.rb', line 52 def value_example value_cleaned.gsub(EXAMPLE_REGEX, "") end |
#value_typed ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/termium/textual_support.rb', line 24 def value_typed if is_example? value_example elsif is_definition? value_definition else value_cleaned end end |