<commit_before>package nme.net;

import StringTools;

class FileFilter
{
   public var description:String;
   public var extension(default,set):String;
   public var macType:String;
   var match:Array<String>;

   public function new(inDescription:String, inExtension:String, inMacType:String = null)
   {
     description = inDescription;
     extension = inExtension;
     macType = inMacType;
   }

   function set_extension(inExtension:String)
   {
      match = [];
      extension = inExtension;
      if (extension!=null)
         for(part in extension.split(";"))
            if (part.length>0 && part.substr(0,1)=="*")
               match.push(part.toLowerCase().substr(1));
      return inExtension;
   }

   public function matches(inFilename:String)
   {
      var filename = inFilename.toLowerCase();
      var flen = filename.length;
      for(m in match)
      {
         if (m.length <= flen && filename.substr(flen-m.length)==m)
            return true;
      }
      return false;
   }
}

<commit_msg>Add getBestExtension function<commit_after>package nme.net;

import StringTools;

class FileFilter
{
   public var description:String;
   public var extension(default,set):String;
   public var macType:String;
   var match:Array<String>;

   public function new(inDescription:String, inExtension:String, inMacType:String = null)
   {
     description = inDescription;
     extension = inExtension;
     macType = inMacType;
   }
 
   // Includes the "." or may be empty string
   public function getBestExtension()
   {
      for(m in match)
      {
         if (m!=".*" && m.substr(0,1)==".")
            return m;
      }
      for(m in match)
      {
         if (m!=".*")
            return "." + m;
      }
      return "";
   }

   function set_extension(inExtension:String)
   {
      match = [];
      extension = inExtension;
      if (extension!=null)
         for(part in extension.split(";"))
            if (part.length>0 && part.substr(0,1)=="*")
               match.push(part.toLowerCase().substr(1));
      return inExtension;
   }

   public function matches(inFilename:String)
   {
      var filename = inFilename.toLowerCase();
      var flen = filename.length;
      for(m in match)
      {
         if (m==".*")
            return true;
         if (m.length <= flen && filename.substr(flen-m.length)==m)
            return true;
      }
      return false;
   }
}


{'fraction_non_alphanumeric': 0.11952191235059761, 'fraction_numerical': 0.00398406374501992, 'mean_word_length': 2.028950542822678, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4401183', 'n_tokens_mistral': 752, 'n_tokens_neox': 730, 'n_words': 162}