<commit_before><?php

class GoogleAppsCalendarDataRetriever extends URLDataRetriever
{
    protected $authority;
    protected $supportsSearch = true;
    
    protected function url() {
        $this->addFilter('orderby', 'starttime');
        $this->addFilter('sortorder', 'a');
        $this->addFilter('singleevents', 'true');
        
        if ($startDate = $this->dataController->getStartDate()) {
            $this->addFilter('start-min', $startDate->format('c'));
        }

        if ($endDate = $this->dataController->getEndDate()) {
            $this->addFilter('start-max', $endDate->format('c'));
        }

        return parent::url();
    }
    
    public function search($searchTerms) {
        $this->addFilter('q', $searchTerms);
        if ($start = $this->dataController->getStart()) {
            $this->addFilter('start-index', $start+1);
        }
        
        if ($limit = $this->dataController->getLimit()) {
            $this->addFilter('max-results', $limit);
        }

        return $this->retrieveData();
    }

    protected function cacheFolder() {
        $oauth = $this->oauth();
        $token = $oauth->getToken();
        return CACHE_DIR . "/" . $this->cacheFolder . ($token ? "/" . md5($token) : '');
    }
    
    public function retrieveData() {
        $url = $this->url();
    
        $oauth = $this->oauth();
        $parameters = array(); //set in query string
        $headers = $this->getHeaders();
        return $oauth->oauthRequest('GET', $url, $parameters, $headers);
    }
    
    protected function addStandardFilters() {
        $this->addFilter('alt','jsonc');
        $this->addHeader('GData-Version', '2');
    }
    
    protected function oauth() {
        return $this->authority->oauth();
    }
    
    protected function init($args)
    {
        parent::init($args);
        //either get the specified authority or attempt to get a GoogleApps authority
        $authorityIndex = isset($args['AUTHORITY']) ? $args['AUTHORITY'] : 'GoogleAppsAuthentication';
        $authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex);
        
        //make sure we're getting a google apps authority
        if ($authority instanceOf GoogleAppsAuthentication) {
            $this->authority = $authority;
        }
        
        $this->addStandardFilters();
    }
}

class GoogleCalendarDataParser extends DataParser
{<commit_msg>updated Google calendar data retriever<commit_after><?php

class GoogleAppsCalendarDataRetriever extends OAuthDataRetriever
{
    protected $DEFAULT_PARSER_CLASS = 'GoogleCalendarDataParser';
    protected $authority;
    protected $supportsSearch = true;
    
    protected function url() {
        $this->addFilter('orderby', 'starttime');
        $this->addFilter('sortorder', 'a');
        $this->addFilter('singleevents', 'true');
        
        if ($startDate = $this->dataController->getStartDate()) {
            $this->addFilter('start-min', $startDate->format('c'));
        }

        if ($endDate = $this->dataController->getEndDate()) {
            $this->addFilter('start-max', $endDate->format('c'));
        }

        return parent::url();
    }
    
    public function search($searchTerms) {
        $this->addFilter('q', $searchTerms);
        if ($start = $this->dataController->getStart()) {
            $this->addFilter('start-index', $start+1);
        }
        
        if ($limit = $this->dataController->getLimit()) {
            $this->addFilter('max-results', $limit);
        }

        return $this->retrieveData();
    }

    protected function addStandardFilters() {
        $this->addFilter('alt','jsonc');
        $this->addHeader('GData-Version', '2');
    }
    
    protected function init($args)
    {
        parent::init($args);
        $this->addStandardFilters();
    }
}

class GoogleCalendarDataParser extends DataParser
{
{'fraction_non_alphanumeric': 0.1569080636877247, 'fraction_numerical': 0.0012840267077555213, 'mean_word_length': 2.5344827586206895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, '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': '3393832', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1103, 'n_words': 202}