<commit_before><?php
/**
 * This file is part of the beebot package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright Bee4 2015
 * @author	<NAME> <<EMAIL>>
 * @package Bee4\RobotsTxt
 */

namespace Bee4\RobotsTxt;

/**
 * Class ParserFactory
 * Take an URL, try to load the robots.txt file and return the parsed rules
 * @package Bee4\RobotsTxt
 */
class ParserFactory
{
	public static function build($item) {
		if( filter_var($item, FILTER_VALIDATE_URL)!==false ) {
			$parsed = parse_url($item);
			if( isset($parsed['path']) && $parsed['path'] != '/robots.txt' ) {
				throw new \InvalidArgumentException(
					sprintf(
						'The robots.txt file can\'t be found at: %s this file
						must be hosted at website root', $item)
				);
			}

			$parsed['path'] = '/robots.txt';
			$parsed = array_intersect_key(
				$parsed,
				array_flip(['scheme', 'host', 'port', 'path'])
			);
			$port = isset($parsed['port'])?':'.$parsed['port']:'';
			$url = $parsed['scheme'].'://'.$parsed['host'].$port.$parsed['path'];

			$handle = curl_init();
			curl_setopt($handle, CURLOPT_URL, $url);
			curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
			$item = curl_exec($handle);
			$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
			curl_close($handle);

			if( $status !== 200 ) {
				throw new \RuntimeException('Can\'t access the robots.txt file at: '.$url);
			}
		}

		$parser = new Parser($item);
		return $parser->parse();
	}
}<commit_msg>Now return the parser instance instead of rule set<commit_after><?php
/**
 * This file is part of the beebot package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright Bee4 2015
 * @author	<NAME> <<EMAIL>>
 * @package Bee4\RobotsTxt
 */

namespace Bee4\RobotsTxt;

/**
 * Class ParserFactory
 * Take an URL, try to load the robots.txt file and return the parsed rules
 * @package Bee4\RobotsTxt
 */
class ParserFactory
{
	public static function build($item) {
		if( filter_var($item, FILTER_VALIDATE_URL)!==false ) {
			$parsed = parse_url($item);
			if( isset($parsed['path']) && $parsed['path'] != '/robots.txt' ) {
				throw new \InvalidArgumentException(
					sprintf(
						'The robots.txt file can\'t be found at: %s this file
						must be hosted at website root', $item)
				);
			}

			$parsed['path'] = '/robots.txt';
			$parsed = array_intersect_key(
				$parsed,
				array_flip(['scheme', 'host', 'port', 'path'])
			);
			$port = isset($parsed['port'])?':'.$parsed['port']:'';
			$url = $parsed['scheme'].'://'.$parsed['host'].$port.$parsed['path'];

			$handle = curl_init();
			curl_setopt($handle, CURLOPT_URL, $url);
			curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
			$item = curl_exec($handle);
			$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
			curl_close($handle);

			if( $status !== 200 ) {
				throw new \RuntimeException('Can\'t access the robots.txt file at: '.$url);
			}
		}

		return new Parser($item);
	}
}
{'fraction_non_alphanumeric': 0.16488153197013958, 'fraction_numerical': 0.007140538786108407, 'mean_word_length': 3.8231611893583723, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 10, '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': '4904602', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1033, 'n_words': 278}