Class: PatternRuby::MatchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/pattern_ruby/match_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(intent: nil, entities: {}, pattern: nil, score: 0.0, input: nil, metadata: {}, response: nil, fallback: false) ⇒ MatchResult

Returns a new instance of MatchResult.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pattern_ruby/match_result.rb', line 5

def initialize(intent: nil, entities: {}, pattern: nil, score: 0.0,
               input: nil, metadata: {}, response: nil, fallback: false)
  @intent = intent
  @entities = entities
  @pattern = pattern
  @score = score
  @input = input
  @metadata = 
  @response = response
  @fallback = fallback
end

Instance Attribute Details

#entitiesObject (readonly)

Returns the value of attribute entities.



3
4
5
# File 'lib/pattern_ruby/match_result.rb', line 3

def entities
  @entities
end

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/pattern_ruby/match_result.rb', line 3

def input
  @input
end

#intentObject (readonly)

Returns the value of attribute intent.



3
4
5
# File 'lib/pattern_ruby/match_result.rb', line 3

def intent
  @intent
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3
4
5
# File 'lib/pattern_ruby/match_result.rb', line 3

def 
  @metadata
end

#patternObject (readonly)

Returns the value of attribute pattern.



3
4
5
# File 'lib/pattern_ruby/match_result.rb', line 3

def pattern
  @pattern
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/pattern_ruby/match_result.rb', line 3

def response
  @response
end

#scoreObject (readonly)

Returns the value of attribute score.



3
4
5
# File 'lib/pattern_ruby/match_result.rb', line 3

def score
  @score
end

Instance Method Details

#fallback?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/pattern_ruby/match_result.rb', line 21

def fallback?
  @fallback
end

#matched?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pattern_ruby/match_result.rb', line 17

def matched?
  @intent != nil && !fallback?
end

#to_hObject



25
26
27
# File 'lib/pattern_ruby/match_result.rb', line 25

def to_h
  { intent: @intent, entities: @entities, score: @score, pattern: @pattern }
end