10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/charyf/engine/dispatcher/default.rb', line 10
def dispatch_internal(request)
context = Charyf::Engine::Context.new
context.request = request
context.session = session_processor.get.process(request)
intents = intent_processors.collect do |processor_klass|
processor = processor_klass.instance
processor.determine(
request
)
end.flatten.sort_by do |intent|
intent.confidence
end.reverse
best_match = intents.shift
if best_match
context.intent = best_match
context.alternative_intents = intents
end
context.routing = routes.process(context)
context.freeze
spawn_controller(context)
end
|