<commit_before>module Swicky
  module ExhibitJson

    # Takes a number of triples and encodes them in the SIMILE JSON format.
    # See http://simile.mit.edu/wiki/Exhibit/Understanding_Exhibit_Database
    class ItemCollection

      def initialize(triples)
        @triples = triples
        triple_hash.each { |object, values| add_item(object, values) }
      end

      def to_json(*a)
        my_types = {}
        types.values.each { |t| my_types[t.id] = t }
        my_properties = {}
        properties.values.each { |p| my_properties[p.id] = p }
        {
          'items' => items.values,
          'types' => my_types,
          'properties' => my_properties
        }.to_json(*a)
      end

      def triple_hash
        @triple_hash ||= begin<commit_msg>Xpointer passthrough for exhibit json<commit_after>module Swicky
  module ExhibitJson

    # Takes a number of triples and encodes them in the SIMILE JSON format.
    # See http://simile.mit.edu/wiki/Exhibit/Understanding_Exhibit_Database
    class ItemCollection

      def initialize(triples, original_xpointer = nil)
        @triples = triples
        @original_xpointer = original_xpointer
        triple_hash.each { |object, values| add_item(object, values) }
      end

      def to_json(*a)
        my_types = {}
        types.values.each { |t| my_types[t.id] = t }
        my_properties = {}
        properties.values.each { |p| my_properties[p.id] = p }
        result = {
          'items' => items.values,
          'types' => my_types,
          'properties' => my_properties
        }
        result['annotation-for'] = @original_xpointer if(@original_xpointer)
        result.to_json(*a)
      end

      def triple_hash
        @triple_hash ||= begin
{'fraction_non_alphanumeric': 0.10213502596653203, 'fraction_numerical': 0.0, 'mean_word_length': 2.302857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5439514', 'n_tokens_mistral': 542, 'n_tokens_neox': 526, 'n_words': 121}