<commit_before>#include "ride/quickopendlg.h"

#include "ride/wx.h"
#include "ride/generated/ui.h"
#include "ride/wxutils.h"
#include <vector>
#include <set>

// based on http://docs.wholetomato.com/default.asp?W193

class QuickOpenDlg : public ui::QuickOpen {
public:
  QuickOpenDlg(wxWindow* parent);

private:
  void UpdateFilters();

protected:
  void OnCancel(wxCommandEvent& event);
  void OnOk(wxCommandEvent& event);
  void OnActivate(wxActivateEvent& event);
  void OnFilterKeyUp(wxKeyEvent& event);
  void OnFilterUpdated(wxCommandEvent& event);
  void OnFilterNameEnter(wxCommandEvent& event);

  std::vector<wxString> files_;
};

void AddIfMoreThanOne(std::vector<wxString>& ret, const std::vector<wxString>& space) {
  if (space.size() != 1) {
    ret.insert(ret.begin(), space.begin(), space.end());
  }
}

std::vector<wxString> SmartSplit(const wxString str) {
  const auto space = Split(str, ' ');
  const auto dash = Split(str, '-');
  const auto under = Split(str, '_');
  std::vector<wxString> ret;
  ret.push_back(str);

  AddIfMoreThanOne(ret, space);
  AddIfMoreThanOne(ret, dash);
  AddIfMoreThanOne(ret, under);

  return ret;
}

bool MatchFilter(const wxString& filter, const wxString file, int* count) {
  const wxFileName name(file); 
  const auto filters = RemoveEmptyStrings(Split(filter, ' '));
  const auto parts = SmartSplit(name.GetFullName());
  if (filters.empty()) return true;
  for (auto f : filters) {
    for (auto part : parts) {
      if (part.StartsWith(f)) {
        *count += 1;
      }
    }
  }
  return *count > 0;
}

struct FilterMatch {
  wxString path;
  int count;

  FilterMatch(const wxString& p, int c) : path(p), count(c) {}
  bool operator<(const FilterMatch& rhs) const {<commit_msg>- at the start of the filter now removes the match<commit_after>#include "ride/quickopendlg.h"

#include "ride/wx.h"
#include "ride/generated/ui.h"
#include "ride/wxutils.h"
#include <vector>
#include <set>

// based on http://docs.wholetomato.com/default.asp?W193

class QuickOpenDlg : public ui::QuickOpen {
public:
  QuickOpenDlg(wxWindow* parent);

private:
  void UpdateFilters();

protected:
  void OnCancel(wxCommandEvent& event);
  void OnOk(wxCommandEvent& event);
  void OnActivate(wxActivateEvent& event);
  void OnFilterKeyUp(wxKeyEvent& event);
  void OnFilterUpdated(wxCommandEvent& event);
  void OnFilterNameEnter(wxCommandEvent& event);

  std::vector<wxString> files_;
};

void AddIfMoreThanOne(std::vector<wxString>& ret, const std::vector<wxString>& space) {
  if (space.size() != 1) {
    ret.insert(ret.begin(), space.begin(), space.end());
  }
}

std::vector<wxString> SmartSplit(const wxString str) {
  const auto space = Split(str, ' ');
  const auto dash = Split(str, '-');
  const auto under = Split(str, '_');
  std::vector<wxString> ret;
  ret.push_back(str);

  AddIfMoreThanOne(ret, space);
  AddIfMoreThanOne(ret, dash);
  AddIfMoreThanOne(ret, under);

  return ret;
}

bool MatchFilter(const wxString& filter, const wxString file, int* count) {
  const wxFileName name(file); 
  const auto filters = RemoveEmptyStrings(Split(filter, ' '));
  const auto parts = SmartSplit(name.GetFullName());
  if (filters.empty()) return true;
  for (auto fi : filters) {
    const bool exclude = fi.StartsWith("-");
    const wxString f = exclude ? fi.Mid(1) : fi;
    for (auto part : parts) {
      if (part.StartsWith(f)) {
        if (exclude) return false;
        *count += 1;
      }
    }
  }
  return *count > 0;
}

struct FilterMatch {
  wxString path;
  int count;

  FilterMatch(const wxString& p, int c) : path(p), count(c) {}
  bool operator<(const FilterMatch& rhs) const {
{'fraction_non_alphanumeric': 0.14387503425596054, 'fraction_numerical': 0.00356261989586188, 'mean_word_length': 4.391432791728213, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5032872', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1240, 'n_words': 308}