<commit_before>module Normalizers
  class TelegaBasicNormalizer < Normalizers::RssNormalizer
    protected

    def text
      Service::Html.post_excerpt(
        content,
        link: sanitized_link,
        separator: separator
      )
    end

    def sanitized_link
      entity.link.to_s.gsub(%r{^//}, 'https://')
    end

    private

    def content
      (paragraphs[0..-1] || []).join("\n\n")
    end

    def paragraphs
      Service::Html.paragraphs(entity.description)
    end
  end
end<commit_msg>Support images for the Telega normalizer<commit_after>module Normalizers
  class TelegaBasicNormalizer < Normalizers::RssNormalizer
    protected

    def text
      Service::Html.post_excerpt(
        content,
        link: sanitized_link,
        separator: separator
      )
    end

    def sanitized_link
      entity.link.to_s.gsub(%r{^//}, 'https://')
    end

    def attachments
      image_url ? [image_url] : []
    end

    private

    def content
      (paragraphs[0..-1] || []).join("\n\n")
    end

    def paragraphs
      Service::Html.paragraphs(entity.description)
    end

    def image_url
      html = Nokogiri::HTML(entity.description)
      html.css('img').first.attributes['src'].value
    rescue StandardError
      nil
    end
  end
end
{'fraction_non_alphanumeric': 0.10666666666666667, 'fraction_numerical': 0.003137254901960784, 'mean_word_length': 2.3490813648293964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '515707', 'n_tokens_mistral': 412, 'n_tokens_neox': 390, 'n_words': 82}