<commit_before>package handlers

import (
	"net/http"
	"encoding/json"
	"strings"
)

type chillifier struct {}

func NewChillifierHandler() http.Handler {
	return chillifier{}
}

func (ch chillifier) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
	rw.Header().Set("Content-Type", "text/json; charset=utf-8")
	ch.processRequest(rw, req)
}

func (ch chillifier) processRequest(rw http.ResponseWriter, req *http.Request) {
	text := req.FormValue("text")
	if text == "" {
		ch.writeErrorResponse(rw)
		return
	}

	ch.writeChillResponse(rw, text)
}

func (ch chillifier) writeErrorResponse(rw http.ResponseWriter) {
	rw.WriteHeader(http.StatusBadRequest)
	response := map[string]string{"error": "missing \"text\" parameter"}
	encoder := json.NewEncoder(rw)
	encoder.Encode(response)
}

func (ch chillifier) writeChillResponse(rw http.ResponseWriter, text string) {
	rw.WriteHeader(http.StatusOK)

	r := strings.NewReplacer(
		" the ", " the chill ",
		" The ", " The chill ",
		"The ", "The chill ",
		" a ", " a chill ",
		" A ", " A chill ",
		"A ", "A chill ",
		" their ", " their chill ",
		" Their ", " Their chill ")

	response := map[string]string{"chill text": r.Replace(text)}
	encoder := json.NewEncoder(rw)
	encoder.Encode(response)
}<commit_msg>add more chill conversion to chillifier<commit_after>package handlers

import (
	"net/http"
	"encoding/json"
	"strings"
)

type chillifier struct {}

func NewChillifierHandler() http.Handler {
	return chillifier{}
}

func (ch chillifier) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
	rw.Header().Set("Content-Type", "text/json; charset=utf-8")
	ch.processRequest(rw, req)
}

func (ch chillifier) processRequest(rw http.ResponseWriter, req *http.Request) {
	text := req.FormValue("text")
	if text == "" {
		ch.writeErrorResponse(rw)
		return
	}

	ch.writeChillResponse(rw, text)
}

func (ch chillifier) writeErrorResponse(rw http.ResponseWriter) {
	rw.WriteHeader(http.StatusBadRequest)
	response := map[string]string{"error": "missing \"text\" parameter"}
	encoder := json.NewEncoder(rw)
	encoder.Encode(response)
}

func (ch chillifier) writeChillResponse(rw http.ResponseWriter, text string) {
	rw.WriteHeader(http.StatusOK)

	r := strings.NewReplacer(
		" the ", " the chill ",
		" The ", " The chill ",
		"The ", "The chill ",
		" a ", " a chill ",
		" A ", " A chill ",
		"A ", "A chill ",
		" their ", " their chill ",
		" Their ", " Their chill ",
		" hate ", " love ",
		" Hate ", " Love ",
		"Hate ", "Love ",
		" my ", " my chill ",
		" My ", " My chill ",
		"My ", "My chill",
	)

	response := map[string]string{"chill text": r.Replace(text)}
	encoder := json.NewEncoder(rw)
	encoder.Encode(response)
}
{'fraction_non_alphanumeric': 0.1628166915052161, 'fraction_numerical': 0.0007451564828614009, 'mean_word_length': 4.3273809523809526, 'pattern_counts': {'":': 4, '<': 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': '78855', 'n_tokens_mistral': 955, 'n_tokens_neox': 915, 'n_words': 212}