<commit_before><?php
class SnippetLanguage extends DataObject {
    public static $db=array(
                            'Name'=>'Varchar(100)',
                            'FileExtension'=>'Varchar(45)',
                            'HighlightCode'=>'Varchar(45)',
                            'UserLanguage'=>'Boolean'
                         );
    
    public static $defaults=array(
                                'HighlightCode'=>'Plain',
                                'UserLanguage'=>true
                            );
    
    public static $extensions=array(
                                    'SnippetHierarchy'
                                );
    
    public static $default_sort='Name';
    
    private $defaultLanguages=array(
                                    'Flex 3'=>array('Extension'=>'mxml', 'HighlightCode'=>'Flex'),
                                    'ActionScript 3'=>array('Extension'=>'as', 'HighlightCode'=>'AS3'),
                                    'PHP'=>array('Extension'=>'php', 'HighlightCode'=>'Php'),
                                    'Bison'=>array('Extension'=>'bison', 'HighlightCode'=>'bison'),
                                    'C'=>array('Extension'=>'c', 'HighlightCode'=>'Cpp'),
                                    'C++'=>array('Extension'=>'cpp', 'HighlightCode'=>'Cpp'),
                                    'C#'=>array('Extension'=>'csharp', 'HighlightCode'=>'CSharp'),
                                    'ChangeLog'=>array('Extension'=>'log', 'HighlightCode'=>'Plain'),
                                    'CSS'=>array('Extension'=>'css', 'HighlightCode'=>'Css'),
                                    'Diff'=>array('Extension'=>'diff', 'HighlightCode'=>'Diff'),
                                    'Flex'=>array('Extension'=>'mxml', 'HighlightCode'=>'Flex'),
                                    'GLSL'=>array('Extension'=>'glsl', 'HighlightCode'=>'Plain'),
                                    'Haxe'=>array('Extension'=>'haxe', 'HighlightCode'=>'Plain'),
                                    'HTML'=>array('Extension'=>'html', 'HighlightCode'=>'Xml'),
                                    'Java'=>array('Extension'=>'java', 'HighlightCode'=>'Java'),
                                    'Java properties'=>array('Extension'=>'properties', 'HighlightCode'=>'properties'),
                                    'JavaScript'=>array('Extension'=>'js', 'HighlightCode'=>'JScript'),
                                    'JavaScript with DOM'=>array('Extension'=>'js', 'HighlightCode'=>'JScript'),
                                    'LaTeX'=>array('Extension'=>'latax', 'HighlightCode'=>'Latex'),
                                    'LDAP'=>array('Extension'=>'ldap', 'HighlightCode'=>'Plain'),
                                    'Log'=>array('Extension'=>'log', 'HighlightCode'=>'Plain'),
                                    'LSM (Linux Software Map)'=>array('Extension'=>'lsm', 'HighlightCode'=>'Plain'),
                                    'M4'=>array('Extension'=>'m4', 'HighlightCode'=>'Plain'),
                                    'Makefile'=>array('Extension'=>'makefile', 'HighlightCode'=>'Plain'),
                                    'Oracle SQL'=>array('Extension'=>'sql', 'HighlightCode'=>'Sql'),
                                    'Pascal'=>array('Extension'=>'pascal', 'HighlightCode'=>'Delphi'),
                                    'Perl'=>array('Extension'=>'pl', 'HighlightCode'=>'Perl'),
                                    'Prolog'=>array('Extension'=>'prolog', 'HighlightCode'=>'Plain'),
                                    'Python'=>array('Extension'=>'python', 'HighlightCode'=>'Python'),
                                    'RPM spec'=>array('Extension'=>'spec', 'HighlightCode'=>'Plain'),
                                    'Ruby'=>array('Extension'=>'ruby', 'HighlightCode'=>'Ruby'),
                                    'S-Lang'=>array('Extension'=>'slang', 'HighlightCode'=>'Plain'),
                                    'Scala'=>array('Extension'=>'scala', 'HighlightCode'=>'Scala'),
                                    'Shell'=>array('Extension'=>'sh', 'HighlightCode'=>'Bash'),
                                    'SQL'=>array('Extension'=>'sql', 'HighlightCode'=>'Sql'),
                                    'Standard ML'=>array('Extension'=>'sml', 'HighlightCode'=>'Plain'),
                                    'Tcl'=>array('Extension'=>'tcl', 'HighlightCode'=>'Plain'),
                                    'XML'=>array('Extension'=>'xml', 'HighlightCode'=>'Xml'),
                                    'Xorg configuration'=>array('Extension'=>'conf', 'HighlightCode'=>'Plain'),
                                    'Objective Caml'=>array('Extension'=>'caml', 'HighlightCode'=>'Plain'),
                                    'AppleScript'=>array('Extension'=>'applescript', 'HighlightCode'=>'AppleScript'),
                                    'Assembler'=>array('Extension'=>'asm', 'HighlightCode'=>'Asm'),
                                    'Ada'=>array('Extension'=>'ada', 'HighlightCode'=>'Ada'),
                                    'ColdFusion'=>array('Extension'=>'cf', 'HighlightCode'=>'ColdFusion'),
                                    'Batch'=>array('Extension'=>'bat', 'HighlightCode'=>'Bat'),
                                    'Bash'=>array('Extension'=>'bash', 'HighlightCode'=>'Bash'),
                                    'Delphi'=>array('Extension'=>'delphi', 'HighlightCode'=>'Delphi'),
                                    'Erlang'=>array('Extension'=>'el', 'HighlightCode'=>'Erlang'),
                                    'F#'=>array('Extension'=>'fsharp', 'HighlightCode'=>'FSharp'),
                                    'Groovy'=>array('Extension'=>'groovy', 'HighlightCode'=>'Groovy'),
                                    'Visual Basic'=>array('Extension'=>'vb', 'HighlightCode'=>'Vb'),
                                    'PowerShell'=>array('Extension'=>'ps', 'HighlightCode'=>'PowerShell'),
                                    'Other'=>array('Extension'=>'txt', 'HighlightCode'=>'Plain'),
                                    'SilverStripe Template'=>array('Extension'=>'ss', 'HighlightCode'=>'SilverStripe'),
                                    'Yaml'=>array('Extension'=>'yml', 'HighlightCode'=>'yml'),
                                    'AutoIt'=>array('Extension'=>'au3', 'HighlightCode'=>'au3')
                                );
    
    /**
     * Adds the default languages if they are missing
     */
    public function requireDefaultRecords() {
        parent::requireDefaultRecords();
        
        $defaultLangs=array_keys($this->defaultLanguages);
        $dbLangCount=SnippetLanguage::get()
                                        ->filter('Name', $defaultLangs)
                                        ->filter('UserLanguage', false)
                                        ->Count();
        if($dbLangCount<count($defaultLangs)) {
            foreach($this->defaultLanguages as $name=>$data) {
                if(!SnippetLanguage::get()->find('Language', $name)) {
                    $lang=new SnippetLanguage();
                    $lang->Name=$name;
                    $lang->FileExtension=$data['Extension'];
                    $lang->HighlightCode=$data['HighlightCode'];
                    $lang->UserLanguage=false;
                    $lang->write();
                    
                    DB::alteration_message('Created snippet language "'.$name.'"', 'created');<commit_msg>Corrected language codes for AutoIt and Yaml<commit_after><?php
class SnippetLanguage extends DataObject {
    public static $db=array(
                            'Name'=>'Varchar(100)',
                            'FileExtension'=>'Varchar(45)',
                            'HighlightCode'=>'Varchar(45)',
                            'UserLanguage'=>'Boolean'
                         );
    
    public static $defaults=array(
                                'HighlightCode'=>'Plain',
                                'UserLanguage'=>true
                            );
    
    public static $extensions=array(
                                    'SnippetHierarchy'
                                );
    
    public static $default_sort='Name';
    
    private $defaultLanguages=array(
                                    'Flex 3'=>array('Extension'=>'mxml', 'HighlightCode'=>'Flex'),
                                    'ActionScript 3'=>array('Extension'=>'as', 'HighlightCode'=>'AS3'),
                                    'PHP'=>array('Extension'=>'php', 'HighlightCode'=>'Php'),
                                    'Bison'=>array('Extension'=>'bison', 'HighlightCode'=>'bison'),
                                    'C'=>array('Extension'=>'c', 'HighlightCode'=>'Cpp'),
                                    'C++'=>array('Extension'=>'cpp', 'HighlightCode'=>'Cpp'),
                                    'C#'=>array('Extension'=>'csharp', 'HighlightCode'=>'CSharp'),
                                    'ChangeLog'=>array('Extension'=>'log', 'HighlightCode'=>'Plain'),
                                    'CSS'=>array('Extension'=>'css', 'HighlightCode'=>'Css'),
                                    'Diff'=>array('Extension'=>'diff', 'HighlightCode'=>'Diff'),
                                    'Flex'=>array('Extension'=>'mxml', 'HighlightCode'=>'Flex'),
                                    'GLSL'=>array('Extension'=>'glsl', 'HighlightCode'=>'Plain'),
                                    'Haxe'=>array('Extension'=>'haxe', 'HighlightCode'=>'Plain'),
                                    'HTML'=>array('Extension'=>'html', 'HighlightCode'=>'Xml'),
                                    'Java'=>array('Extension'=>'java', 'HighlightCode'=>'Java'),
                                    'Java properties'=>array('Extension'=>'properties', 'HighlightCode'=>'properties'),
                                    'JavaScript'=>array('Extension'=>'js', 'HighlightCode'=>'JScript'),
                                    'JavaScript with DOM'=>array('Extension'=>'js', 'HighlightCode'=>'JScript'),
                                    'LaTeX'=>array('Extension'=>'latax', 'HighlightCode'=>'Latex'),
                                    'LDAP'=>array('Extension'=>'ldap', 'HighlightCode'=>'Plain'),
                                    'Log'=>array('Extension'=>'log', 'HighlightCode'=>'Plain'),
                                    'LSM (Linux Software Map)'=>array('Extension'=>'lsm', 'HighlightCode'=>'Plain'),
                                    'M4'=>array('Extension'=>'m4', 'HighlightCode'=>'Plain'),
                                    'Makefile'=>array('Extension'=>'makefile', 'HighlightCode'=>'Plain'),
                                    'Oracle SQL'=>array('Extension'=>'sql', 'HighlightCode'=>'Sql'),
                                    'Pascal'=>array('Extension'=>'pascal', 'HighlightCode'=>'Delphi'),
                                    'Perl'=>array('Extension'=>'pl', 'HighlightCode'=>'Perl'),
                                    'Prolog'=>array('Extension'=>'prolog', 'HighlightCode'=>'Plain'),
                                    'Python'=>array('Extension'=>'python', 'HighlightCode'=>'Python'),
                                    'RPM spec'=>array('Extension'=>'spec', 'HighlightCode'=>'Plain'),
                                    'Ruby'=>array('Extension'=>'ruby', 'HighlightCode'=>'Ruby'),
                                    'S-Lang'=>array('Extension'=>'slang', 'HighlightCode'=>'Plain'),
                                    'Scala'=>array('Extension'=>'scala', 'HighlightCode'=>'Scala'),
                                    'Shell'=>array('Extension'=>'sh', 'HighlightCode'=>'Bash'),
                                    'SQL'=>array('Extension'=>'sql', 'HighlightCode'=>'Sql'),
                                    'Standard ML'=>array('Extension'=>'sml', 'HighlightCode'=>'Plain'),
                                    'Tcl'=>array('Extension'=>'tcl', 'HighlightCode'=>'Plain'),
                                    'XML'=>array('Extension'=>'xml', 'HighlightCode'=>'Xml'),
                                    'Xorg configuration'=>array('Extension'=>'conf', 'HighlightCode'=>'Plain'),
                                    'Objective Caml'=>array('Extension'=>'caml', 'HighlightCode'=>'Plain'),
                                    'AppleScript'=>array('Extension'=>'applescript', 'HighlightCode'=>'AppleScript'),
                                    'Assembler'=>array('Extension'=>'asm', 'HighlightCode'=>'Asm'),
                                    'Ada'=>array('Extension'=>'ada', 'HighlightCode'=>'Ada'),
                                    'ColdFusion'=>array('Extension'=>'cf', 'HighlightCode'=>'ColdFusion'),
                                    'Batch'=>array('Extension'=>'bat', 'HighlightCode'=>'Bat'),
                                    'Bash'=>array('Extension'=>'bash', 'HighlightCode'=>'Bash'),
                                    'Delphi'=>array('Extension'=>'delphi', 'HighlightCode'=>'Delphi'),
                                    'Erlang'=>array('Extension'=>'el', 'HighlightCode'=>'Erlang'),
                                    'F#'=>array('Extension'=>'fsharp', 'HighlightCode'=>'FSharp'),
                                    'Groovy'=>array('Extension'=>'groovy', 'HighlightCode'=>'Groovy'),
                                    'Visual Basic'=>array('Extension'=>'vb', 'HighlightCode'=>'Vb'),
                                    'PowerShell'=>array('Extension'=>'ps', 'HighlightCode'=>'PowerShell'),
                                    'Other'=>array('Extension'=>'txt', 'HighlightCode'=>'Plain'),
                                    'SilverStripe Template'=>array('Extension'=>'ss', 'HighlightCode'=>'SilverStripe'),
                                    'Yaml'=>array('Extension'=>'yml', 'HighlightCode'=>'Yaml'),
                                    'AutoIt'=>array('Extension'=>'au3', 'HighlightCode'=>'AutoIt')
                                );
    
    /**
     * Adds the default languages if they are missing
     */
    public function requireDefaultRecords() {
        parent::requireDefaultRecords();
        
        $defaultLangs=array_keys($this->defaultLanguages);
        $dbLangCount=SnippetLanguage::get()
                                        ->filter('Name', $defaultLangs)
                                        ->filter('UserLanguage', false)
                                        ->Count();
        if($dbLangCount<count($defaultLangs)) {
            foreach($this->defaultLanguages as $name=>$data) {
                if(!SnippetLanguage::get()->find('Language', $name)) {
                    $lang=new SnippetLanguage();
                    $lang->Name=$name;
                    $lang->FileExtension=$data['Extension'];
                    $lang->HighlightCode=$data['HighlightCode'];
                    $lang->UserLanguage=false;
                    $lang->write();
                    
                    DB::alteration_message('Created snippet language "'.$name.'"', 'created');
{'fraction_non_alphanumeric': 0.1786402605170466, 'fraction_numerical': 0.0017943776168006912, 'mean_word_length': 1.5261037434950477, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 375, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 124, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5033488', 'n_tokens_mistral': 3417, 'n_tokens_neox': 3304, 'n_words': 385}