<commit_before><?php
class DuckDuckGoBridge extends BridgeAbstract{

	public $maintainer = "Astalaseven";
	public $name = "DuckDuckGo";
	public $uri = "https://duckduckgo.com/";
	public $description = "Returns most recent results from DuckDuckGo.";

    public $parameters = array( array(
        'u'=>array(
            'name'=>'keyword',
            'required'=>true)
        ));

    public function collectData(){
        $html = '';
        $link = 'http://duckduckgo.com/html/?q='.$this->getInput('u').'+sort:date';

        $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request DuckDuckGo.');

        foreach($html->find('div.results_links') as $element) {
                $item = array();
                $item['uri'] = $element->find('a', 0)->href;
                $item['title'] = $element->find('a', 1)->innertext;
                $item['content'] = $element->find('div.snippet', 0)->plaintext;
                $this->items[] = $item;
        }
    }

    public function getCacheDuration(){
        return 21600; // 6 hours
    }
}<commit_msg>[DuckDuckGoBridge] code simplification<commit_after><?php
class DuckDuckGoBridge extends BridgeAbstract{

	public $maintainer = "Astalaseven";
	public $name = "DuckDuckGo";
	public $uri = "https://duckduckgo.com/";
	public $description = "Returns most recent results from DuckDuckGo.";

    public $parameters = array( array(
        'u'=>array(
            'name'=>'keyword',
            'required'=>true)
        ));

    public function collectData(){
        $html = $this->getSimpleHTMLDOM($this->uri.'html/?q='.$this->getInput('u').'+sort:date')
            or $this->returnServerError('Could not request DuckDuckGo.');

        foreach($html->find('div.results_links') as $element) {
                $item = array();
                $item['uri'] = $element->find('a', 0)->href;
                $item['title'] = $element->find('a', 1)->innertext;
                $item['content'] = $element->find('div.snippet', 0)->plaintext;
                $this->items[] = $item;
        }
    }

    public function getCacheDuration(){
        return 21600; // 6 hours
    }
}
{'fraction_non_alphanumeric': 0.17608897126969417, 'fraction_numerical': 0.008341056533827619, 'mean_word_length': 2.5277777777777777, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, 'https://': 2, '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': '332433', 'n_tokens_mistral': 681, 'n_tokens_neox': 634, 'n_words': 129}