import os
from numpy import ones, zeros


PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

TRAINING_DATA_DIR_PATH = os.path.join(PROJECT_ROOT, "training_data")

SAVED_MODEL_DIR_PATH = os.path.join(PROJECT_ROOT, "models")

MAX_WORD_LENGTH = 80

MAX_SENTENCE_LENGTH = 30

IDENTITY_AUTO_ENCODER_TRAINING_DATA = os.path.join(TRAINING_DATA_DIR_PATH, "polish_words.txt")

MOVIE_LINES_RAW = os.path.join(TRAINING_DATA_DIR_PATH, "dialogs.txt")

DIALOG_FILES_DIR = os.path.join(TRAINING_DATA_DIR_PATH, "dialogs")

DIALOG_ALL_FILES_PATHS = [os.path.join(DIALOG_FILES_DIR, "dialogs_part_" + str(part) + ".txt") for part in range(500)]

DIALOG_TRAINING_FILES_PATHS = [os.path.join(DIALOG_FILES_DIR, "dialogs_part_" + str(part) + ".txt") for part in
                               range(500) if part % 5 != 0]

DIALOG_VALIDATION_FILES_PATHS = [os.path.join(DIALOG_FILES_DIR, "dialogs_part_" + str(part) + ".txt") for part in
                                 range(500) if part % 5 == 0]

WORD_2_VEC_PREPROCESSED_TRAINING_DATA = os.path.join(TRAINING_DATA_DIR_PATH, "dialogs_processed.txt")

ENCODING = "utf-8"

WORD_2_VEC_WINDOW = 10

VOCABULARY_SIZE = 20000

WORD_2_VEC_WORKERS = 2

WORD_2_VEC_MIN_COUNT = 5

TOKENIZER_MIN_COUNT = 50000

TOKENIZER_TOKEN_LIMIT = 5

WORD_2_VEC_EPOCHS = 10000

WORD_2_VEC_NUMBER_OF_FEATURES = 50

WORD_2_VEC_MODEL_PATH = os.path.join(SAVED_MODEL_DIR_PATH, "word_2_vec")

CONVERSATION_MODEL_PATH = os.path.join(SAVED_MODEL_DIR_PATH, "conversation_model.h5")
NORMALIZATION_MAGNITUDE = 0

CORRECTOR_PANDAS_BATCH_SIZE = 2000
CONVERSATION_NUMBER_OF_ENCODER_LAYERS = 4
CONVERSATION_NUMBER_OF_DECODER_LAYERS = 4
CONTEXT_VECTOR_SIZE = 1500
CONVERSATION_NUMBER_OF_EPOCHS = 300
CONVERSATIONS_MINI_BATCH_SIZE = 1
CONVERSATION_NUMBER_OF_LEARNING_STEPS = 1e4 // CONVERSATIONS_MINI_BATCH_SIZE
CATEGORICAL_INDEX_FILE_PATH = os.path.join(SAVED_MODEL_DIR_PATH, "categorical_indexes.json")
EOS_WORD = "[eos]"
UNKNOWN_WORD = "[unknown]"
PADDING_WORD = "[padding]"
PADDING_VECTOR_INDEX = 999

WORD_CACHE_SIZE = 200

CATEGORICAL_VECTOR_SIZE = 1000

CONVERSATION_GENERATOR_QUEUE_SIZE = 100

CONVERSATION_VALIDATION_PART_SIZE = int(CONVERSATION_NUMBER_OF_LEARNING_STEPS * 0.2)

WORD_2_VEC_NORMALIZATION_PARAMS_PATH = os.path.join(SAVED_MODEL_DIR_PATH, "normalization")

NEW_FILE_SYMBOL = "RESET_CONTEXT"
END_FILE_SYMBOL = "FILE_END"

INPUT_INVERTER = lambda sentence: sentence[::-1]