<commit_before><?php

class bencode {

	public function __construct()
	{
	}

	//construct bencode 
	//(assoc array)$array = arguments (query node ID, target, info hash), 
	//(assoc array)$type = protocol stuff
	public static function encode($array,$type)
	{
		print_r($array);
		print_r($type);
		
		//dictionary 1 start
		$ret = "d1:a";
		
		//dictionary 2 start
		$ret .= "d";
		foreach($array as $key => $value)
		{
			$ret .= strlen($key) . ":" . $key . strlen($value) . ":" . $value;
		}
		$ret .= "e";
		//dictionary 2 finish
		
		foreach($type as $key => $value)
		{
			$ret .= strlen($key) . ":" . $key . strlen($value) . ":" . $value;
		}
		
		$ret .= "e";
		//dictionary 1 finish
		
		echo "construct_bencode output = \n" . $ret . "\n";
		return $ret;
	}

	
	/**
	 * Decodes an bencoded string to data
	 *
	 * @param   string  String to decode
	 * @return  mixed   Outputted data
	 */<commit_msg>removed debugging output in bencoded.php<commit_after><?php

class bencode {

	public function __construct()
	{
	}

	//construct bencode 
	//(assoc array)$array = arguments (query node ID, target, info hash), 
	//(assoc array)$type = protocol stuff
	public static function encode($array,$type)
	{
		//dictionary 1 start
		$ret = "d1:a";
		
		//dictionary 2 start
		$ret .= "d";
		foreach($array as $key => $value)
		{
			$ret .= strlen($key) . ":" . $key . strlen($value) . ":" . $value;
		}
		$ret .= "e";
		//dictionary 2 finish
		
		foreach($type as $key => $value)
		{
			$ret .= strlen($key) . ":" . $key . strlen($value) . ":" . $value;
		}
		
		$ret .= "e";
		//dictionary 1 finish
		
		return $ret;
	}

	
	/**
	 * Decodes an bencoded string to data
	 *
	 * @param   string  String to decode
	 * @return  mixed   Outputted data
	 */
{'fraction_non_alphanumeric': 0.17765042979942694, 'fraction_numerical': 0.0057306590257879654, 'mean_word_length': 2.548780487804878, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 7, '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': '3067356', 'n_tokens_mistral': 705, 'n_tokens_neox': 600, 'n_words': 172}