<commit_before>#!/usr/bin/python

import unittest

def benfords_law(text):
	words = text.split()
	digits = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}
	for word in words:
		if word[0].isdigit():
			digits[int(word[0])] += 1
	return str(digits) + "\nnot passed\n"

class test_benfords_law(unittest.TestCase):
	def test_one_number(self):
		text = "12345"
		digits = {1:1, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}
		output = str(digits) + "\nnot passed\n"
		self.assertEqual(benfords_law(text), output)

	def test_two_numbers_separated_by_space(self):
		text = "12345 234"
		digits = {1:1, 2:1, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}
		output = str(digits) + "\nnot passed\n"
		self.assertEqual(benfords_law(text), output)

unittest.main()<commit_msg>format_result function extracted<commit_after>#!/usr/bin/python

import unittest

def format_result(digits, whether_passed):
	return str(digits) + "\n" + whether_passed + "\n"

def benfords_law(text):
	words = text.split()
	digits = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}
	for word in words:
		if word[0].isdigit():
			digits[int(word[0])] += 1
	return format_result(digits, "not passed")

class test_benfords_law(unittest.TestCase):
	def test_one_number(self):
		text = "12345"
		digits = {1:1, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}
		self.assertEqual(benfords_law(text), format_result(digits, "not passed"))

	def test_two_numbers_separated_by_space(self):
		text = "12345 234"
		digits = {1:1, 2:1, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}
		self.assertEqual(benfords_law(text), format_result(digits, "not passed"))

unittest.main()
{'fraction_non_alphanumeric': 0.1863550221099179, 'fraction_numerical': 0.08843967150979154, 'mean_word_length': 5.068965517241379, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2172240', 'n_tokens_mistral': 813, 'n_tokens_neox': 710, 'n_words': 151}