<commit_before>{-# LANGUAGE OverloadedStrings #-}

-- Module      : Gen.V2.Names
-- Copyright   : (c) 2013-2014 <NAME> <<EMAIL>>
-- License     : This Source Code Form is subject to the terms of
--               the Mozilla Public License, v. 2.0.
--               A copy of the MPL can be found in the LICENSE file or
--               you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer  : <NAME> <<EMAIL>>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)

module Gen.V2.Names where

import           Data.Char
import           Data.Maybe
import           Data.Monoid
import           Data.Text            (Text)
import qualified Data.Text            as Text
import           Data.Text.Manipulate

enumName :: Text -> Text -> Text
enumName k = mappend (Text.toUpper k) . toPascal . Text.replace ":" "-"

lensName :: Text -> Text
lensName = stripText "_"

keyPython :: Text -> Text
keyPython = toSnake . keyName . Text.replace "." "_"

keyName :: Text -> Text
keyName t
    | "_" `Text.isPrefixOf` t = lowerHead (dropLower t)
    | otherwise               = t

ctorName :: Text -> Text
ctorName t = toSpinal (fromMaybe t ("'" `Text.stripSuffix` t))
<commit_msg>Tweaking enum branch names<commit_after>{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns      #-}

-- Module      : Gen.V2.Names
-- Copyright   : (c) 2013-2014 <NAME> <<EMAIL>>
-- License     : This Source Code Form is subject to the terms of
--               the Mozilla Public License, v. 2.0.
--               A copy of the MPL can be found in the LICENSE file or
--               you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer  : <NAME> <<EMAIL>>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)

module Gen.V2.Names where

import           Data.Char
import           Data.Maybe
import           Data.Monoid
import           Data.Text            (Text)
import qualified Data.Text            as Text
import           Data.Text.Manipulate

enumName :: Text -> Text -> Text
enumName k v = Text.toUpper k <> (toPascal . Text.toLower $ Text.replace ":" "-" v)

lensName :: Text -> Text
lensName = stripText "_"

keyPython :: Text -> Text
keyPython = toSnake . keyName . Text.replace "." "_"

keyName :: Text -> Text
keyName t
    | "_" `Text.isPrefixOf` t = lowerHead (dropLower t)
    | otherwise               = t

ctorName :: Text -> Text
ctorName t = toSpinal (fromMaybe t ("'" `Text.stripSuffix` t))

{'fraction_non_alphanumeric': 0.1222583265637693, 'fraction_numerical': 0.011372867587327376, 'mean_word_length': 2.133587786259542, 'pattern_counts': {'":': 2, '<': 16, '<?xml version=': 0, '>': 28, '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': '5074475', 'n_tokens_mistral': 778, 'n_tokens_neox': 742, 'n_words': 245}