def construct_vocab(
        self, sentences, vocab_size, lowercase=False, charlevel=False
    ):
        """Create vocabulary.

        Args:
            sentences(list): The list of sentences.
            vocab_size(int): The size of vocabulary.
            lowercase(bool): If lowercase the sentences.
            charlevel(bool): If need to split the sentence with space.

        Returns:
            word2id(list): Word to index list.
            id2word(list): Index to word list.
        """
        vocab = {}
        for sentence in sentences:
            if isinstance(sentence, str):
                if lowercase:
                    sentence = sentence.lower()
                if not charlevel:
                    sentence = sentence.split()
            for word in sentence:
                if word not in vocab:
                    vocab[word] = 1
                else:
                    vocab[word] += 1
        word2id, id2word = self._trim_vocab(vocab, vocab_size)
        return word2id, id2word
Create vocabulary.

        Args:
            sentences(list): The list of sentences.
            vocab_size(int): The size of vocabulary.
            lowercase(bool): If lowercase the sentences.
            charlevel(bool): If need to split the sentence with space.

        Returns:
            word2id(list): Word to index list.
            id2word(list): Index to word list.
        
utils_nlp/models/gensen/utils.py