Measuring code sentiment in a Git repository

Vadim Markovtsev, source{d}.

Measuring code sentiment in a Git repository

Vadim Markovtsev, source{d}

What we want to achieve

Technologies

go-git flying gopher holding a trident logo

src-d/go-git

src-d/hercules

src-d/hercules

Babelfish

Classic approach

Babelfish

Our approach

import (
	"gopkg.in/bblfsh/client-go.v2"
	"gopkg.in/bblfsh/client-go.v2/tools"
)
client, _ := bblfsh.NewClient("0.0.0.0:9432")
resp, _ := client.NewParseRequest().Content("...").Do()
nodes, err := tools.Filter(resp.UAST, "//*[@roleComment]")
// nodes[0].Token

Tensorflow

Tensorflow graph scheme Tensorflow graph scheme

Tensorflow

Tensorflow

Production pipeline:

Tensorflow

modelBytes, _ := assets.Asset("model.pb")
graph := tf.NewGraph()
graph.Import(modelBytes, "")
input := graph.Operation("input").Output(0)
output := graph.Operation("output").Output(0)
sess, _ := tf.NewSession(graph, &tf.SessionOptions{})
feed, _ := tf.NewTensor([][]float32{})
result, _ := sess.Run(
    map[tf.Output]*tf.Tensor{input: input1},
    []tf.Output{output}, nil)
		
Happy and sad gophers.

vmarkovtsev/BiDiSentiment

vmarkovtsev/BiDiSentiment

		echo "When I wrote this, only God and I understood \
		what I was doing. Now, God only knows" | $GOPATH/bin/sentiment
		
0.8803515

vmarkovtsev/BiDiSentiment

		echo "sometimes I believe compiler ignores \
		all my comments" | $GOPATH/bin/sentiment
		
0.88705057

vmarkovtsev/BiDiSentiment

		echo "drunk, fix later" | $GOPATH/bin/sentiment
		
0.08034721

Slap projects together and deploy

# install and run bblfshd
# install hercules
# install libtensorflow
hercules --sentiment https://github.com/golang/go

Results

Project Positive Negative Effective
pygame/pygame 93.4 98.2 -4.8
pallets/flask 23.6 31.9 -8.3
django/django 462.1 536.1 -74.0
golang/go 402.1 507.3 -105.2
kubernetes/kubernetes 186.1 91.6 94.5
keras-team/keras 104.8 71.1 33.7

- golang/go

+ golang/go

+ keras-team/keras

Conclusion

Papers

Via Mining Software Repositories:

Thank you

My contacts:

#MLonCode