<commit_before><?php

/**
 * Maps ranges from one set of numbers to another
 *
 * @author <NAME> 06/05/2007
 * @package sb_Math
 * 
 * $rangeMapper =new sb_Math_RangeMapper(Array(8,20), Array(10,100));
 * $rangeMapper->convert(50); //return 13.3 repeating
 * //basically 50 from the range of 10 to 100 is equivalent to 13.33 in the range of 8 to 20
 */
class sb_Math_RangeMapper{
 
	public function __construct($toRange, $fromRange){
		$this->toRange = $toRange;
		$this->fromRange = $fromRange;
		$toRangeDifference = $toRange[1]-$toRange[0];
		$fromRangeDifference = $fromRange[1]-$fromRange[0];

		if($fromRangeDifference == 0){
			$this->ratio = 1;
		} else {
			$this->ratio = $toRangeDifference/$fromRangeDifference;
		}

	}
	
	public function convert($fromRangeNumber){
		return (($fromRangeNumber-$this->fromRange[0])*$this->ratio)+$this->toRange[0];
	}
	
}
	



?><commit_msg>if range difference ratio is 1 then the original toRange[1] value is returned<commit_after><?php

/**
 * Maps ranges from one set of numbers to another
 *
 * @author <NAME> 06/05/2007
 * @package sb_Math
 * 
 * $rangeMapper =new sb_Math_RangeMapper(Array(8,20), Array(10,100));
 * $rangeMapper->convert(50); //return 13.3 repeating
 * //basically 50 from the range of 10 to 100 is equivalent to 13.33 in the range of 8 to 20
 */
class sb_Math_RangeMapper{
 
	public function __construct($toRange, $fromRange){
		$this->toRange = $toRange;
		$this->fromRange = $fromRange;
		$toRangeDifference = $toRange[1]-$toRange[0];
		$fromRangeDifference = $fromRange[1]-$fromRange[0];

		if($fromRangeDifference == 0){
			$this->ratio = 1;
		} else {
			$this->ratio = $toRangeDifference/$fromRangeDifference;
		}

	}
	
	public function convert($fromRangeNumber){
		if($this->ratio == 1){
			return $this->toRange[1];
		}
		return (($fromRangeNumber-$this->fromRange[0])*$this->ratio)+$this->toRange[0];
	}
	
}
	



?>
{'fraction_non_alphanumeric': 0.1569767441860465, 'fraction_numerical': 0.04756871035940803, 'mean_word_length': 4.317415730337078, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '2599985', 'n_tokens_mistral': 757, 'n_tokens_neox': 646, 'n_words': 154}