<commit_before><?php

class Set extends Model {
    public function get_vocabularies() {
        return $this->has_many('Vocabulary')->order_by_asc('id');
    }

    public function get_new_vocabularies() {
        $max = Setting::get('new_vocabs_per_day') - Vocabulary::filter('learned_today')->count();
        $sets = Vocabulary::filter('inactive')->select('set_id')->limit($max)->distinct()->find_many();

        if (count($sets) == 0 || !in_array($this->id, array_map(function($x) { return $x->set_id; }, $sets)))
            return Vocabulary::where_id_is(-1);

        $limit = round($max / count($sets));
        return Set::get_vocabularies()->filter('inactive')->limit($limit);
    }

    public function get_due_vocabularies() {
        return $this->get_vocabularies()->filter('due');
    }

    /**
     * Links
     */

    public function get_permalink() {
        return BASE_PATH . 'set/' . $this->id;
    }
<commit_msg>When deleting set, also delete vocabulary<commit_after><?php

class Set extends Model {
    public function get_vocabularies() {
        return $this->has_many('Vocabulary')->order_by_asc('id');
    }

    public function get_new_vocabularies() {
        $max = Setting::get('new_vocabs_per_day') - Vocabulary::filter('learned_today')->count();
        $sets = Vocabulary::filter('inactive')->select('set_id')->limit($max)->distinct()->find_many();

        if (count($sets) == 0 || !in_array($this->id, array_map(function($x) { return $x->set_id; }, $sets)))
            return Vocabulary::where_id_is(-1);

        $limit = round($max / count($sets));
        return Set::get_vocabularies()->filter('inactive')->limit($limit);
    }

    public function get_due_vocabularies() {
        return $this->get_vocabularies()->filter('due');
    }

    public function delete() {
        Vocabulary::where('set_id', $this->id)->delete_many();
        parent::delete();
    }

    /**
     * Links
     */

    public function get_permalink() {
        return BASE_PATH . 'set/' . $this->id;
    }

{'fraction_non_alphanumeric': 0.18168389955686853, 'fraction_numerical': 0.0019694731659281144, 'mean_word_length': 3.2245322245322243, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '6562526', 'n_tokens_mistral': 675, 'n_tokens_neox': 655, 'n_words': 103}