<commit_before>package provider

import (
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
	"strings"

	"koding/kites/kloud/stack"
	"koding/kites/kloud/utils/object"

	"github.com/hashicorp/hcl"
	"github.com/hashicorp/hcl/hcl/ast"
	"github.com/hashicorp/hcl/json/parser"
	"github.com/hashicorp/hil"
	"github.com/hashicorp/terraform/config"
	"github.com/koding/logging"
)

// Slice is a workaround for hcl.DecodeObject,
// which always appends
type Slice map[string]interface{}

var (
	_ json.Marshaler   = new(Slice)
	_ json.Unmarshaler = new(Slice)
)

func (s *Slice) init(v []interface{}) {
	*s = make(Slice, len(v))

	for i := range v {
		(*s)[strconv.Itoa(i)] = v[i]
	}
}

func (s Slice) slice() []interface{} {
	max := 0
	slice := make([]interface{}, len(s))

	for k, v := range s {
		i, err := strconv.Atoi(k)
		if err != nil {
			// HCL's decoder errornously merges object's keys
			// into the slice. In order to make it working,<commit_msg>provider: finish inline doc<commit_after>package provider

import (
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
	"strings"

	"koding/kites/kloud/stack"
	"koding/kites/kloud/utils/object"

	"github.com/hashicorp/hcl"
	"github.com/hashicorp/hcl/hcl/ast"
	"github.com/hashicorp/hcl/json/parser"
	"github.com/hashicorp/hil"
	"github.com/hashicorp/terraform/config"
	"github.com/koding/logging"
)

// Slice is a workaround for hcl.DecodeObject,
// which always appends to existing slices,
// thus making the output of DecodeObject
// non-idempotent, as it always doubles
// any slices values.
//
// Wrapping a slice value with ToSlice
// prevents from doubling the items
// on hcl.DecodeObject.
type Slice map[string]interface{}

var (
	_ json.Marshaler   = new(Slice)
	_ json.Unmarshaler = new(Slice)
)

func (s *Slice) init(v []interface{}) {
	*s = make(Slice, len(v))

	for i := range v {
		(*s)[strconv.Itoa(i)] = v[i]
	}
}

func (s Slice) slice() []interface{} {
	max := 0
	slice := make([]interface{}, len(s))

	for k, v := range s {
		i, err := strconv.Atoi(k)
		if err != nil {
			// HCL's decoder errornously merges object's keys
			// into the slice. In order to make it working,
{'fraction_non_alphanumeric': 0.15821596244131456, 'fraction_numerical': 0.0009389671361502347, 'mean_word_length': 3.6835164835164833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3627038', 'n_tokens_mistral': 866, 'n_tokens_neox': 828, 'n_words': 198}