<commit_before>package main

import (
	"encoding/json"
	"io"
	"io/ioutil"
	"net/http"

	"github.com/gorilla/mux"
	"gopkg.in/yaml.v2"
)

/**
Analyzer of programming language
Input:
 git diff from one commit
Collected data:
 - user email
 - filename
Rules:
 - defined in config file as regexps

Output:
 - JSON sent to Collector API

*/

var languageAnalyzer Analyzer
var rulesAnalyzer Analyzer
var config *Config

func main() {
	c, err := NewConfig("etc/app.ini")
	if err != nil {
		panic(err.Error())
	}
	config = c

	rules, err := readRules(config.RulesFile)
	if err != nil {
		panic(err.Error())
	}
	rulesAnalyzer = NewRulesAnalyzer(rules, config.Source)
	languageAnalyzer = NewLanguageAnalyzer(config.DefaultXp)

	r := mux.NewRouter()
	r.HandleFunc("/commit", CommitHandler).
		Methods("POST")

	http.Handle("/", r)
}<commit_msg>Bluemix spicific<commit_after>package main

import (
	"encoding/json"
	"io"
	"io/ioutil"
	"net/http"
	"os"
	"strconv"

	"github.com/gorilla/mux"
	"gopkg.in/yaml.v2"
)

/**
Analyzer of programming language
Input:
 git diff from one commit
Collected data:
 - user email
 - filename
Rules:
 - defined in config file as regexps

Output:
 - JSON sent to Collector API

*/

var languageAnalyzer Analyzer
var rulesAnalyzer Analyzer
var config *Config

func main() {
	c, err := NewConfig("etc/app.ini")
	if err != nil {
		panic(err.Error())
	}
	config = c

	rules, err := readRules(config.RulesFile)
	if err != nil {
		panic(err.Error())
	}
	rulesAnalyzer = NewRulesAnalyzer(rules, config.Source)
	languageAnalyzer = NewLanguageAnalyzer(config.DefaultXp)

	r := mux.NewRouter()
	r.HandleFunc("/commit", CommitHandler).
		Methods("POST")
	if port := os.Getenv("VCAP_APP_PORT"); len(port) != 0 {
		if p, e := strconv.Atoi(port); e == nil && p > 0 {
			config.Port = int(p)
		}
	}

	http.Handle("/", r)
}
{'fraction_non_alphanumeric': 0.14136986301369864, 'fraction_numerical': 0.002191780821917808, 'mean_word_length': 3.9086021505376345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2412330', 'n_tokens_mistral': 698, 'n_tokens_neox': 672, 'n_words': 170}