Class: Termium::TextualSupport
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Termium::TextualSupport
- Defined in:
- lib/termium/textual_support.rb
Overview
For
Constant Summary collapse
- EXAMPLE_REGEX =
/\AEx[ea]mples?\s*:\s*/- DEFINITION_REGEX =
/\A<(.+?)>\s*/
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
64 65 66 67 68 |
# File 'lib/termium/textual_support.rb', line 64 def domain return unless has_domain? value_cleaned.match(DEFINITION_REGEX)[1] end |
#has_domain? ⇒ Boolean
60 61 62 |
# File 'lib/termium/textual_support.rb', line 60 def has_domain? !value_cleaned.match(DEFINITION_REGEX).nil? end |
#is_definition? ⇒ Boolean
38 39 40 |
# File 'lib/termium/textual_support.rb', line 38 def is_definition? type == "DEF" end |
#is_example? ⇒ Boolean
34 35 36 |
# File 'lib/termium/textual_support.rb', line 34 def is_example? value_cleaned.match(EXAMPLE_REGEX) end |
#is_note? ⇒ Boolean
42 43 44 |
# File 'lib/termium/textual_support.rb', line 42 def is_note? !is_definition? && !is_example? end |
#is_observation? ⇒ Boolean
46 47 48 |
# File 'lib/termium/textual_support.rb', line 46 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 [<
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/termium/textual_support.rb', line 75 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
18 19 20 |
# File 'lib/termium/textual_support.rb', line 18 def value_cleaned value.gsub(/\n\s+/, " ") end |
#value_definition ⇒ Object
56 57 58 |
# File 'lib/termium/textual_support.rb', line 56 def value_definition value_cleaned.gsub(DEFINITION_REGEX, "") end |
#value_example ⇒ Object
50 51 52 |
# File 'lib/termium/textual_support.rb', line 50 def value_example value_cleaned.gsub(EXAMPLE_REGEX, "") end |
#value_typed ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/termium/textual_support.rb', line 22 def value_typed if is_example? value_example elsif is_definition? value_definition else value_cleaned end end |