def __store_context(
     self, id_context: int, content: str, text_transformer: TextTransformer
 ):
     context = Context(content)
     context.encode(text_transformer)
     url_without_extension = self.url.split(".")[0]
     context_pickle_name = "{}_{}_{}_{}.p".format(
         text_transformer.embedding_model_label,
         text_transformer.pooling_modes,
         url_without_extension,
         id_context,
     )
     with open("contexts/{}".format(context_pickle_name), "wb") as target_file:
         dump(context, target_file)
     self.__nb_contexts += 1
示例#2
0
def nldslcompute(input: str, sql=False):
    context = Context()
    suggestions = []  # the list of results in the end
    results = []  # a list of possible results = suggestions

    #if there is no entry, return special suggestion:
    if input == "":
        return [{
            "suggestion": "Please type in the Input",
            "chance": 1.0,
            "result": "nothing typed in yet"
        }]

    # the suggestions contain all possible solutions

    #get the list of existing columns
    columns = getcolumns()
    context.columns = columns  # add it to the context
    context.entity = "flight"

    ## preprocessing
    # right now preprocessing is done in the inltosql function

    # the main function! Convert the NL to list of (p_i,INL_i), while p_i is the probability, that INL_i
    # is correct
    inllist: list = nltoinl(input)

    for inltuple in inllist:
        if sql:
            sqlob: NQL = NQL.fromsql(input)
        else:
            sqlob: NQL = inltoobj.inltosqlobj(inltuple[1], context)
        results.append((inltuple[0], sqlob.title, str(sqlob)))

    for e in results:
        suggestions.append({
            "suggestion": e[1],
            "chance": e[0],
            "result": e[2]
        })
    if len(results) == 0:
        suggestions.append({
            "suggestion": "No Suggestions",
            "chance": 1.0,
            "result": "No matching suggestion found =("
        })

    return suggestions
示例#3
0
def main():
    # logger configuration
    # FIXME Problème avec la récupération de la configuration
    logger_init(logging.DEBUG)
    config = read_configuration("config.cfg")
    ctx = Context(config)
    logging.info(
        "🔥🔥🔥 TradingBot just spawned, start program. 🔥🔥🔥")
    # Setup core system features
    queueTimer = Queue()
    queueTrader = Queue()
    signal.signal(signal.SIGINT, service_shutdown)
    try:
        t1 = WorkerDataGetter(queueTimer, queueTrader, ctx)
        t1.start()
        t2 = WorkerTrader(queueTrader, ctx)
        t2.start()
        t3 = WorkerAsset(ctx)
        t3.start()
        while True:
            time.sleep(60)
            queueTimer.put(537)

    except ServiceExit:
        # Terminate the running threads.
        # Set the shutdown flag on each thread to trigger a clean shutdown of each thread.
        t1.shutdown_flag.set()
        t2.shutdown_flag.set()
        t3.shutdown_flag.set()
        # Wait for the threads to close...
        t1.join()
        t2.join()
        t3.join()
示例#4
0
 def setUp(self):
     config = read_configuration("config.cfg")
     self.ctx = Context(config)
     if os.path.exists("data/raw/{}_{}.csv".format(self.ctx.pairs[0],
                                                   self.ctx.timeframes[0])):
         os.remove("data/raw/{}_{}.csv".format(self.ctx.pairs[0],
                                               self.ctx.timeframes[0]))
示例#5
0
 def __init__(self, user_controller, profile_controller, post_controller):
     self.__user_controller = user_controller
     self.__profile_controller = profile_controller
     self.__post_controller = post_controller
     self.__context = Context()
     self.__next_menus = {
         '1': lambda *_: raise_exception(ExitFromMenuException)
     }
示例#6
0
 def process_context_update_event(self, event):
     context = event.obj
     i = 0
     while self.contexts_model.item(i):
         if context.id == self.contexts_model.item(i).context.id:
             if event.notification.notification_type == NOTIFICATION_TYPE_UPDATED:
                 self.contexts_model.item(i).context = Context(event.obj.to_json())
                 self.tableView.editObject(self.contexts_model.item(i).context)
                 break
         i += 1
示例#7
0
    def process_context_add_event(self, event):
        application = self.applications[self.appsCombobox.currentIndex()]
        context = event.obj
        if not context.application_id == application["id"]:
            return

        item = ContextItem(Context(context.to_json()))
        item.setEditable(False)
        for key in application:
            subitem = ModelItem(key, Model(application.schema[key].to_json()))
            subitem.setEditable(False)
            item.appendRow(subitem)
        self.contexts_model.appendRow(item)
示例#8
0
 def __init__(self, user_controller, profile_controller, post_controller):
     self.__user_controller = user_controller
     self.__profile_controller = profile_controller
     self.__post_controller = post_controller
     self.__context = Context()
示例#9
0
 def setUp(self):
     config = read_configuration("config.cfg")
     self.ctx = Context(config)
示例#10
0
 def setUp(self):
     config = read_configuration("config.cfg")
     self.ctx = Context(config)
     self.ctx.trades_history_file = "test_trade_history.csv"
     self.trade_test_id = ""
示例#11
0
 def __init__(self, inputs):
     self.file = config.getWorkflowsFile()
     self.list = openJSON(self.file)
     self.current = -1
     self.context = Context(inputs)