<commit_before>package trindex

import (
	"fmt"
	"math/rand"
	"os"
	"path/filepath"
	"testing"
	"time"
)

func TestSimple(t *testing.T) {
	rand.Seed(time.Now().Unix())
	idx := NewIndex(filepath.Join(os.TempDir(), fmt.Sprintf("trindex_test_%d.idx", rand.Int63())))
	defer idx.Close()

	dataset := []string{
		"Mallorca", "Ibiza", "Menorca", "Pityusen", "Formentera", "Berlin", "New York", "Yorkshire",
	}

	for _, data := range dataset {
		idx.Insert(data)
	}

	queries := []string{
		"malorka", "ibza", "enorc", "yusen", "formtera", "bärlihn", "newyorc", "yorkshir",
	}

	for i, qry := range queries {
		rs := idx.Query(qry, 1)
		if len(rs) < 1 {
			t.Fatalf("len(rs) != 1, instead %d", len(rs))
		}
		if rs[0].ID != uint64(i+1) {
			t.Log(rs)
			t.Fatalf("rs[0].ID != idx, instead %d", rs[0].ID)
		}
	}
}
<commit_msg>Fixing the tests<commit_after>package trindex

import (
	"fmt"
	"math/rand"
	"os"
	"path/filepath"
	"testing"
	"time"
)

func TestSimple(t *testing.T) {
	rand.Seed(time.Now().Unix())
	idx := NewIndex(filepath.Join(os.TempDir(), fmt.Sprintf("trindex_test_%d.idx", rand.Int63())))
	defer idx.Close()

	dataset := []string{
		"Mallorca", "Ibiza", "Menorca", "Pityusen", "Formentera", "Berlin", "New York", "Yorkshire",
	}

	for _, data := range dataset {
		idx.Insert(data)
	}

	queries := []string{
		"malorka", "ibza", "enorc", "yusen", "formtera", "bärlihn", "newyorc", "yorkshir",
	}

	for i, qry := range queries {
		rs := idx.Query(qry, 1, 0)
		if len(rs) < 1 {
			t.Fatalf("len(rs) != 1, instead %d", len(rs))
		}
		if rs[0].ID != uint64(i+1) {
			t.Log(rs)
			t.Fatalf("rs[0].ID != idx, instead %d", rs[0].ID)
		}
	}
}

{'fraction_non_alphanumeric': 0.2271619975639464, 'fraction_numerical': 0.014007308160779537, 'mean_word_length': 3.978787878787879, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3549685', 'n_tokens_mistral': 783, 'n_tokens_neox': 731, 'n_words': 143}