<commit_before>{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}

module Hyakko.Types where

import Control.Applicative ((<$>), (<*>), empty)
import Data.Aeson
import Data.HashMap.Strict (HashMap)
import Data.Text (Text)
import System.Console.CmdArgs

-- The `Sections` type is just an alias to keep type signatures short.
type Sections = [HashMap String Text]

-- Alias `Languages`, for the multiple different languages inside the
-- `languages.json` file.
type Languages = HashMap String Language

-- Better data type for language info — compared to the `Object` data type
-- in `Aeson`.
data Language =
  Language { name_     :: Text
           , symbol    :: Text
           , literate  :: Maybe Bool
           , litSymbol :: Maybe Text
           }

instance FromJSON Language where
  parseJSON (Object o) = Language
                     <$> o .:  "name"
                     <*> o .:  "symbol"
                     <*> o .:? "literate"
                     <*> o .:? "litSymbol"
  parseJSON _          = empty

-- Data structure for command line argument parsing.
data Hyakko =<commit_msg>Use defaults making the literate type just a Bool<commit_after>{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}

module Hyakko.Types where

import Control.Applicative ((<$>), (<*>), empty)
import Data.Aeson
import Data.HashMap.Strict (HashMap)
import Data.Text (Text)
import System.Console.CmdArgs

-- The `Sections` type is just an alias to keep type signatures short.
type Sections = [HashMap String Text]

-- Alias `Languages`, for the multiple different languages inside the
-- `languages.json` file.
type Languages = HashMap String Language

-- Better data type for language info — compared to the `Object` data type
-- in `Aeson`.
data Language =
  Language { name_     :: Text
           , symbol    :: Text
           , literate  :: Bool
           , litSymbol :: Maybe Text
           }

instance FromJSON Language where
  parseJSON (Object o) = Language
                     <$> o .:  "name"
                     <*> o .:  "symbol"
                     <*> o .:? "literate" .!= False
                     <*> o .:? "litSymbol"
  parseJSON _          = empty

-- Data structure for command line argument parsing.
data Hyakko =
{'fraction_non_alphanumeric': 0.10660124888492417, 'fraction_numerical': 0.0, 'mean_word_length': 2.3328380386329868, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '70882', 'n_tokens_mistral': 637, 'n_tokens_neox': 621, 'n_words': 224}