<commit_before><?php
/**
 * @package framework.indexer.query
 */
class indexer_RangeQuery extends indexer_QueryBase implements indexer_Query
{
	/**
	 * @var mixed
	 */
	private $min = null;

	/**
	 * @var mixed
	 */
	private $max = null;

	/**
	 * @var String
	 */
	private $field = null;

	public function __construct($field, $min = null, $max = null)
	{
		if (is_null($max) && is_null($min))
		{
			throw new IllegalArgumentException('$min and $max arguments can not be both null');
		}
		$this->field = $field;
		if ($min instanceof date_Calendar )
		{
			$this->min = date_DateFormat::format($min, indexer_Field::SOLR_DATE_FORMAT);
		}
		else
		{
			$this->min = $min;
		}
		if ($max instanceof date_Calendar )
		{
			$this->max = date_DateFormat::format($max, indexer_Field::SOLR_DATE_FORMAT);
		}
		else
		{
			$this->max = $max;
		}
	}

	/**
	 * Sets the range's maximum value to $value (inclusive)
	 *
	 * @param Mixed $value
	 * @return indexer_RangeQuery
	 */
	public function setMaxValue($value)
	{
		$this->max = $value;
		return $this;
	}

	/**
	 * Sets the range's minimum value to $value (inclusive)
	 *
	 * @param Mixed $value
	 * @return indexer_RangeQuery
	 */
	public function setMinValue($value)
	{
		$this->min = $value;
		return $this;
	}

	/**
	 * @return String
	 */
	public function toSolrString()
	{
		return $this->field . ":[" . $this->wildCardIfNull($this->min) . ' TO ' . $this->wildCardIfNull($this->max) . "]";
	}

	/**
	 * Insert wildcard if needed for null min/max arguments
	 *
	 * @param mixed $val
	 * @return String
	 */
	private function wildCardIfNull($val)
	{
		return is_null($val) ? "*" : strval($val);
	}
}
<commit_msg>[NEW] RangeQuery can now be exclusive<commit_after><?php
/**
 * @package framework.indexer.query
 */
class indexer_RangeQuery extends indexer_QueryBase implements indexer_Query
{
	/**
	 * @var mixed
	 */
	private $min = null;

	/**
	 * @var mixed
	 */
	private $max = null;

	/**
	 * @var String
	 */
	private $field = null;
	
	private $sepStart = "[";
	private $sepEnd = "]";

	/**
	 * Construct a range, including min and max. Use <code>setExclusive()</code> to exclude min and max
	 * @param String $field
	 * @param String $min
	 * @param String $max
	 */
	public function __construct($field, $min = null, $max = null)
	{
		if (is_null($max) && is_null($min))
		{
			throw new IllegalArgumentException('$min and $max arguments can not be both null');
		}
		$this->field = $field;
		if ($min instanceof date_Calendar )
		{
			$this->min = date_DateFormat::format($min, indexer_Field::SOLR_DATE_FORMAT);
		}
		else
		{
			$this->min = $min;
		}
		if ($max instanceof date_Calendar )
		{
			$this->max = date_DateFormat::format($max, indexer_Field::SOLR_DATE_FORMAT);
		}
		else
		{
			$this->max = $max;
		}
	}

	/**
	 * Sets the range's maximum value to $value (inclusive)
	 *
	 * @param Mixed $value
	 * @return indexer_RangeQuery
	 */
	public function setMaxValue($value)
	{
		$this->max = $value;
		return $this;
	}

	/**
	 * Sets the range's minimum value to $value (inclusive)
	 *
	 * @param Mixed $value
	 * @return indexer_RangeQuery
	 */
	public function setMinValue($value)
	{
		$this->min = $value;
		return $this;
	}
	
	/**
	 * @return indexer_RangeQuery
	 */
	public function setExclusive()
	{
		$this->sepStart = "{";
		$this->sepEnd = "}";
		return $this;
	}

	/**
	 * @return String
	 */
	public function toSolrString()
	{
		return $this->field . ":".$this->sepStart . $this->wildCardIfNull($this->min) . '%20TO%20' . $this->wildCardIfNull($this->max) . $this->sepEnd;
	}

	/**
	 * Insert wildcard if needed for null min/max arguments
	 *
	 * @param mixed $val
	 * @return String
	 */
	private function wildCardIfNull($val)
	{
		return is_null($val) ? "*" : strval($val);
	}
}

{'fraction_non_alphanumeric': 0.16125598722724854, 'fraction_numerical': 0.0010643959552953698, 'mean_word_length': 3.237880496054115, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 33, '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': '5696493', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1304, 'n_words': 315}