Class: Termium::TextualSupport
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- 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
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
39 40 41 |
# File 'lib/termium/textual_support.rb', line 39 def is_definition? type == "DEF" end |
#is_example? ⇒ Boolean
35 36 37 |
# File 'lib/termium/textual_support.rb', line 35 def is_example? value_cleaned.match(EXAMPLE_REGEX) end |
#is_note? ⇒ Boolean
43 44 45 |
# File 'lib/termium/textual_support.rb', line 43 def is_note? !is_definition? && !is_example? end |
#is_observation? ⇒ Boolean
47 48 49 |
# File 'lib/termium/textual_support.rb', line 47 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>>].
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
20 21 22 |
# File 'lib/termium/textual_support.rb', line 20 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
51 52 53 |
# File 'lib/termium/textual_support.rb', line 51 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 |