<commit_before>module Common
  where

import           Data.List

data Config = C { inbox :: FilePath
                , rules :: [Rule]
                }
data Mail = M { file :: FilePath
              , content :: String
              , subject :: String
              , from :: String
              , to :: [String]
              , cc :: [String]
              } deriving (Eq,Show)
data Rule = R { name :: String
              , rule :: Mail -> Bool
              , target :: String
              }

emptyM = M { file = ""
           , content = ""
           , subject = ""
           , from = ""
           , to = []
           , cc = [] }

--------------------------------------------------------------------------------
--  common functions

isAnyInfix :: String -> Mail -> Bool
isAnyInfix needle m = any (needle `isInfixOf`) (to m)
                    || any (needle `isInfixOf`) (cc m)
                    || needle `isInfixOf` from m<commit_msg>add Action-data<commit_after>module Common
  where

import           Data.List

data Config = C { inbox :: FilePath
                , rules :: [Rule]
                }
data Mail = M { file :: FilePath
              , content :: String
              , subject :: String
              , from :: String
              , to :: [String]
              , cc :: [String]
              } deriving (Eq,Show)
data Action = MoveTo FilePath | GenAction (Mail -> IO())
data Rule = R { name :: String
              , rule :: Mail -> Bool
              , target :: String
              }

emptyM = M { file = ""
           , content = ""
           , subject = ""
           , from = ""
           , to = []
           , cc = [] }

--------------------------------------------------------------------------------
--  common functions

isAnyInfix :: String -> Mail -> Bool
isAnyInfix needle m = any (needle `isInfixOf`) (to m)
                    || any (needle `isInfixOf`) (cc m)
                    || needle `isInfixOf` from m
{'fraction_non_alphanumeric': 0.19491094147582697, 'fraction_numerical': 0.0, 'mean_word_length': 1.006122448979592, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '4687683', 'n_tokens_mistral': 502, 'n_tokens_neox': 485, 'n_words': 147}