<commit_before><?php namespace thiagoalessio\TesseractOCR;

class ImageNotFoundException extends \Exception {}
class TesseractNotFoundException extends \Exception {}
class UnsuccessfulCommandException extends \Exception {}

class FriendlyErrors
{
	public static function checkImagePath($image)
	{
		if (file_exists($image)) return;

		$currentDir = __DIR__;
		$msg = array();
		$msg[] = "Error! The image \"$image\" was not found.";
		$msg[] = '';
		$msg[] = "The current __DIR__ is $currentDir";
		$msg = join(PHP_EOL, $msg);

		throw new ImageNotFoundException($msg);
	}

	public static function checkTesseractPresence($executable)
	{
		$cmd = stripos(PHP_OS, 'win') === 0
			? 'where.exe '.Command::escape($executable).' > NUL 2>&1'
			: 'type '.Command::escape($executable).' > /dev/null 2>&1';<commit_msg>Fix tesseract presence check with custom paths<commit_after><?php namespace thiagoalessio\TesseractOCR;

class ImageNotFoundException extends \Exception {}
class TesseractNotFoundException extends \Exception {}
class UnsuccessfulCommandException extends \Exception {}

class FriendlyErrors
{
	public static function checkImagePath($image)
	{
		if (file_exists($image)) return;

		$currentDir = __DIR__;
		$msg = array();
		$msg[] = "Error! The image \"$image\" was not found.";
		$msg[] = '';
		$msg[] = "The current __DIR__ is $currentDir";
		$msg = join(PHP_EOL, $msg);

		throw new ImageNotFoundException($msg);
	}

	public static function checkTesseractPresence($executable)
	{
		if (file_exists($executable)) return;

		$cmd = stripos(PHP_OS, 'win') === 0
			? 'where.exe '.Command::escape($executable).' > NUL 2>&1'
			: 'type '.Command::escape($executable).' > /dev/null 2>&1';
{'fraction_non_alphanumeric': 0.14994096812278632, 'fraction_numerical': 0.0059031877213695395, 'mean_word_length': 5.11913357400722, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '3705913', 'n_tokens_mistral': 576, 'n_tokens_neox': 542, 'n_words': 138}