<commit_before># @abstract Handles GmVault directory structure and mails/metadata
#
# @author <NAME> <<EMAIL>>

VCS_GMV_ID = "$Id: gmvault.rb,v 8aa5c9d46616 2012/09/18 15:53:13 roberto $"

# Non-standard packages
#
require "json"

# Handle GmVault mails with .eml as raw mail and .meta as metadata (i.e.tags)
#
class GMail
  attr_reader :name
  attr_reader :meta
  attr_reader :tags

  # @param filename name of the file to open
  def initialize(filename)
    @path, ext = filename.split(/\./)
    raise ArgumentError if ext != "meta"
    raise ArgumentError if not File.exists?(filename)
    @name = File.basename(@path)
    @mail = nil
    @tags = []
    self.load
  end # -- initialize

  # Preload metadata
  # @return [String] returns the mail id
  def load
    File.open(self.meta_path) do |fh|
      @meta = JSON.load(fh)
    end

    # check consistency
    raise DataError if @meta.nil?
    if @name.to_i != @meta["gm_id"] then<commit_msg>More meaningful exception messages.<commit_after># @abstract Handles GmVault directory structure and mails/metadata
#
# @author <NAME> <<EMAIL>>

VCS_GMV_ID = "$Id: gmvault.rb,v 6fc5132a4c97 2012/09/18 15:53:46 roberto $"

# Non-standard packages
#
require "json"

# Handle GmVault mails with .eml as raw mail and .meta as metadata (i.e.tags)
#
class GMail
  attr_reader :name
  attr_reader :meta
  attr_reader :tags

  # @param filename name of the file to open
  def initialize(filename)
    @path, ext = filename.split(/\./)
    raise(ArgumentError, "File should end in .meta: #{filename}") if ext != "meta"
    raise(ArgumentError, "File does not exist #{filename}") if not File.exists?(filename)
    @name = File.basename(@path)
    @mail = nil
    @tags = []
    self.load
  end # -- initialize

  # Preload metadata
  # @return [String] returns the mail id
  def load
    File.open(self.meta_path) do |fh|
      @meta = JSON.load(fh)
    end

    # check consistency
    raise DataError if @meta.nil?
    if @name.to_i != @meta["gm_id"] then
{'fraction_non_alphanumeric': 0.11973947895791583, 'fraction_numerical': 0.022044088176352707, 'mean_word_length': 3.331887201735358, 'pattern_counts': {'":': 0, '<': 9, '<?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': '727595', 'n_tokens_mistral': 723, 'n_tokens_neox': 682, 'n_words': 211}