def construct_vocab(file_location, min_count, vocab_size):
    """ Constructing vocabulary for the dataset

        Keyword arguments:
        file_location : Location of the dataset(The dataset is assumed to be in a tokenized format)
        min_count : minimum count of each word to be included in the vocabulary
        vocab_size: Maximum vocabulary size allowed

        Output:
        id2word,word2id,id2counts,word_counts (self-explainable)
    """
    word_counts = dict()

    file = open(file_location,"r", encoding="utf-8")


    for i,line in enumerate(file):
        if i % 10000 == 0:
            print(str(i) + " lines processed.", end="\r")
        for word in line.split():
            word = word.lower()
            if word in word_counts:
                word_counts[word] += 1
            else:
                word_counts[word] = 1

    new_word_counts = dict()
    for word in word_counts:
        if word_counts[word] >= min_count:
            new_word_counts[word] = word_counts[word]

    sorted_word_counts = sorted(list(new_word_counts.items()),key=lambda count: count[1],reverse=True)
    if len(sorted_word_counts) > vocab_size:
        sorted_word_counts = sorted_word_counts[:vocab_size]

    word_counts = dict()
    word2id = dict()
    id2word = []
    id2counts = []
    i = 0

    for word_count_pair in sorted_word_counts:
        word_counts[word_count_pair[0]] = word_count_pair[1]
        word2id[word_count_pair[0]] = i
        id2word.append(word_count_pair[0])
        id2counts.append(word_count_pair[1])
        i+=1
    file.close()
    return id2word,word2id,id2counts,word_counts