<commit_before># coding: utf-8

module PDF
  class Reader
    class BrowserPage
      def initialize(ohash, pagenum)
        @ohash, @pagenum = ohash, pagenum
        @page_obj = get_page_obj(pagenum)
      end

      def fonts
        resources[:Font] || {}
      end

      def xobjects
        resources[:XObject] || {}
      end

      def text
        # TODO
      end

      def walk(receiver)
        content_stream(receiver, raw_content)
      end

      # returns the raw content stream for this page. This is plumbing, nothing to
      # see unless you're a PDF nerd like me.
      #
      def raw_content
        contents = ohash.object(@page_obj[:Contents])
        [contents].flatten.compact.map { |obj|
          ohash.object(obj)
        }.map { |obj|<commit_msg>BrowserPage#fonts should return wrapped Font objects<commit_after># coding: utf-8

module PDF
  class Reader
    class BrowserPage
      def initialize(ohash, pagenum)
        @ohash, @pagenum = ohash, pagenum
        @page_obj = get_page_obj(pagenum)
      end

      def fonts
        raw_fonts = resources[:Font] || {}
        ::Hash[raw_fonts.map { |label, font|
          [label, PDF::Reader::Font.new(ohash, ohash.object(font))]
        }]
      end

      def xobjects
        resources[:XObject] || {}
      end

      def text
        # TODO
      end

      def walk(receiver)
        content_stream(receiver, raw_content)
      end

      # returns the raw content stream for this page. This is plumbing, nothing to
      # see unless you're a PDF nerd like me.
      #
      def raw_content
        contents = ohash.object(@page_obj[:Contents])
        [contents].flatten.compact.map { |obj|
          ohash.object(obj)
        }.map { |obj|
{'fraction_non_alphanumeric': 0.09474292316580012, 'fraction_numerical': 0.0011554015020219526, 'mean_word_length': 2.0121739130434784, 'pattern_counts': {'":': 0, '<': 3, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7125064', 'n_tokens_mistral': 546, 'n_tokens_neox': 516, 'n_words': 143}