|
@@ -8,62 +8,64 @@ logging.basicConfig()
|
|
|
logger = logging.getLogger("jarvis")
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-user_said = "jarvis régle le réveil pour sept heures et pour vingts minutes"
|
|
|
-
|
|
|
-order = "régle le réveil pour {{ hour }} heures et pour {{ minute }} minutes"
|
|
|
-
|
|
|
-
|
|
|
-def counterSubset(list1, list2):
|
|
|
- """
|
|
|
- check if the number of occurrences matches
|
|
|
- :param list1:
|
|
|
- :param list2:
|
|
|
- :return:
|
|
|
- """
|
|
|
- c1, c2 = Counter(list1), Counter(list2)
|
|
|
- for k, n in c1.items():
|
|
|
- if n > c2[k]:
|
|
|
- return False
|
|
|
- return True
|
|
|
|
|
|
+
|
|
|
+from core import OrderAnalyser
|
|
|
+order = "jarvis régle le réveil pour sept heures et vingt minutes"
|
|
|
|
|
|
-def _spelt_order_match_brain_order_via_table(order_to_analyse, user_said):
|
|
|
- list_word_user_said = user_said.split()
|
|
|
- split_order_without_bracket = _get_list_word_without_bracket(order_to_analyse)
|
|
|
|
|
|
- number_of_word_in_order = len(split_order_without_bracket)
|
|
|
-
|
|
|
-
|
|
|
- return counterSubset(split_order_without_bracket, list_word_user_said)
|
|
|
+oa = OrderAnalyser(order)
|
|
|
|
|
|
+oa.start()
|
|
|
|
|
|
-def _get_list_word_without_bracket(order):
|
|
|
- """
|
|
|
- Get an order with bracket inside like: "hello my name is {{ name }}.
|
|
|
- return a list of string without bracket like ["hello", "my", "name", "is"]
|
|
|
- :param order: sentence to split
|
|
|
- :return: list of string without bracket
|
|
|
- """
|
|
|
- pattern = r"((?:{{\s*)[\w\.]+(?:\s*}}))"
|
|
|
-
|
|
|
- matches = re.findall(pattern, order)
|
|
|
- for match in matches:
|
|
|
- order = order.replace(match, "")
|
|
|
-
|
|
|
- split_order = order.split()
|
|
|
- return split_order
|
|
|
|
|
|
-
|
|
|
-if _spelt_order_match_brain_order_via_table(order, user_said):
|
|
|
- print "order matched"
|
|
|
-else:
|
|
|
- print "order does not match"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|