<commit_before>package main

import (
	"flag"
	"log"
	"path"
	"strings"

	"github.com/to6ka/go-queryset/queryset"
)

func main() {
	inFile := flag.String("in", "models.go", "path to input file")
	outFile := flag.String("out", "{in}_queryset.go", "path to output file")
	flag.Parse()

	if strings.Contains(*outFile, "{in}") {
		baseName := path.Base(*inFile)
		*outFile = strings.Replace(*outFile, "{in}", baseName, 1)
	}

	if err := queryset.GenerateQuerySets(*inFile, *outFile); err != nil {
		log.Fatalf("can't generate query sets: %s", err)
	}
}<commit_msg>smart file detection<commit_after>package main

import (
	"flag"
	"log"
	"os"
	"path"
	"strings"

	"github.com/to6ka/go-queryset/queryset"
)

var outFile = flag.String("out", "{in}_queryset.go", "path to output file")

func main() {
	flag.Parse()

	inFile := os.Getenv("GOFILE")
	inFile = path.Base(inFile)

	fileStat, err := os.Stat(inFile)
	if err != nil {
		log.Fatalf("failed to access file %s", inFile)
	}
	if !fileStat.Mode().IsRegular() {
		log.Fatalf("file %s is not a regular file", inFile)
	}

	if strings.Contains(*outFile, "{in}") {
		inName := strings.TrimSuffix(inFile, ".go")
		*outFile = strings.Replace(*outFile, "{in}", inName, 1)
	}

	if err := queryset.GenerateQuerySets(inFile, *outFile); err != nil {
		log.Fatalf("can't generate query sets: %s", err)
	}
}
{'fraction_non_alphanumeric': 0.187593423019432, 'fraction_numerical': 0.0029895366218236174, 'mean_word_length': 4.421052631578948, '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': '1334033', 'n_tokens_mistral': 531, 'n_tokens_neox': 513, 'n_words': 118}