<commit_before>package db

import (
	"io/ioutil"
	"log"
	"math/rand"
	"strings"
)

var links []string

func initLinks() {
	content, err := ioutil.ReadFile("resources/links.txt")
	if err != nil {
		log.Fatal(err)
	}
	links = strings.Split(string(content), "\n")
}

func RandomLinks() []string {
	// urls of chosen random links
	var r []string
	// size of this map used to check when 3 unique links have been selected
	m := make(map[int]bool)

	for len(m) < 3 {
		i := rand.Intn(len(links))
		if !m[i] {
			m[i] = true
			r = append(r, links[i])
		}
	}
	return r
}
<commit_msg>Make sure random links returned are not just empty strings<commit_after>package db

import (
	"io/ioutil"
	"log"
	"math/rand"
	"strings"
)

var links []string

func initLinks() {
	content, err := ioutil.ReadFile("resources/links.txt")
	if err != nil {
		log.Fatal(err)
	}
	links = strings.Split(string(content), "\n")
}

func RandomLinks() []string {
	// urls of chosen random links
	var r []string
	// size of this map used to check when 3 unique links have been selected
	m := make(map[int]bool)

	for len(m) < 3 {
		i := rand.Intn(len(links))
		if !m[i] && links[i] != "" {
			m[i] = true
			r = append(r, links[i])
		}
	}
	return r
}

{'fraction_non_alphanumeric': 0.15828524319868095, 'fraction_numerical': 0.0032976092333058533, 'mean_word_length': 3.366906474820144, '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': '284990', 'n_tokens_mistral': 495, 'n_tokens_neox': 470, 'n_words': 136}