<commit_before># Copyright (c) 2008 The Kaphan Foundation
#
# Possession of a copy of this file grants no permission or license
# to use, modify, or create derivate works.
# Please contact <EMAIL> for further information.
#
FixBase = File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures')

require File.dirname(__FILE__) + '/spec_helper.rb'
gem 'ratom'
require 'atom'

describe "Classify" do  
  describe "file" do
    before(:each) do
      FileUtils.rm_f("/tmp/taggings.atom")
    end

    it "should classify a file" do
      classify(FixBase + "/valid", 'file:' + FixBase + "/file_tag.atom")
      File.exist?("/tmp/taggings.atom").should be_true
    end

    it "should have taggings for each entry" do
      classify(FixBase + "/valid", 'file:' + FixBase + "/file_tag.atom")
      Atom::Feed.load_feed(File.open("/tmp/taggings.atom")).should have(10).entries    
    end
  end
  
  describe "directory" do
    before(:each) do
      FileUtils.rm_rf("/tmp/taggings")
      FileUtils.mkdir_p("/tmp/taggings")
    end
    
    it "should classify all files" do
      classify(FixBase + "/valid", File.dirname(__FILE__) + '/fixtures/tag_dir')
      Dir.glob("/tmp/taggings/*.atom").size.should == Dir.glob(FixBase + "/tag_dir/*.atom").size
    end
  end
  
  def classify(corpus, tag)
    cmd = File.join(ROOT, '../src/classify')
    
    if ENV['srcdir']
      cmd = File.join(ENV['PWD'], '../src/classify')
    end
    
    system("#{cmd} #{corpus} #{tag}")
  end
end<commit_msg>Redirect logging in classify spec<commit_after># Copyright (c) 2008 The Kaphan Foundation
#
# Possession of a copy of this file grants no permission or license
# to use, modify, or create derivate works.
# Please contact <EMAIL> for further information.
#
FixBase = File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures')

require File.dirname(__FILE__) + '/spec_helper.rb'
gem 'ratom'
require 'atom'

describe "Classify" do  
  describe "file" do
    before(:each) do
      FileUtils.rm_f("/tmp/taggings.atom")
    end

    it "should classify a file" do
      classify(FixBase + "/valid", 'file:' + FixBase + "/file_tag.atom")
      File.exist?("/tmp/taggings.atom").should be_true
    end

    it "should have taggings for each entry" do
      classify(FixBase + "/valid", 'file:' + FixBase + "/file_tag.atom")
      Atom::Feed.load_feed(File.open("/tmp/taggings.atom")).should have(10).entries    
    end
  end
  
  describe "directory" do
    before(:each) do
      FileUtils.rm_rf("/tmp/taggings")
      FileUtils.mkdir_p("/tmp/taggings")
    end
    
    it "should classify all files" do
      classify(FixBase + "/valid", File.dirname(__FILE__) + '/fixtures/tag_dir')
      Dir.glob("/tmp/taggings/*.atom").size.should == Dir.glob(FixBase + "/tag_dir/*.atom").size
    end
  end
  
  def classify(corpus, tag)
    cmd = File.join(ROOT, '../src/classify')
    
    if ENV['srcdir']
      cmd = File.join(ENV['PWD'], '../src/classify')
    end
    
    system("#{cmd} #{corpus} #{tag} 2> /dev/null")
  end
end
{'fraction_non_alphanumeric': 0.1514749751408684, 'fraction_numerical': 0.004308916141862778, 'mean_word_length': 3.117326057298772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '2189722', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1016, 'n_words': 251}