def runLoki(input_str): resultDICT = {} lokiRst = LokiResult(input_str) for i in range(0, lokiRst.getLen()): # Exchange if lokiRst.getIntent(i) == "Exchange": resultDICT = Loki_Exchange.getResult(lokiRst.getPattern(i), lokiRst.getArgs(i), resultDICT) getCurrencyExRate() # 兌換數字 * 貨幣轉換匯率 resultDICT["answer"] = amountSTRconvert(resultDICT["amount"]) * getSrc2TgtCurrencyExRate(resultDICT["source"], resultDICT["target"]) return resultDICT
def runLoki(inputLIST, filterLIST=[]): resultDICT = {"config": configDICT, "result_list": []} lokiRst = LokiResult(inputLIST, filterLIST) if lokiRst.getStatus(): for index, key in enumerate(inputLIST): for resultIndex in range(0, lokiRst.getLokiLen(index)): # Exchange if lokiRst.getIntent(index, resultIndex) == "Exchange": resultDICT = Loki_Exchange.getResult( key, lokiRst.getUtterance(index, resultIndex), lokiRst.getArgs(index, resultIndex), resultDICT) else: resultDICT = {"msg": lokiRst.getMessage()} return resultDICT