def _recalc_idfs(self, session, grams=None):
        """Re-calculate idfs for database.

        calculating idfs for gram is taking long time.
        So I made it calculates idfs for some grams.
        If you want make accuracy higher, use this with grams=None.

        :param session: DB session
        :type session: :class:`sqlalchemt.orm.Session`

        :param grams: grams that you want to re-calculating idfs
        :type grams: A set of :class:`Gram`

        """

        if not grams:
            grams = session.query(Gram)
        for gram in grams:
            orig_idf = gram.idf
            gram.idf = self._get_idf(session, gram)
            logger.debug('Recalculating {} {} -> {}'.format(
                gram.gram, orig_idf, gram.idf))
Re-calculate idfs for database.

        calculating idfs for gram is taking long time.
        So I made it calculates idfs for some grams.
        If you want make accuracy higher, use this with grams=None.

        :param session: DB session
        :type session: :class:`sqlalchemt.orm.Session`

        :param grams: grams that you want to re-calculating idfs
        :type grams: A set of :class:`Gram`