<commit_before>module Data.CardEffect exposing (CardEffect(..), decoder, effectToString, effectToHtml)

import Html exposing (img, text, Html)
import Html.Attributes exposing (src, class)
import Regex exposing (regex, find, replace, HowMany(..), Match)
import Json.Decode exposing (field, map, string, oneOf, null, Decoder)


type CardEffect
    = Play String
    | Push String
    | Constant String
    | Attack String
    | Defend String
      -- TODO: Any isn't the best name
    | Any String


decoder : Decoder CardEffect
decoder =
    field "effect" (oneOf [
        (map toEffect string),
        null (Any "")
    ])



-- Utils


effectToString : CardEffect -> String
effectToString effect =
    case effect of
        Play content ->
            content

        Push content ->
            content

        Constant content ->
            content
<commit_msg>Handle "effect" or "effect_old" keys<commit_after>module Data.CardEffect exposing (CardEffect(..), decoder, effectToString, effectToHtml)

import Html exposing (img, text, Html)
import Html.Attributes exposing (src, class)
import Regex exposing (regex, find, replace, HowMany(..), Match)
import Json.Decode exposing (field, map, string, oneOf, null, Decoder)


type CardEffect
    = Play String
    | Push String
    | Constant String
    | Attack String
    | Defend String
      -- TODO: Any isn't the best name
    | Any String


effectDecoder : Decoder CardEffect
effectDecoder =
    field "effect"
        (oneOf
            [ (map toEffect string)
            , null (Any "")
            ]
        )


oldEffectDecoder : Decoder CardEffect
oldEffectDecoder =
    field "effect_old"
        (oneOf
            [ (map toEffect string)
            , null (Any "")
            ]
        )


decoder : Decoder CardEffect
decoder =
    oneOf
        [ effectDecoder
        , oldEffectDecoder
        ]



-- Utils


effectToString : CardEffect -> String
effectToString effect =
    case effect of
        Play content ->
            content

        Push content ->
            content

        Constant content ->
            content

{'fraction_non_alphanumeric': 0.0835707502374169, 'fraction_numerical': 0.0, 'mean_word_length': 2.211890243902439, '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': '5074860', 'n_tokens_mistral': 596, 'n_tokens_neox': 555, 'n_words': 193}