|
@@ -3,25 +3,18 @@ import os
|
|
|
|
|
|
import re
|
|
|
|
|
|
-from core.ConfigurationManager import SettingLoader
|
|
|
-from core.ConfigurationManager.BrainLoader import BrainLoader
|
|
|
-from core.CrontabManager import CrontabManager
|
|
|
-from core.Models import Order
|
|
|
-from core.OrderAnalyser import OrderAnalyser
|
|
|
|
|
|
import logging
|
|
|
|
|
|
-from core.TriggerLauncher import TriggerLauncher
|
|
|
|
|
|
|
|
|
# user_said = "maman je voudrais ecouter ACDC"
|
|
|
# order = "je voudrais ecouter {{ artist_name }}"
|
|
|
|
|
|
-user_said = "regle le reveil pour sept heures et dix minutes"
|
|
|
+user_said = "s'il te plait regle le reveil pour sept heures et dix minutes"
|
|
|
order = "regle le reveil pour {{ hour }} heures et {{ minute }} minutes"
|
|
|
|
|
|
|
|
|
-brain = BrainLoader.get_brain()
|
|
|
# take a look to each order
|
|
|
|
|
|
|
|
@@ -34,26 +27,39 @@ def _is_containing_bracket(sentence):
|
|
|
return True
|
|
|
return False
|
|
|
|
|
|
-list_word = user_said.split()
|
|
|
-# list_word = ["je", "voudrais"]
|
|
|
-print "user said: %s" % list_word
|
|
|
-
|
|
|
-
|
|
|
-def _get_order_without_variables(list_word_in_order):
|
|
|
-
|
|
|
- pass
|
|
|
-
|
|
|
|
|
|
# check if the order contain bracket
|
|
|
if _is_containing_bracket(order):
|
|
|
+ # remove white space between {{ and }}
|
|
|
# get a table of word said
|
|
|
- list_word_in_order = order.split()
|
|
|
+ list_word_in_order = order.replace("{{ ","{{").replace(" }}", "}}").split()
|
|
|
print "order matched: %s" % list_word_in_order
|
|
|
- split_orider_variable = _get_order_without_variables(list_word_in_order)
|
|
|
+
|
|
|
+ # get the order, defined by the first words before {{
|
|
|
+ the_order = order[:order.find('{{')]
|
|
|
+ print "the order catched %s" % the_order
|
|
|
+
|
|
|
+
|
|
|
+ # remove sentence before order
|
|
|
+ nb = user_said[user_said.find(the_order):]
|
|
|
+ truncate_list_word_said = nb.split()
|
|
|
+ print "truncate_list_word_said : %s" % truncate_list_word_said
|
|
|
+
|
|
|
+
|
|
|
+ # make dict var:value
|
|
|
+ dictVar = {}
|
|
|
+ for idx, ow in enumerate(list_word_in_order):
|
|
|
+ if _is_containing_bracket(ow):
|
|
|
+ # remove bracket et key dict
|
|
|
+ oo = ow.replace("{{","").replace("}}", "")
|
|
|
+ dictVar[oo] = truncate_list_word_said[idx]
|
|
|
+
|
|
|
+ print "The dict Var : %s" % dictVar
|
|
|
+
|
|
|
|
|
|
|
|
|
# return the beginning of the sentence before first bracket
|
|
|
-# return sentence[:sentence.find('{{')]
|
|
|
+# return
|
|
|
|
|
|
# split each word
|
|
|
#
|