<commit_before>package main

import (
	"flag"
	"log"
	"net/http"
	"time"

	as "github.com/icunion/arithmospora"
)

var configFile = flag.String("c", "", "/path/to/configfile")

func main() {
	// Load config
	log.Printf("Loading config %s", *configFile)
	flag.Parse()
	if err := as.ParseConfig(*configFile); err != nil {
		log.Fatal("ParseConfig: ", err)
	}

	// Set config for redis and websocket
	log.Print("Setting config for Redis and WebSocket")
	as.SetRedisConfig(as.Config.Redis)
	as.SetWebSocketConfig(as.Config.Websocket)

	// Set up sources
	log.Print("Setting up sources")
	sources := as.MakeSourcesFromConfig(as.Config)

	// Set up error channel
	errors := make(chan error)
	go func() {
		for {
			err := <-errors
			log.Println(err)
		}
	}()

	// Set up websocket handlers per source
	for _, source := range sources {
		log.Printf("Publishing source '%s'", source.Name)
		// Create Hub and run
		sourceHub := as.NewHub(source)
		go sourceHub.Run()
		http.HandleFunc("/"+source.Name, func(w http.ResponseWriter, r *http.Request) {
			as.ServeWs(sourceHub, w, r, errors)
		})

		// Publish source
		if err := source.Publish(sourceHub, errors); err != nil {
			log.Fatal("source.Publish: ", err)
		}
<commit_msg>cmd/arithmospora: Fix scoping in source for loop [refs #2432]<commit_after>package main

import (
	"flag"
	"log"
	"net/http"
	"time"

	as "github.com/icunion/arithmospora"
)

var configFile = flag.String("c", "", "/path/to/configfile")

func main() {
	// Load config
	log.Printf("Loading config %s", *configFile)
	flag.Parse()
	if err := as.ParseConfig(*configFile); err != nil {
		log.Fatal("ParseConfig: ", err)
	}

	// Set config for redis and websocket
	log.Print("Setting config for Redis and WebSocket")
	as.SetRedisConfig(as.Config.Redis)
	as.SetWebSocketConfig(as.Config.Websocket)

	// Set up sources
	log.Print("Setting up sources")
	sources := as.MakeSourcesFromConfig(as.Config)

	// Set up error channel
	errors := make(chan error)
	go func() {
		for {
			err := <-errors
			log.Println(err)
		}
	}()

	// Set up websocket handlers per source
	for _, s := range sources {
		source := s
		log.Printf("Publishing source '%s'", source.Name)
		// Create Hub and run
		sourceHub := as.NewHub(source)
		go sourceHub.Run()
		http.HandleFunc("/"+source.Name, func(w http.ResponseWriter, r *http.Request) {
			as.ServeWs(sourceHub, w, r, errors)
		})

		// Publish source
		if err := source.Publish(sourceHub, errors); err != nil {
			log.Fatal("source.Publish: ", err)
		}

{'fraction_non_alphanumeric': 0.15406162464985995, 'fraction_numerical': 0.001600640256102441, 'mean_word_length': 3.6904315196998123, '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': '3676830', 'n_tokens_mistral': 946, 'n_tokens_neox': 889, 'n_words': 220}