Refactoring of the TdIdf class