<commit_before>class LingrbotTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    @app ||= Rack::Builder.parse_file(File.join(base_dir, "config.ru")).first
  end

  def setup
    @request = File.read(File.join(fixtures_dir, "test-request.json"))
  end

  def test_parse
    post "/", @request
    assert_true(last_response.ok?)
    assert_empty(last_response.body)
  end

  def test_mecab
    post "/", @request.gsub("XXX", "%25mecab hoge")
    assert_true(last_response.ok?)
    assert_match(/\Ahoge\t.*(,.*){5}\n\z/, last_response.body)
  end

  def test_mora
    post "/", @request.gsub("XXX", "%25mora foo")
    assert_true(last_response.ok?)
    assert_equal("0", last_response.body)
  end

  def test_shogikoma
    post "/", @request.gsub("XXX", "%25shogikoma R")
    assert_true(last_response.ok?)
    assert_match(%r(\Ahttp://myokoym.net/lingrbot/shogikoma/\w+\.png\z),
                 last_response.body)
  end

  private<commit_msg>test: add a test for font option<commit_after>class LingrbotTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    @app ||= Rack::Builder.parse_file(File.join(base_dir, "config.ru")).first
  end

  def setup
    @request = File.read(File.join(fixtures_dir, "test-request.json"))
  end

  def test_parse
    post "/", @request
    assert_true(last_response.ok?)
    assert_empty(last_response.body)
  end

  def test_mecab
    post "/", @request.gsub("XXX", "%25mecab hoge")
    assert_true(last_response.ok?)
    assert_match(/\Ahoge\t.*(,.*){5}\n\z/, last_response.body)
  end

  def test_mora
    post "/", @request.gsub("XXX", "%25mora foo")
    assert_true(last_response.ok?)
    assert_equal("0", last_response.body)
  end

  def test_shogikoma
    post "/", @request.gsub("XXX", "%25shogikoma R")
    assert_true(last_response.ok?)
    assert_match(%r(\Ahttp://myokoym.net/lingrbot/shogikoma/\w+\.png\z),
                 last_response.body)
  end

  def test_shogikoma_with_font
    post "/", @request.gsub("XXX", "%25shogikoma --font KouzanBrushFontOTF R")
    assert_true(last_response.ok?)
    assert_match(%r(\Ahttp://myokoym.net/lingrbot/shogikoma/\w+\.png\z),
                 last_response.body)
  end

  private
{'fraction_non_alphanumeric': 0.15722700498414136, 'fraction_numerical': 0.008155867693701857, 'mean_word_length': 3.4787018255578093, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3476032', 'n_tokens_mistral': 849, 'n_tokens_neox': 815, 'n_words': 127}