From 099af2a8156dbd6404634e15e07d85d0d8a98365 Mon Sep 17 00:00:00 2001 From: kenkeiras Date: Sat, 13 May 2017 20:33:09 +0200 Subject: [PATCH] Add remix application sample. --- naive-nlu/parsing.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/naive-nlu/parsing.py b/naive-nlu/parsing.py index de57d64..4e4b179 100644 --- a/naive-nlu/parsing.py +++ b/naive-nlu/parsing.py @@ -63,6 +63,10 @@ def integrate_language(knowledge_base, example): print("Tx:", tokens) print("Mx:", matcher) print("Rx:", result) + print("Remix:", remix) + after_remix = apply_remix(tokens[len(start_bounds):-len(end_bounds)], remix) + assert(len(after_remix) + len(start_bounds) + len(end_bounds) == len(tokens)) + print(" \\->", after_remix) print("#########") break @@ -75,6 +79,13 @@ def integrate_language(knowledge_base, example): return tokens, matcher, result +def apply_remix(tokens, remix): + rebuilt = [] + for i in remix: + rebuilt.append(tokens[i]) + return rebuilt + + def build_remix_matrix(knowledge_base, text, atom, similar): # print("+" * 20)