<commit_before>package model

import "net/http"
import "github.com/ishiikurisu/moneylog"
import "io"

func RegisterApi() {
    http.HandleFunc("/api/new", func (w http.ResponseWriter, r *http.Request) {
        log := moneylog.EmptyLog()
        io.WriteString(w, log.ToString())
    })
    http.HandleFunc("/api/add", func (w http.ResponseWriter, r *http.Request) {
        rawDescription := r.FormValue("description")
        rawValue := r.FormValue("value")
        rawLog := r.FormValue("log")
        log := moneylog.LogFromString(rawLog)
        description, value := stuffFromRaw(rawDescription, rawValue)
        log.Add(description, value)
        io.WriteString(w, log.ToString())
    })
    http.HandleFunc("/api/get/balance", func (w http.ResponseWriter, r *http.Request) {
        rawLog := r.FormValue("log")
        log := moneylog.LogFromString(rawLog)
        balance := log.CalculateBalance()
        io.WriteString(w, stuff2raw(balance))
    })
}<commit_msg>Adding basic remaining tools for API<commit_after>package model

import "net/http"
import "github.com/ishiikurisu/moneylog"
import "io"

func RegisterApi() {
    http.HandleFunc("/api/new", func (w http.ResponseWriter, r *http.Request) {
        log := moneylog.EmptyLog()
        io.WriteString(w, log.ToString())
    })
    http.HandleFunc("/api/add", func (w http.ResponseWriter, r *http.Request) {
        rawDescription := r.FormValue("description")
        rawValue := r.FormValue("value")
        rawLog := r.FormValue("log")
        log := moneylog.LogFromString(rawLog)
        description, value := stuffFromRaw(rawDescription, rawValue)
        log.Add(description, value)
        io.WriteString(w, log.ToString())
    })
    http.HandleFunc("/api/get/balance", func (w http.ResponseWriter, r *http.Request) {
        rawLog := r.FormValue("log")
        log := moneylog.LogFromString(rawLog)
        balance := log.CalculateBalance()
        io.WriteString(w, stuff2raw(balance))
    })
    http.HandleFunc("/api/get/descriptions", func (w http.ResponseWriter, r *http.Request) {
        rawLog := r.FormValue("log")
        log := moneylog.LogFromString(rawLog)
        descriptions := log.GetDescriptions()
        outlet := ""
        for _, description := range descriptions {
            outlet += description + ","
        }
        io.WriteString(w, outlet)
    })
    http.HandleFunc("/api/get/values", func (w http.ResponseWriter, r *http.Request) {
        rawLog := r.FormValue("log")
        log := moneylog.LogFromString(rawLog)
        values := log.GetValues()
        outlet := ""
        for _, value := range values {
            outlet += stuff2raw(value) + ","
        }
        io.WriteString(w, outlet)
    })
}
{'fraction_non_alphanumeric': 0.14548126377663484, 'fraction_numerical': 0.0011021307861866275, 'mean_word_length': 2.7819444444444446, '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': '6088748', 'n_tokens_mistral': 824, 'n_tokens_neox': 830, 'n_words': 159}