<commit_before>#!/usr/bin/env ruby

begin
  require File.join(File.dirname(__FILE__), '../lib/gmail-britta.rb')
rescue
  require 'bundler/setup'
  require 'gmail-britta'
end

if File.exist?(File.expand_path("~/.gmail-britta.personal.rb"))
  require "~/.gmail-britta.personal.rb"
else
  # Some fake constants to let you run this (-:
  MY_EMAILS = %w[<EMAIL> <EMAIL>]
  FB_EMAIL = 'from:<EMAIL>'
  TWITTER_EMAILS = %w{n-yhex=abcdefg.def-3123f@<EMAIL>.twitter.<EMAIL>}
  TWITTER_TEST_EMAILS = %w{n-yhex=abcdefg.def-12345@postmaster.twitter.com}
  BANK_EMAILS = %w{<EMAIL>}
  V_EMAILS=['from:<EMAIL>', {:or => MY_EMAILS.map{|email| "to:#{email}"}}]
end


puts(GmailBritta.filterset(:me => MY_EMAILS) do
    # Put all mailman reminders away
    filter {
      has ['subject:"moderator request"']
      label 'bulk/mailman'
      archive
      mark_read
    }

    filter {
      has ['list:mailman@', 'subject:reminder']
      label 'bulk/mailman'
      archive
      mark_read
    }

    # Archive all mailman mail except confirmation ones
    filter {
      has %w{from:mailman subject:confirm}
      label 'bulk'
    }.otherwise {
      has %w{from:mailman}
      label 'bulk'
      archive
    }

    # Label all sysadmin-related email
    filter {
      has %w{to:root}
      archive
      label 'bulk/admin'
    }

    # Mailing lists I read:
    filter {
      has %w{list:<EMAIL>}
      label 'lisp/McCLIM'
    }.archive_unless_directed.otherwise {
      has [{:or => %w{list:*<EMAIL> list:<EMAIL>}}]
      label 'lisp'
    }.archive_unless_directed

    filter {
      has [{:or => %w{list:sbcl-devel list:sbcl-help}}]
      never_spam
      label 'lisp/sbcl'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      never_spam
      label 'lisp/cclan'
    }.archive_unless_directed

    filter {
      has %w{list:openmcl-*}
      label 'lisp/clozure'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      label 'lisp/quicklisp'
    }.archive_unless_directed

    filter {
      has [{:or => %w{list:<EMAIL> list:replicatorg-dev@googlegroups.<EMAIL>}}]
      label 'thingiverse'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      label 'thingiverse'
    }.archive_unless_directed

    filter {
      has %w{list:emacs-orgmode@gnu.org}
      label 'orgmode'
    }.archive_unless_directed

    filter {
      has [{:or => %w{list:<EMAIL> list:<EMAIL>
                      list:<EMAIL> list:*<EMAIL>}}]
      label 'hackerspaces'
    }.archive_unless_directed

    # Stuff from the bank:
    filter {
      has BANK_EMAILS
      label 'banking'
      mark_important
    }

    filter {
      has V_EMAILS
      label '=(-:<'
      mark_important
      never_spam
    }

    # People/things I get occasional personal email from:
    filter {
      has [{:or => %w{from:<EMAIL> from:<EMAIL> list:<EMAIL> list:<EMAIL>}}]
      label 'bulk'
    }.archive_unless_directed

    filter {
      has [FB_EMAIL, {:or => ['subject:"added you as a friend"', 'subject:"sent you a message"', 'subject:"changed the time"']}]
      label 'bulk/fb'
    }.otherwise {
      has [FB_EMAIL]
      label 'bulk/fb'
      archive
    }.otherwise {
      has TWITTER_EMAILS + [{:or => ['subject:"is now following"', 'subject:"direct message"']}]
      label 'bulk/twitter'
    }.otherwise {
      has [{:or => TWITTER_EMAILS + TWITTER_TEST_EMAILS}]
      label 'bulk/twitter'
      archive
      mark_read
    }.otherwise {
      # Mail from web services I don't care about THAT much:
      bacon_senders = %w{<EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> *@carsonified.com *@crossmediaweek.org <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> *@dotnetsolutions.co.uk
        <EMAIL> <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> *@*.boinx.com <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>.com}

      has [{:or => "from:(#{bacon_senders.join("|")})"}]
      archive
      label 'bulk'
    }.otherwise {
      to_me = me.map {|address| "to:#{address}"}
      has [{:or => to_me}]
      label '_asf'
    }


  end.generate)<commit_msg>Add elixir and amazon package autotracking rule<commit_after>#!/usr/bin/env ruby

begin
  require File.join(File.dirname(__FILE__), '../lib/gmail-britta.rb')
rescue
  require 'bundler/setup'
  require 'gmail-britta'
end

if File.exist?(File.expand_path("~/.gmail-britta.personal.rb"))
  require "~/.gmail-britta.personal.rb"
else
  # Some fake constants to let you run this (-:
  MY_EMAILS = %w[<EMAIL> <EMAIL>]
  FB_EMAIL = 'from:<EMAIL>'
  TWITTER_EMAILS = %w{n-yhex=abcdefg.def-3123f@post<EMAIL>.com}
  TWITTER_TEST_EMAILS = %w{n-yhex=abcdefg.def-12345@postmaster.twitter.com}
  BANK_EMAILS = %w{<EMAIL>}
  V_EMAILS=['from:<EMAIL>', {:or => MY_EMAILS.map{|email| "to:#{email}"}}]
  AMAZON_PACKAGE_TRACKING_EMAIL='<EMAIL>' # See https://github.com/antifuchs/amazon-autotracker
end


puts(GmailBritta.filterset(:me => MY_EMAILS) do
    # Put all mailman reminders away
    filter {
      has ['subject:"moderator request"']
      label 'bulk/mailman'
      archive
      mark_read
    }

    filter {
      has ['list:mailman@', 'subject:reminder']
      label 'bulk/mailman'
      archive
      mark_read
    }

    # Archive all mailman mail except confirmation ones
    filter {
      has %w{from:mailman subject:confirm}
      label 'bulk'
    }.otherwise {
      has %w{from:mailman}
      label 'bulk'
      archive
    }

    # Label all sysadmin-related email
    filter {
      has %w{to:root}
      archive
      label 'bulk/admin'
    }

    # Mailing lists I read:
    filter {
      has %w{list:<EMAIL>}
      label 'lisp/McCLIM'
    }.archive_unless_directed.otherwise {
      has [{:or => %w{list:*<EMAIL> list:<EMAIL>}}]
      label 'lisp'
    }.archive_unless_directed

    filter {
      has [{:or => %w{list:sbcl-devel list:sbcl-help}}]
      never_spam
      label 'lisp/sbcl'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      never_spam
      label 'lisp/cclan'
    }.archive_unless_directed

    filter {
      has %w{list:openmcl-*}
      label 'lisp/clozure'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      label 'lisp/quicklisp'
    }.archive_unless_directed

    filter {
      has [{:or => %w{list:<EMAIL> list:<EMAIL>}}]
      label 'thingiverse'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      label 'thingiverse'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      label 'orgmode'
    }.archive_unless_directed

    filter {
      has %w{list:<EMAIL>}
      label 'elixir'
    }.archive_unless_directed

    filter {
      has [{:or => %w{list:<EMAIL> list:<EMAIL>
                      list:<EMAIL> list:*<EMAIL>}}]
      label 'hackerspaces'
    }.archive_unless_directed

    # Stuff from the bank:
    filter {
      has BANK_EMAILS
      label 'banking'
      mark_important
    }

    filter {
      has V_EMAILS
      label '=(-:<'
      mark_important
      never_spam
    }

    # People/things I get occasional personal email from:
    filter {
      has [{:or => %w{from:<EMAIL> from:<EMAIL> list:<EMAIL> list:<EMAIL>}}]
      label 'bulk'
    }.archive_unless_directed

    filter {
      has [FB_EMAIL, {:or => ['subject:"added you as a friend"', 'subject:"sent you a message"', 'subject:"changed the time"']}]
      label 'bulk/fb'
    }.otherwise {
      has [FB_EMAIL]
      label 'bulk/fb'
      archive
    }.otherwise {
      has TWITTER_EMAILS + [{:or => ['subject:"is now following"', 'subject:"direct message"']}]
      label 'bulk/twitter'
    }.otherwise {
      has [{:or => TWITTER_EMAILS + TWITTER_TEST_EMAILS}]
      label 'bulk/twitter'
      archive
      mark_read
    }.otherwise {
      # Mail from web services I don't care about THAT much:
      bacon_senders = %w{<EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> *@carsonified.com *@crossmediaweek.org <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL>@letter.eyepin.com <EMAIL> <EMAIL> *@dotnetsolutions.co.uk
        <EMAIL> <EMAIL> <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> *@*.boinx.com <EMAIL> <EMAIL> <EMAIL>
        <EMAIL> <EMAIL> <EMAIL> <EMAIL>}

      has [{:or => "from:(#{bacon_senders.join("|")})"}]
      archive
      label 'bulk'
    }.otherwise {
      to_me = me.map {|address| "to:#{address}"}
      has [{:or => to_me}]
      label '_asf'
    }

    filter {
      has %w{from:<EMAIL>}
      label 'bulk/packages'
      forward_to AMAZON_PACKAGE_TRACKING_EMAIL
    }

  end.generate)
{'fraction_non_alphanumeric': 0.14791288566243194, 'fraction_numerical': 0.002041742286751361, 'mean_word_length': 2.58123476848091, 'pattern_counts': {'":': 0, '<': 130, '<?xml version=': 0, '>': 152, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '6669029', 'n_tokens_mistral': 3425, 'n_tokens_neox': 3242, 'n_words': 655}