<commit_before><?php
namespace elasticsearch;

/**
* This class provides numerous helper methods for working with facet information returned from elastic search results.
*
* @license http://opensource.org/licenses/MIT
* @author <NAME> <<EMAIL>>
* @version 2.0.0
**/
class Faceting{
	/**
	* A convenient method that aggregates the results of all the other methods in the class. Example of output:
	*
	* <code>
	* 	array(
	*		// the keys are names of fields and/or taxonomies
	* 		'taxonomy' => array(
	* 			'available' => array(
	* 				'taxonomy1'	=> array(
	* 					'count'	=> 10,
	* 					'slug'	=> 'taxonomy1',
	* 					'name'	=> 'Taxonomy One',
	* 					'font'	=> 24
	* 				)
	* 			),
	* 			'selected' => array(
	* 				'taxonomy2'	=> array(
	* 					'slug'	=> 'taxonomy2',
	* 					'name'	=> 'Taxonomy Two'
	* 				)
	* 			),
	* 			'total' => 10
	* 		),
	* 		'rating' => array(
	* 			'available' => array(
	* 				'10-20' => array(
	* 					'count'	=> 4,
	* 					'slug'	=> '10-20',
	* 					'to'	=> 20,
	* 					'from'	=> 10
	* 				)			
	* 			),
	* 			'total' => 4
	* 		)
	* 	)
	* </code>
	* 
	* @param string $minFont The minimum font size to use for display in a tag cloud (defaults to : 12)
	* @param string $maxFont The maximum font size to use for display in a tag cloud (defaults to : 24)
	* 
	* @return array An associative array where the keys represent the data point with a list of selected and/or available options.
	**/
	static function all($minFont = 12, $maxFont = 24){
		$options = array();

		foreach(Config::taxonomies() as $tax){
			$options[$tax] = self::taxonomy($tax);
		}

		$numeric = Config::option('numeric');

		foreach(Config::fields() as $field){
			if(isset($numeric[$field])){
				$options[$field] = self::range($field);
			}

			if($field == 'post_type'){
				$options['post_type'] = self::types(Config::types());
			}
		}

		foreach(Config::meta_fields() as $field){
			if(isset($numeric[$field])){
				$options[$field] = self::range($field);
			}
		}

		foreach($options as $name => &$field){
			if(isset($field['available'])){
				foreach($field['available'] as &$available){
					$available['font'] = self::cloud($field['available'], $available, $minFont, $maxFont);<commit_msg>As per comment, use array_merge instead of two for loops to create range indexes<commit_after><?php
namespace elasticsearch;

/**
* This class provides numerous helper methods for working with facet information returned from elastic search results.
*
* @license http://opensource.org/licenses/MIT
* @author <NAME> <<EMAIL>>
* @version 2.0.0
**/
class Faceting{
	/**
	* A convenient method that aggregates the results of all the other methods in the class. Example of output:
	*
	* <code>
	* 	array(
	*		// the keys are names of fields and/or taxonomies
	* 		'taxonomy' => array(
	* 			'available' => array(
	* 				'taxonomy1'	=> array(
	* 					'count'	=> 10,
	* 					'slug'	=> 'taxonomy1',
	* 					'name'	=> 'Taxonomy One',
	* 					'font'	=> 24
	* 				)
	* 			),
	* 			'selected' => array(
	* 				'taxonomy2'	=> array(
	* 					'slug'	=> 'taxonomy2',
	* 					'name'	=> 'Taxonomy Two'
	* 				)
	* 			),
	* 			'total' => 10
	* 		),
	* 		'rating' => array(
	* 			'available' => array(
	* 				'10-20' => array(
	* 					'count'	=> 4,
	* 					'slug'	=> '10-20',
	* 					'to'	=> 20,
	* 					'from'	=> 10
	* 				)			
	* 			),
	* 			'total' => 4
	* 		)
	* 	)
	* </code>
	* 
	* @param string $minFont The minimum font size to use for display in a tag cloud (defaults to : 12)
	* @param string $maxFont The maximum font size to use for display in a tag cloud (defaults to : 24)
	* 
	* @return array An associative array where the keys represent the data point with a list of selected and/or available options.
	**/
	static function all($minFont = 12, $maxFont = 24){
		$options = array();

		foreach(Config::taxonomies() as $tax){
			$options[$tax] = self::taxonomy($tax);
		}

		$numeric = Config::option('numeric');

		foreach(array_merge(Config::fields(),Config::meta_fields()) as $field){
			if(isset($numeric[$field])){
				$options[$field] = self::range($field);
			}

			if($field == 'post_type'){
				$options['post_type'] = self::types(Config::types());
			}
		}

		foreach($options as $name => &$field){
			if(isset($field['available'])){
				foreach($field['available'] as &$available){
					$available['font'] = self::cloud($field['available'], $available, $minFont, $maxFont);
{'fraction_non_alphanumeric': 0.17891373801916932, 'fraction_numerical': 0.01597444089456869, 'mean_word_length': 3.065862708719852, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 55, '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': '753222', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1621, 'n_words': 404}