<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_document(self, question, answer):
 """Add question answer set to DB. :param question: A question to an answer :type question: :class:`str` :param answer: An answer to a question :type answer: :class:`str` """

        question = question.strip()
        answer = answer.strip()

        session = self.Session()

        if session.query(Document) \
                .filter_by(text=question, answer=answer).count():
            logger.info('Already here: {0} -> {1}'.format(question, answer))
            return
        logger.info('add document: {0} -> {1}'.format(question, answer))

        grams = self._get_grams(session, question, make=True)

        doc = Document(question, answer)
        doc.grams = list(grams)
        self._recalc_idfs(session, grams)

        session.add(doc)
        session.commit()