Class: NluAdapter::Adapters::Dialogflow::Intent
- Inherits:
-
Object
- Object
- NluAdapter::Adapters::Dialogflow::Intent
- Includes:
- NluAdapterIntent
- Defined in:
- lib/nlu_adapter/dialogflow.rb
Overview
Class represents Intent in an IntentCollection
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Attributes included from NluAdapterIntent
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Intent
constructor
Constructor.
-
#to_h ⇒ Hash
Convert self to Hash.
-
#to_json ⇒ json
convert self to json.
Constructor Details
#initialize(options = {}) ⇒ Intent
Constructor
116 117 118 119 120 |
# File 'lib/nlu_adapter/dialogflow.rb', line 116 def initialize( = {}) @name = [:name] #DF.intent.display_name @id = [:id] #DF.intent.name @utterences = [:utterences] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
113 114 115 |
# File 'lib/nlu_adapter/dialogflow.rb', line 113 def id @id end |
Instance Method Details
#to_h ⇒ Hash
Convert self to Hash
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/nlu_adapter/dialogflow.rb', line 125 def to_h training_phrases = [] @utterences.each do |u| training_phrases << {"type" => "EXAMPLE", "parts" =>[{"text" => u }]} end { name: @id, display_name: @name, training_phrases: training_phrases } end |
#to_json ⇒ json
convert self to json
141 142 143 |
# File 'lib/nlu_adapter/dialogflow.rb', line 141 def to_json to_h.to_json end |