<commit_before><?php


require_once('pudlResult.php');


class pudlSqliteResult extends pudlResult {
	public function __construct($result, $query) {
		parent::__construct($result, $query);
	}
	
	
	public function __destruct() {
		$this->free();
	}


	public function free() {
		if (is_object($this->result)) {
			$this->result->finalize();
			$this->result = NULL;
			return true;
		}
		return false;
	}


	public function cell($row=0, $column=0) {
		$return = false;
		if (is_object($this->result)) {
			sqlite_seek($this->result, $row);
			$data = $this->row(PUDL_NUMBER);
			if (isset($data[$column])) $return = $data[$column];
		}
		return $return;
	}


	public function count() {
		return 0;
		//TODO: IMPLEMENT THIS (but it'll be hacky, since Sqlite doesn't support it!)
//		$rows = false;
//		if (is_object($this->result)) $rows = $this->result->numColumns();
//		return ($rows !== false) ? $rows : 0;
	}

	
	public function fields() {
		$fields = false;
		if (is_object($this->result)) $fields = $this->result->numColumns();
		return ($fields !== false) ? $fields : 0;
	}


	public function getField($column) {
		$field = false;
		if (is_object($this->result)) $field = $this->result->columnName($column);
		return ($field !== false) ? $field : false;
	}

	
	public function row($type=PUDL_ARRAY) {
		if (!is_object($this->result)) return false;
		$data = false;
		switch ($type) {
			case PUDL_ARRAY:	$data = $this->result->fetchArray(SQLITE3_ASSOC);	break;
			case PUDL_NUMBER:	$data = $this->result->fetchArray(SQLITE3_NUM);		break;
			case PUDL_BOTH:		$data = $this->result->fetchArray(SQLITE3_BOTH);	break;
			default:			$data = $this->result->fetchArray();
		}
		return is_array($data) ? $data : false;
	}
	
}
<commit_msg>Added a row counter and implemented cell() in pudlSqlite<commit_after><?php


require_once('pudlResult.php');


class pudlSqliteResult extends pudlResult {
	public function __construct($result, $query) {
		parent::__construct($result, $query);

		$this->rownum = 0;
	}
	
	
	public function __destruct() {
		$this->free();
	}


	public function free() {
		if (is_object($this->result)) {
			$this->result->finalize();
			$this->result = NULL;
			return true;
		}
		return false;
	}


	public function cell($row=0, $column=0) {
		$return = false;

		if (is_object($this->result)) {
			if ($row > $this->rownum) {
				$this->rownum = 0;
				$this->result->reset();
			}

			for ($i=$this->rownum; $i<=$row; $i++) {
				$data = $this->row(PUDL_NUMBER);
			}

			if (isset($data[$column])) $return = $data[$column];
		}

		return $return;
	}


	public function count() {
		return 0;
		//TODO: IMPLEMENT THIS (but it'll be hacky, since Sqlite doesn't support it!)
//		$rows = false;
//		if (is_object($this->result)) $rows = $this->result->numColumns();
//		return ($rows !== false) ? $rows : 0;
	}

	
	public function fields() {
		$fields = false;
		if (is_object($this->result)) $fields = $this->result->numColumns();
		return ($fields !== false) ? $fields : 0;
	}


	public function getField($column) {
		$field = false;
		if (is_object($this->result)) $field = $this->result->columnName($column);
		return ($field !== false) ? $field : false;
	}

	
	public function row($type=PUDL_ARRAY) {
		if (!is_object($this->result)) return false;

		$this->rownum++;

		$data = false;
		switch ($type) {
			case PUDL_ARRAY:	$data = $this->result->fetchArray(SQLITE3_ASSOC);	break;
			case PUDL_NUMBER:	$data = $this->result->fetchArray(SQLITE3_NUM);		break;
			case PUDL_BOTH:		$data = $this->result->fetchArray(SQLITE3_BOTH);	break;
			default:			$data = $this->result->fetchArray();
		}
		return is_array($data) ? $data : false;
	}


	private $rownum;
	
}

{'fraction_non_alphanumeric': 0.1770210553678191, 'fraction_numerical': 0.004678970626462178, 'mean_word_length': 3.1826086956521737, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 62, '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': '5590387', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1336, 'n_words': 291}