<commit_before><?php
/**
 * ownCloud - search_lucene
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2012-2015
 */

namespace OCA\Search_Lucene\Search;
use OC\Files\Filesystem;
use ZendSearch\Lucene\Search\QueryHit;
use OC\Search\Result\File;

/**
 * A found file
 */
class LuceneResult extends File {

	/**
	 * Type name; translated in templates
	 * @var string
	 */
	public $type = 'lucene';

	/**
	 * @var float
	 */
	public $score;

	/**
	 * Create a new content search result
	 * @param QueryHit $hit file data given by provider
	 */
	public function __construct(QueryHit $hit) {
		$this->id = (string)$hit->fileId;
		$this->path = $this->getRelativePath($hit->path);
		$this->name = basename($this->path);
		$this->size = (int)$hit->size;
		$this->score = $hit->score;
		$this->link = \OCP\Util::linkTo(
			'files',
			'index.php',
			array('dir' => dirname($this->path), 'file' => $this->name)
		);
		$this->permissions = $this->getPermissions($this->path);
		$this->modified = (int)$hit->mtime;
		$this->mime_type = $hit->mimetype;
	}

	protected function getRelativePath ($path) {
		$root = \OC::$server->getUserFolder();
		return $root->getRelativePath($path);
  	}

	/**
	 * Determine permissions for a given file path
	 * @param string $path
	 * @return int<commit_msg>Fix scrolling to result. Closes #88<commit_after><?php
/**
 * ownCloud - search_lucene
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2012-2015
 */

namespace OCA\Search_Lucene\Search;
use OC\Files\Filesystem;
use ZendSearch\Lucene\Search\QueryHit;
use OC\Search\Result\File;

/**
 * A found file
 */
class LuceneResult extends File {

	/**
	 * Type name; translated in templates
	 * @var string
	 */
	public $type = 'lucene';

	/**
	 * @var float
	 */
	public $score;

	/**
	 * Create a new content search result
	 * @param QueryHit $hit file data given by provider
	 */
	public function __construct(QueryHit $hit) {
		$this->id = (string)$hit->fileId;
		$this->path = $this->getRelativePath($hit->path);
		$this->name = basename($this->path);
		$this->size = (int)$hit->size;
		$this->score = $hit->score;
		$this->link = \OCP\Util::linkTo(
			'files',
			'index.php',
			array('dir' => dirname($this->path), 'scrollto' => $this->name)
		);
		$this->permissions = $this->getPermissions($this->path);
		$this->modified = (int)$hit->mtime;
		$this->mime_type = $hit->mimetype;
	}

	protected function getRelativePath ($path) {
		$root = \OC::$server->getUserFolder();
		return $root->getRelativePath($path);
  	}

	/**
	 * Determine permissions for a given file path
	 * @param string $path
	 * @return int
{'fraction_non_alphanumeric': 0.1708008504606662, 'fraction_numerical': 0.007087172218284904, 'mean_word_length': 3.6507413509060958, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 61, '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': '7624234', 'n_tokens_mistral': 1036, 'n_tokens_neox': 941, 'n_words': 240}