MCPcopy Create free account
hub / github.com/DragonComputer/Dragonfire / command

Method command

dragonfire/__init__.py:179–589  ·  view source on GitHub ↗

Function that serves as the entry point for each one of the user commands. This function goes through these steps for each one of user's commands, respectively: - Search across the built-in commands via a simple if-else control flow. - Try to get a response from :func:`drag

(self, com)

Source from the content-addressed store, hash-verified

177
178
179 def command(self, com):
180 """Function that serves as the entry point for each one of the user commands.
181
182 This function goes through these steps for each one of user's commands, respectively:
183
184 - Search across the built-in commands via a simple if-else control flow.
185 - Try to get a response from :func:`dragonfire.arithmetic.arithmetic_parse` function.
186 - Try to get a response from :func:`dragonfire.learn.Learner.respond` method.
187 - Try to get a answer from :func:`dragonfire.odqa.ODQA.respond` method.
188 - Try to get a response from :func:`dragonfire.deepconv.DeepConversation.respond` method.
189
190 Args:
191 com (str): User's command.
192
193 Returns:
194 str: Response.
195 """
196
197 if not self.args["server"]:
198 global config_file
199 global e
200 if (e.is_set()): # System Tray Icon exit must trigger this
201 exit(0)
202 args = self.args
203 userin = self.userin
204 user_full_name = self.user_full_name
205 user_prefix = self.user_prefix
206 if self.testing:
207 config_file = self.config_file
208
209 if isinstance(com, str) and com:
210 com = com.strip()
211 else:
212 return False
213
214 print("You: " + com.upper())
215 doc = nlp(com)
216 h = Helper(doc)
217 self.h = h
218
219 if args["verbose"]:
220 userin.pretty_print_nlp_parsing_results(doc)
221
222 # Input: DRAGONFIRE | WAKE UP | HEY
223 if self.inactive and not self.check_wake_up_intent:
224 return ""
225
226 # User is answering to Dragonfire
227 if user_answering['status']:
228 if com.startswith("FIRST") or com.startswith("THE FIRST") or com.startswith("SECOND") or com.startswith("THE SECOND") or com.startswith("THIRD") or com.startswith("THE THIRD"):
229 user_answering['status'] = False
230 selection = None
231 if com.startswith("FIRST") or com.startswith("THE FIRST"):
232 selection = 0
233 elif com.startswith("SECOND") or com.startswith("THE SECOND"):
234 selection = 1
235 elif com.startswith("THIRD") or com.startswith("THE THIRD"):
236 selection = 2

Calls 15

wikisearchMethod · 0.95
check_wake_up_intentMethod · 0.95
check_verb_lemmaMethod · 0.95
check_noun_lemmaMethod · 0.95
directly_equalMethod · 0.95
check_nth_lemmaMethod · 0.95
check_wh_lemmaMethod · 0.95
check_deps_containsMethod · 0.95
check_textMethod · 0.95
check_lemmaMethod · 0.95

Tested by 8

test_builtin_commandsFunction · 0.64
test_arithmetic_responseFunction · 0.64
test_learner_responseFunction · 0.64
test_odqa_responseFunction · 0.64
test_deepconv_responseFunction · 0.64