Class: SvgConform::Compatibility::DiscoveredPattern

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/svg_conform/compatibility/pattern_discovery.rb

Overview

Model for discovered validation patterns

Instance Method Summary collapse

Constructor Details

#initialize(source_tool:, message_text:, pattern_category: "unknown") ⇒ DiscoveredPattern

Returns a new instance of DiscoveredPattern.



17
18
19
20
21
22
23
24
# File 'lib/svg_conform/compatibility/pattern_discovery.rb', line 17

def initialize(source_tool:, message_text:, pattern_category: "unknown")
  @source_tool = source_tool
  @message_text = message_text
  @pattern_category = pattern_category
  @frequency = 1
  @files_affected = []
  @confidence_level = 0.0
end

Instance Method Details

#common_pattern?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/svg_conform/compatibility/pattern_discovery.rb', line 40

def common_pattern?
  @frequency >= 3
end

#high_confidence?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/svg_conform/compatibility/pattern_discovery.rb', line 36

def high_confidence?
  @confidence_level >= 0.8
end

#increment_frequency(filename) ⇒ Object



26
27
28
29
# File 'lib/svg_conform/compatibility/pattern_discovery.rb', line 26

def increment_frequency(filename)
  @frequency += 1
  @files_affected << filename unless @files_affected.include?(filename)
end

#suggest_semantic_key(key, confidence) ⇒ Object



31
32
33
34
# File 'lib/svg_conform/compatibility/pattern_discovery.rb', line 31

def suggest_semantic_key(key, confidence)
  @suggested_semantic_key = key
  @confidence_level = confidence
end