Load exchange data and return dataset.

def load_exchange_word_vectors(
    filename                 = "database.db",
    maximum_number_of_events = None
    ):
    """
    Load exchange data and return dataset.
    """
    log.info("load word vectors of database {filename}".format(
        filename = filename
    ))
    # Ensure that the database exists.
    if not os.path.isfile(filename):
        log.info("database {filename} nonexistent".format(
            filename = filename
        ))
        program.terminate()
        raise Exception
    # Access the database.
    database = access_database(filename = filename)
    # Access or create the exchanges table.
    table_exchanges = database["exchanges"]
    # Access exchanges.
    table_name = "exchanges"
    # Create a datavision dataset.
    data = datavision.Dataset()
    # progress
    progress = shijian.Progress()
    progress.engage_quick_calculation_mode()
    number_of_entries = len(database[table_name])
    index = 0
    for index_entry, entry in enumerate(database[table_name].all()):
        if maximum_number_of_events is not None and\
            index >= int(maximum_number_of_events):
            log.info(
                "loaded maximum requested number of events " +
                "({maximum_number_of_events})\r".format(
                    maximum_number_of_events = maximum_number_of_events
                )
            )
            break
        #unique_identifier = str(entry["id"])
        utteranceWordVector = str(entry["utteranceWordVector"])
        responseWordVector = str(entry["responseWordVector"])
        if utteranceWordVector != "None" and responseWordVector != "None":
            index += 1

            utteranceWordVector = eval("np." + utteranceWordVector.replace("float32", "np.float32"))
            responseWordVector  = eval("np." + responseWordVector.replace("float32", "np.float32"))
            data.variable(index = index, name = "utteranceWordVector", value = utteranceWordVector)
            data.variable(index = index, name = "responseWordVector",  value = responseWordVector )

            #utteranceWordVector = list(eval("np." + utteranceWordVector.replace("float32", "np.float32")))
            #responseWordVector  = list(eval("np." + responseWordVector.replace("float32", "np.float32")))
            #for index_component, component in enumerate(utteranceWordVector):
            #    data.variable(index = index, name = "uwv" + str(index_component), value = component)
            #for index_component, component in enumerate(responseWordVector):
            #    data.variable(index = index, name = "rwv" + str(index_component), value = component)

        print progress.add_datum(fraction = index_entry / number_of_entries),
    return data