From 7f7feb27e9e1c8e41b13247f9419cc7e20d932bd Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Tue, 27 Jul 2021 12:37:09 +0200 Subject: [PATCH] Renamed intents for skills --- ia/process.py | 2 +- ia/train.py | 2 +- main.py | 4 ++-- requirements.txt | 3 ++- {intents => skills}/__init__.py | 0 {intents => skills}/daily/__init__.py | 0 .../entertainement => skills/daily/date_and_time}/__init__.py | 0 {intents => skills}/daily/date_and_time/info.json | 0 {intents => skills}/daily/date_and_time/intent.py | 0 {intents => skills}/daily/date_and_time/lang/en-en.json | 0 {intents => skills}/daily/date_and_time/lang/fr-fr.json | 0 .../jokes => skills/entertainement}/__init__.py | 0 skills/entertainement/jokes/__init__.py | 0 {intents => skills}/entertainement/jokes/info.json | 0 {intents => skills}/entertainement/jokes/intent.py | 0 {intents => skills}/entertainement/jokes/lang/en-en.json | 0 {intents => skills}/entertainement/jokes/lang/fr-fr.json | 0 utils/intents_utils.py | 4 ++-- utils/utils.py | 2 +- 19 files changed, 9 insertions(+), 8 deletions(-) rename {intents => skills}/__init__.py (100%) rename {intents => skills}/daily/__init__.py (100%) rename {intents/entertainement => skills/daily/date_and_time}/__init__.py (100%) rename {intents => skills}/daily/date_and_time/info.json (100%) rename {intents => skills}/daily/date_and_time/intent.py (100%) rename {intents => skills}/daily/date_and_time/lang/en-en.json (100%) rename {intents => skills}/daily/date_and_time/lang/fr-fr.json (100%) rename {intents/entertainement/jokes => skills/entertainement}/__init__.py (100%) create mode 100644 skills/entertainement/jokes/__init__.py rename {intents => skills}/entertainement/jokes/info.json (100%) rename {intents => skills}/entertainement/jokes/intent.py (100%) rename {intents => skills}/entertainement/jokes/lang/en-en.json (100%) rename {intents => skills}/entertainement/jokes/lang/fr-fr.json (100%) diff --git a/ia/process.py b/ia/process.py index d67daeb..4fe34fc 100644 --- a/ia/process.py +++ b/ia/process.py @@ -37,7 +37,7 @@ def get_tag_for_sentence(input_sentence): ---------- input_sentence is your sentence - Returns tag from the intents.json file + Returns tag from the skills.json file ------- """ diff --git a/ia/train.py b/ia/train.py index 27275e7..3b2bb30 100644 --- a/ia/train.py +++ b/ia/train.py @@ -20,7 +20,7 @@ def train(): all_words = [] tags = [] xy = [] - # loop through each sentence in our intents patterns + # loop through each sentence in our skills patterns for intent in all_intents_patterns: tag = intent # add to tag list diff --git a/main.py b/main.py index 6609cdc..19b7b01 100644 --- a/main.py +++ b/main.py @@ -24,8 +24,8 @@ def process_request(): return jsonify("I didn't get that.") path_of_intent = intents_utils.get_path(tag_for_request) - path_of_intent = path_of_intent.split('/intents/')[1].replace('/', '.') - path_of_intent = "intents." + path_of_intent + "intent" + path_of_intent = path_of_intent.split('/skills/')[1].replace('/', '.') + path_of_intent = "skills." + path_of_intent + "intent" method = utils.import_method_from_string(path_of_intent, tag_for_request) return jsonify(method()) diff --git a/requirements.txt b/requirements.txt index 4096be3..ea8d29a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ Unidecode~=1.2.0 nltk~=3.6.2 torch~=1.9.0 numpy~=1.21.1 -requests~=2.26.0 \ No newline at end of file +requests~=2.26.0 +adapt-parser \ No newline at end of file diff --git a/intents/__init__.py b/skills/__init__.py similarity index 100% rename from intents/__init__.py rename to skills/__init__.py diff --git a/intents/daily/__init__.py b/skills/daily/__init__.py similarity index 100% rename from intents/daily/__init__.py rename to skills/daily/__init__.py diff --git a/intents/entertainement/__init__.py b/skills/daily/date_and_time/__init__.py similarity index 100% rename from intents/entertainement/__init__.py rename to skills/daily/date_and_time/__init__.py diff --git a/intents/daily/date_and_time/info.json b/skills/daily/date_and_time/info.json similarity index 100% rename from intents/daily/date_and_time/info.json rename to skills/daily/date_and_time/info.json diff --git a/intents/daily/date_and_time/intent.py b/skills/daily/date_and_time/intent.py similarity index 100% rename from intents/daily/date_and_time/intent.py rename to skills/daily/date_and_time/intent.py diff --git a/intents/daily/date_and_time/lang/en-en.json b/skills/daily/date_and_time/lang/en-en.json similarity index 100% rename from intents/daily/date_and_time/lang/en-en.json rename to skills/daily/date_and_time/lang/en-en.json diff --git a/intents/daily/date_and_time/lang/fr-fr.json b/skills/daily/date_and_time/lang/fr-fr.json similarity index 100% rename from intents/daily/date_and_time/lang/fr-fr.json rename to skills/daily/date_and_time/lang/fr-fr.json diff --git a/intents/entertainement/jokes/__init__.py b/skills/entertainement/__init__.py similarity index 100% rename from intents/entertainement/jokes/__init__.py rename to skills/entertainement/__init__.py diff --git a/skills/entertainement/jokes/__init__.py b/skills/entertainement/jokes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/intents/entertainement/jokes/info.json b/skills/entertainement/jokes/info.json similarity index 100% rename from intents/entertainement/jokes/info.json rename to skills/entertainement/jokes/info.json diff --git a/intents/entertainement/jokes/intent.py b/skills/entertainement/jokes/intent.py similarity index 100% rename from intents/entertainement/jokes/intent.py rename to skills/entertainement/jokes/intent.py diff --git a/intents/entertainement/jokes/lang/en-en.json b/skills/entertainement/jokes/lang/en-en.json similarity index 100% rename from intents/entertainement/jokes/lang/en-en.json rename to skills/entertainement/jokes/lang/en-en.json diff --git a/intents/entertainement/jokes/lang/fr-fr.json b/skills/entertainement/jokes/lang/fr-fr.json similarity index 100% rename from intents/entertainement/jokes/lang/fr-fr.json rename to skills/entertainement/jokes/lang/fr-fr.json diff --git a/utils/intents_utils.py b/utils/intents_utils.py index 57d39e9..6accb21 100644 --- a/utils/intents_utils.py +++ b/utils/intents_utils.py @@ -15,11 +15,11 @@ def register_all_intents(): result = {} - files = glob.glob(path + "/intents/**/info.json", recursive=True) + files = glob.glob(path + "/skills/**/info.json", recursive=True) for f in files: with open(f, "rb") as infile: intent_info_json = json.load(infile) - intents_in_info = intent_info_json['intents'] + intents_in_info = intent_info_json['skills'] intent_path = str(f).replace('info.json', '') for intent in intents_in_info: diff --git a/utils/utils.py b/utils/utils.py index 4ac6918..c1b673f 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -3,7 +3,7 @@ import importlib def import_method_from_string(file, method_name): """ - Add the posibility to import method dynamically using a string like "intents.daily.date_and_time.intent" as file and + Add the possibility to import method dynamically using a string like "skills.daily.date_and_time.intent" as file and "what_time_is_it" as method_name """ mod = importlib.import_module(file)