

class TophostPortraitTextPreprocessor(object):
    def __init__(self):
        """
        This text preprocessor is implemented for tophost-portrait to remove some reduant text
        """
        self.end_removal = [' free photo', ' premium photo']

    def __call__(self, text):
        for txt in self.end_removal:
            if text.endswith(txt):
                text = txt.join(text.split(txt)[:-1])
                break
        return text
            