<commit_before>package http

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"path"
	"path/filepath"
	"strings"

	govalidator "gopkg.in/asaskevich/govalidator.v4"

	_error "errors"

	"os"

	"github.com/SparrowDb/sparrowdb/auth"
	"github.com/SparrowDb/sparrowdb/errors"
	"github.com/SparrowDb/sparrowdb/script"
	"github.com/SparrowDb/sparrowdb/util"
	"github.com/gin-gonic/gin"
)

func scriptList() ([]string, error) {
	scriptPath, err := script.GetScriptPath()
	if err != nil {
		return nil, err
	}

	files, err := util.ListDirectory(scriptPath)
	if err != nil {
		return nil, err
	}

	scriptName := []string{}

	for _, scriptDir := range files {
		sname := path.Base(scriptDir)
		n := strings.LastIndexByte(sname, '.')
		if n > 0 {
			sname = sname[:n]
		}
		scriptName = append(scriptName, sname)
	}

	return scriptName, nil
}

func readScriptFile(name string) (string, error) {
	scriptPath, err := script.GetScriptPath()
	if err != nil {
		return "", err
	}

	fpath := filepath.Join(scriptPath, name+".lua")
	if exists, err := util.Exists(fpath); exists == false {
		if err != nil {
			return "", nil
		}
		return "", _error.New(fmt.Sprintf(errors.ErrScriptNotExists.Error(), name))<commit_msg>fix path script list<commit_after>package http

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"path/filepath"
	"strings"

	govalidator "gopkg.in/asaskevich/govalidator.v4"

	_error "errors"

	"os"

	"github.com/SparrowDb/sparrowdb/auth"
	"github.com/SparrowDb/sparrowdb/errors"
	"github.com/SparrowDb/sparrowdb/script"
	"github.com/SparrowDb/sparrowdb/util"
	"github.com/gin-gonic/gin"
)

func scriptList() ([]string, error) {
	scriptPath, err := script.GetScriptPath()
	if err != nil {
		return nil, err
	}

	files, err := util.ListDirectory(scriptPath)
	if err != nil {
		return nil, err
	}

	scriptName := []string{}

	for _, scriptDir := range files {
		sname := filepath.Base(scriptDir)
		n := strings.LastIndexByte(sname, '.')
		if n > 0 {
			sname = sname[:n]
		}
		scriptName = append(scriptName, sname)
	}

	return scriptName, nil
}

func readScriptFile(name string) (string, error) {
	scriptPath, err := script.GetScriptPath()
	if err != nil {
		return "", err
	}

	fpath := filepath.Join(scriptPath, name+".lua")
	if exists, err := util.Exists(fpath); exists == false {
		if err != nil {
			return "", nil
		}
		return "", _error.New(fmt.Sprintf(errors.ErrScriptNotExists.Error(), name))
{'fraction_non_alphanumeric': 0.15681341719077568, 'fraction_numerical': 0.0016771488469601676, 'mean_word_length': 3.9502074688796682, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5411233', 'n_tokens_mistral': 972, 'n_tokens_neox': 923, 'n_words': 185}