<commit_before>package opt

import (
	"encoding/json"
	"reflect"

	"github.com/algolia/algoliasearch-client-go/algolia/errs"
)

type TypoToleranceOption struct {
	valueBool   bool
	valueString string
}

func TypoTolerance(value bool) *TypoToleranceOption {
	return &TypoToleranceOption{valueBool: value}
}

func TypoToleranceMin() *TypoToleranceOption {
	return &TypoToleranceOption{valueString: "min"}
}

func TypoToleranceStrict() *TypoToleranceOption {
	return &TypoToleranceOption{valueString: "strict"}
}

func (o TypoToleranceOption) Get() (bool, string) {
	return o.valueBool, o.valueString
}

func (o TypoToleranceOption) MarshalJSON() ([]byte, error) {
	if len(o.valueString) > 0 {
		return json.Marshal(o.valueString)
	}
	return json.Marshal(o.valueBool)
}

func (o *TypoToleranceOption) UnmarshalJSON(data []byte) error {
	if string(data) == "null" {
		o.valueBool = true
		return nil
	}

	var valueString string
	if err := json.Unmarshal(data, &valueString); err == nil {
		o.valueString = valueString
		return nil
	}

	var valueBool bool
	if err := json.Unmarshal(data, &valueBool); err == nil {
		o.valueBool = valueBool
		return nil
	}

	return errs.ErrJSONDecode(data, "TypoTolerance")
}

func (o *TypoToleranceOption) Equal(o2 *TypoToleranceOption) bool {
	if o2 == nil {
		return o.valueBool == true && o.valueString == ""
	}
	return reflect.DeepEqual(o, o2)
}

func TypoToleranceEqual(o1, o2 *TypoToleranceOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)<commit_msg>fixed: correctly deserialized boolean as strings for TypoTolerance option<commit_after>package opt

import (
	"encoding/json"
	"fmt"

	"github.com/algolia/algoliasearch-client-go/algolia/errs"
)

type TypoToleranceOption struct {
	value string
}

func TypoTolerance(value bool) *TypoToleranceOption {
	return &TypoToleranceOption{value: fmt.Sprintf("%t", value)}
}

func TypoToleranceMin() *TypoToleranceOption {
	return &TypoToleranceOption{value: "min"}
}

func TypoToleranceStrict() *TypoToleranceOption {
	return &TypoToleranceOption{value: "strict"}
}

func (o TypoToleranceOption) Get() (bool, string) {
	if o.value == "true" {
		return true, ""
	}
	if o.value == "false" {
		return false, ""
	}
	return false, o.value
}

func (o TypoToleranceOption) MarshalJSON() ([]byte, error) {
	return json.Marshal(o.value)
}

func (o *TypoToleranceOption) UnmarshalJSON(data []byte) error {
	if string(data) == "null" {
		o.value = "true"
		return nil
	}

	var v string
	if err := json.Unmarshal(data, &v); err == nil {
		o.value = v
		return nil
	}

	var b bool
	if err := json.Unmarshal(data, &b); err == nil {
		o.value = fmt.Sprintf("%t", b)
		return nil
	}

	return errs.ErrJSONDecode(data, "TypoTolerance")
}

func (o *TypoToleranceOption) Equal(o2 *TypoToleranceOption) bool {
	if o2 == nil {
		return o.value == "true"
	}
	return o.value == o2.value
}

func TypoToleranceEqual(o1, o2 *TypoToleranceOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
{'fraction_non_alphanumeric': 0.12991735537190083, 'fraction_numerical': 0.007603305785123967, 'mean_word_length': 4.572744014732965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7031938', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1124, 'n_words': 265}