<commit_before>{-# OPTIONS_GHC -fglasgow-exts #-}

-- | Grovel over the result file given on the command-line and output a PNG
-- graph comparison of the runtime data.
--
-- Example usage:
--
-- runghc GraphResults.hs result.1 result.2
module Main where

import Control.Monad
import Data.List( foldl', intercalate, transpose, genericLength )
import Data.Maybe( mapMaybe )
import Debug.Trace( trace )
import Graphics.Rendering.Chart
import Text.Regex
import Test.QuickCheck( quickCheck )
import System.Environment( getArgs )
import System.FilePath.Posix

-- | Assume the input contains @n>0@ records delimited at the start by
-- whatever matches regexp.  Each element @(xs, s)@ of @groups rx f s@ is such
-- that (1) @xs@ is a list of submatches of @rx@ and (2) @s@ is the string
-- from (and not including) the last match, up to and not including the next
-- match (if any).
--
-- If the regex fails to match at all (i.e. @n=0@), the empty list is
-- returned.
groups :: Regex -> String -> [([String], String)]
groups markerRx s = snd $ groups' markerRx s
  where
    -- Returns the text before the match, if any match, in its first position.
    groups' markerRx s =
        case matchRegexAll markerRx s of
          Nothing -> (s, [])<commit_msg>Typo correction.<commit_after>{-# OPTIONS_GHC -fglasgow-exts #-}

-- | Grovel over the result file given on the command-line and output a PNG
-- graph comparison of the runtime data.
--
-- Example usage:
--
-- runghc GraphResult.hs /path/to/benchmark/date-1 ... /path/to/benchmark/date-n
module Main where

import Control.Monad
import Data.List( foldl', intercalate, transpose, genericLength )
import Data.Maybe( mapMaybe )
import Debug.Trace( trace )
import Graphics.Rendering.Chart
import Text.Regex
import Test.QuickCheck( quickCheck )
import System.Environment( getArgs )
import System.FilePath.Posix

-- | Assume the input contains @n>0@ records delimited at the start by
-- whatever matches regexp.  Each element @(xs, s)@ of @groups rx f s@ is such
-- that (1) @xs@ is a list of submatches of @rx@ and (2) @s@ is the string
-- from (and not including) the last match, up to and not including the next
-- match (if any).
--
-- If the regex fails to match at all (i.e. @n=0@), the empty list is
-- returned.
groups :: Regex -> String -> [([String], String)]
groups markerRx s = snd $ groups' markerRx s
  where
    -- Returns the text before the match, if any match, in its first position.
    groups' markerRx s =
        case matchRegexAll markerRx s of
          Nothing -> (s, [])
{'fraction_non_alphanumeric': 0.11347517730496454, 'fraction_numerical': 0.004334121355397951, 'mean_word_length': 3.3106960950764006, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6095601', 'n_tokens_mistral': 772, 'n_tokens_neox': 765, 'n_words': 333}