<commit_before><?php
/**
 * 搜索主类.
 *
 * 个性查询请在 ActTrait 扩充.
 *
 * @farwish
 */
class SController extends ControllerBase
{
    use ActTrait;

    /**
     * 进入.
     *
     * `/s?typ=welcome` 
     * `/s?q=something` 默认主检索
     * `/s?q=something&typ=answers` 指定检索方法
     *
     * @farwish
     */
    public function indexAction()
    {
        $typ = $this->request->get('typ', 'string');

        $data = [];
        if ( empty($typ) ) {
            $data = self::major(); 
        } else if ( method_exists(__CLASS__, $typ)
            && ! in_array($typ, parent::blacklist() )
        ) {
            $data = self::$typ();
        }

        $this->respond($data);

        fastcgi_finish_request();

        parent::spoor();
    }

    /**
     * 搜索建议词.
     *
     * `?q=something` for ajax request.
     * TODO fuzzy obj.
     *
     * @farwish
     */
    protected function suggests()
    {
        $expand = [];
        if ( $q = parent::makeup() ) {
            $expand = parent::fuzzy($q)->getExpandedQuery($q, static::$limit);
        }
        return $expand;
    }

    /**
     * 纠错词.
     *
     * `您是不是要找：`
     *
     * @farwish
     */
    protected function corrected()
    {
        $corrected = [];
        if ( $q = parent::makeup() ) {
            $corrected = parent::fuzzy($q)->getCorrectedQuery($q);
        }
        return $corrected;
    }

    /**<commit_msg>Accept Merge Request #2 .. : (develop -> master)<commit_after><?php
/**
 * 搜索主类.
 *
 * 个性查询请在 ActTrait 扩充.
 *
 * @farwish
 */
class SController extends ControllerBase
{
    use ActTrait;

    /**
     * 进入.
     *
     * `/s?typ=welcome` 
     * `/s?q=something` 默认主检索
     * `/s?q=something&typ=answers` 指定检索方法
     *
     * @farwish
     */
    public function indexAction()
    {
        $typ = $this->request->get('typ', 'string');

        $data = [];
        if ( empty($typ) ) {
            $data = self::major(); 
        } else if ( method_exists(__CLASS__, $typ)
            && ! in_array($typ, parent::blacklist() )
        ) {
            $data = self::$typ();
        }

        $this->respond($data);

        fastcgi_finish_request();

        parent::spoor();
    }

    /**
     * 搜索建议词.
     *
     * `?q=something` for ajax request.
     * TODO fuzzy obj.
     *
     * @farwish
     */
    protected function suggests()
    {
        $expand = [];
        if ( $q = parent::makeup() ) {
            $expand = parent::fuzzy($q)->getExpandedQuery($q, static::$limit);
        }
        return $expand;
    }

    /**
     * 纠错词.
     *
     * `您是不是要找：`
     * TODO fuzzy obj.
     *
     * @farwish
     */
    protected function corrected()
    {
        $corrected = [];
        if ( $q = parent::makeup() ) {
            $corrected = parent::fuzzy($q)->getCorrectedQuery($q);
        }
        return $corrected;
    }

    /**
{'fraction_non_alphanumeric': 0.1726568005637773, 'fraction_numerical': 0.00035236081747709656, 'mean_word_length': 1.562274368231047, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '2466311', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1032, 'n_words': 160}