<commit_before>module EntityNormalizers
  class EsquirePhotosNormalizer < EntityNormalizers::RssNormalizer
    def text
      [description, link].reject(&:blank?).join(separator)
    end

    def published_at
      parts = /(\d\d)(\d\d)(\d\d\d\d)/.match(link)
      DateTime.new(Integer(parts[3]), Integer(parts[2]), Integer(parts[1]))
    rescue
      DateTime.now
    end

    def attachments
      [image_url]
    end

    private

    def image_url
      Service::Html.first_image_url(entity.description)
    end

    READ_MORE_LINK = /\s*Читать дальше\s*/.freeze

    def description
      Service::Html.excerpt(entity.description, length: max_length).
        gsub(READ_MORE_LINK, '')
    end

    def max_length
      Const::Content::MAX_UNCOLLAPSED_POST_LENGTH -
        separator.length - link.length
    end
  end
end<commit_msg>Fix entity titles for the Esquire feed #39<commit_after>module EntityNormalizers
  class EsquirePhotosNormalizer < EntityNormalizers::RssNormalizer
    def text
      [entity.title, link].reject(&:blank?).join(separator)
    end

    def published_at
      parts = /(\d\d)(\d\d)(\d\d\d\d)/.match(link)
      DateTime.new(Integer(parts[3]), Integer(parts[2]), Integer(parts[1]))
    rescue
      super
    end

    def attachments
      [image_url]
    end

    def comments
      [description]
    end

    private

    def image_url
      Service::Html.first_image_url(entity.description)
    end

    READ_MORE_LINK = /\s*Читать дальше\s*/.freeze

    def description
      Service::Html.excerpt(entity.description, length: max_length).
        gsub(READ_MORE_LINK, '')
    end

    def max_length
      Const::Content::MAX_UNCOLLAPSED_POST_LENGTH -
        separator.length - link.length
    end
  end
end
{'fraction_non_alphanumeric': 0.10933028048082427, 'fraction_numerical': 0.0045792787635947334, 'mean_word_length': 2.8082788671023966, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '249465', 'n_tokens_mistral': 590, 'n_tokens_neox': 553, 'n_words': 104}