<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_ngrams(self, corpus, minimum, maximum, catalogue=None):
 """Adds n-gram data from `corpus` to the data store. :param corpus: corpus of works :type corpus: `Corpus` :param minimum: minimum n-gram size :type minimum: `int` :param maximum: maximum n-gram size :type maximum: `int` :param catalogue: optional catalogue to limit corpus to :type catalogue: `Catalogue` """

        self._initialise_database()
        if catalogue:
            for work in catalogue:
                for witness in corpus.get_witnesses(work):
                    self._add_text_ngrams(witness, minimum, maximum)
        else:
            for witness in corpus.get_witnesses():
                self._add_text_ngrams(witness, minimum, maximum)
        self._add_indices()
        self._analyse()