@@ -39,11 +39,11 @@ def __init__(self, console_manager, settings_):
39
39
self .settings = settings_
40
40
self .response_creator = ResponseCreator ()
41
41
self .skill_analyzer = SkillAnalyzer (
42
- weight_measure = TfidfVectorizer ,
43
- similarity_measure = cosine_similarity ,
44
- args = self .settings .SKILL_ANALYZER .get ('args' ),
45
- sensitivity = self .settings .SKILL_ANALYZER .get ('sensitivity' ),
46
- )
42
+ weight_measure = TfidfVectorizer ,
43
+ similarity_measure = cosine_similarity ,
44
+ args = self .settings .SKILL_ANALYZER .get ('args' ),
45
+ sensitivity = self .settings .SKILL_ANALYZER .get ('sensitivity' ),
46
+ )
47
47
48
48
def run (self ):
49
49
"""
@@ -61,26 +61,50 @@ def run(self):
61
61
skill = self .skill_analyzer .extract (transcript )
62
62
63
63
if skill :
64
- skill_to_execute = {'voice_transcript' : transcript , 'skill' : skill }
65
-
66
- response = self .response_creator .create_positive_response (transcript ) if skill_to_execute \
67
- else self .response_creator .create_negative_response (transcript )
64
+ # ----------------------------------------------------------------------------------------------------------
65
+ # Successfully extracted skill
66
+ # ----------------------------------------------------------------------------------------------------------
67
+
68
+ # ---------------
69
+ # Positive answer
70
+ # ---------------
71
+ response = self .response_creator .create_positive_response (transcript )
68
72
jarvis .output_engine .assistant_response (response )
69
73
74
+ # ---------------
75
+ # Skill execution
76
+ # ---------------
77
+ skill_to_execute = {'voice_transcript' : transcript , 'skill' : skill }
70
78
self ._execute_skill (skill_to_execute )
71
79
72
80
else :
73
- # If no skill to execute, it calls the WolframAlpha API
81
+ # ----------------------------------------------------------------------------------------------------------
82
+ # No skill extracted
83
+ # ----------------------------------------------------------------------------------------------------------
84
+
85
+ # ---------------
86
+ # Negative answer
87
+ # ---------------
88
+ response = self .response_creator .create_negative_response (transcript )
89
+ jarvis .output_engine .assistant_response (response )
90
+
91
+ # ---------------
92
+ # WolframAlpha API Call
93
+ # ---------------
74
94
skill_to_execute = {'voice_transcript' : transcript ,
75
95
'skill' : {'name' : WolframSkills .call_wolframalpha .__name__ }
76
96
}
77
97
78
98
response = WolframSkills .call_wolframalpha (transcript )
79
99
100
+ # --------------------------------------------------------------------------------------------------------------
101
+ # Add new record to history
102
+ # --------------------------------------------------------------------------------------------------------------
103
+
80
104
record = {'user_transcript' : transcript ,
81
105
'response' : response if response else '--' ,
82
106
'executed_skill' : skill_to_execute if skill_to_execute else '--'
83
- }
107
+ }
84
108
85
109
db .insert_many_documents ('history' , [record ])
86
110
@@ -94,5 +118,5 @@ def _execute_skill(self, skill):
94
118
skill_func = skill_objects [skill_func_name ]
95
119
skill_func (** skill )
96
120
except Exception as e :
97
- self .console_manager .console_output (error_log = "Failed to execute skill {0} with message {1}"
121
+ self .console_manager .console_output (error_log = "Failed to execute skill {0} with message: {1}"
98
122
.format (skill_func_name , e ))
0 commit comments