def getCmd(commandList): bestCmd=Command("no match found") bestCmd.confidence=50 #go through list of posible spoken commands for possibleCmdKey in commandList: #rmove the word sherlock possibleCmdKey.replace("Sherlock","") #compare each to all comand keys for cmd in Command.getCommands(): #get confidence cmd.confidence=fuzz.token_set_ratio(possibleCmdKey,cmd.key) #check if new closest command if (cmd.confidence>bestCmd.confidence): bestCmd.key=cmd.key bestCmd.confidence=cmd.confidence bestCmd.script=cmd.script bestCmd.transcript=possibleCmdKey if (bestCmd.confidence>90): return bestCmd #return best command to be executed return bestCmd