Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP 1617 - visualisation #231

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
28e8432
Adding Prototype of ncloc module
Nov 26, 2016
3f3aa9f
Added prototype for comment extractor
Dec 2, 2016
65a8997
Improved Comments Module
Dec 7, 2016
7c29c8d
Added general information and developerRanks modules
m-michels Dec 8, 2016
63df99e
Improving CommentExtractor & adding tests
Dec 19, 2016
9349883
Added Visualisation approch, read README
Dec 22, 2016
31d08d6
added visualization module and concept
Skaduwa Dec 28, 2016
4064d8f
CommentExtractor -changed tests, readme
Jan 15, 2017
47aee64
Merge branch 'pp-1617' of https://github.com/101companies/101worker i…
m-michels Jan 16, 2017
ef9d6cc
visualization module:
Skaduwa Jan 22, 2017
2e68e46
Extending visualisation protoype
Jan 25, 2017
b2811bb
Updating structure after todays meeting
Skaduwa Jan 27, 2017
b5bbad9
Sentiment module added
Jan 30, 2017
69b6f95
Reworking visualisation, allow multiple charts from same type
Feb 15, 2017
fe10698
Improving visualistion withut module-Prototype
Mar 12, 2017
db82a68
Update pie.html
Skaduwa Mar 13, 2017
ab61152
Update bar.html
Skaduwa Mar 13, 2017
d3fa38a
added simpleComments for testing, added documentation to simpleSentim…
Mar 17, 2017
30217fe
small modifications commentSentimentPerLanguage
Mar 17, 2017
b323c92
small additions
Mar 17, 2017
13bae76
Improving ncloc
Mar 17, 2017
8a2f458
Update
m-michels May 10, 2017
1ff5c12
modified extractComments, added tests
May 10, 2017
276a775
Merge branch 'pp-1617' of https://github.com/101companies/101worker i…
May 10, 2017
c55f62a
modified exctratComments
May 10, 2017
6f83a77
added google basic templates
Skaduwa May 17, 2017
f28d9b9
UPdating creation of index.html
m-michels May 17, 2017
dd9c1f7
google implementation for locPerContribution
Skaduwa May 17, 2017
bda499c
Merge branch 'pp-1617' of https://github.com/101companies/101worker i…
Skaduwa May 17, 2017
e45b159
update devRanks and more
m-michels May 17, 2017
0514fe1
Merge branch 'pp-1617' of https://github.com/101companies/101worker i…
m-michels May 17, 2017
91ee87e
update for index page
m-michels May 18, 2017
ed57166
resync
Skaduwa May 31, 2017
bceb07b
Merge branch 'pp-1617' of https://github.com/101companies/101worker i…
Skaduwa May 31, 2017
7fc4f28
update visualizer
Skaduwa May 31, 2017
cf6ccde
new templates
m-michels May 31, 2017
2fb0464
Merge branch 'pp-1617' of https://github.com/101companies/101worker i…
m-michels May 31, 2017
bbfa1c5
update
m-michels May 31, 2017
b75ec0e
updatefor googleChart support
Skaduwa May 31, 2017
5ca30d6
update
m-michels May 31, 2017
bc0292c
documentation and refactoring
Skaduwa Jun 14, 2017
d71bbfe
update
m-michels Jun 14, 2017
8517e0e
fixed markup
Skaduwa Jun 21, 2017
c226d4a
update
m-michels Jun 21, 2017
5771896
Merge branch 'pp-1617' of https://github.com/101companies/101worker i…
m-michels Jun 21, 2017
421f947
update
m-michels Jun 28, 2017
ed64ec4
sentiment analysis (+visualization)
Jun 29, 2017
5ef963e
Update ReadMe.md
Skaduwa Aug 5, 2017
4981cf7
small adjustments to commentSentiment module
Aug 6, 2017
439db6a
modified module commentSentimentPerLanguage, made simpler, added filt…
Aug 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion bin/worker_lib/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import json
import logging

from .visualiser import create_googleChart as create_googleChart_viz


def abs_path(path):
return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', path))

Expand Down Expand Up @@ -100,6 +103,26 @@ def write_dump(dump_name, data):
json.dump(data, f, indent=4)
logging.debug('Wrote dump %s at %s', dump_name, d)


########
# d3js #
########
def create_piechart(name,xName,yName,xValue,yValue):
moduleName = str(module).replace("'","").split(" ")[1]
c_piechart(name,moduleName,xName,yName,xValue,yValue,get_env('views101dir'))
#
########


#################
# Google Charts #
#################
#
def create_googleChart(chartType, fileName, data, options = None):
create_googleChart_viz(chartType, str(module).replace("'","").split(" ")[1], fileName, get_env('views101dir'), data, options)
#
#################

return AttrDict({
'get_env': get_env,
'write_derived_resource': write_derived_resource,
Expand All @@ -108,5 +131,7 @@ def write_dump(dump_name, data):
'read_dump': read_dump,
'write_dump': write_dump,
'get_derived_resource': get_derived_resource,
'remove_dump': remove_dump
'remove_dump': remove_dump,
'create_piechart': create_piechart,
'create_googleChart': create_googleChart
})
28 changes: 28 additions & 0 deletions bin/worker_lib/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys
import traceback
import shutil

class Executor(object):

Expand All @@ -23,6 +24,15 @@ def _exec(self, change):
def run(self, changes):
for change in changes:
self._exec(change)
####### added to create Image ################
if self._module.config.get('visualization') == True :
print("Creating Image")
folderName = str(self._module).replace("'","").split(" ")[1]
path = self._env.get_env('views101dir')
if(os.path.isdir(path + os.sep + folderName)):
shutil.rmtree(path + os.sep + folderName)
self._module.visualize(self._env)
##############################################

class FileFullSweepExecutor(Executor):

Expand All @@ -38,6 +48,15 @@ def run(self, changes):
}

self._exec(change)
####### added to create Image ################
if self._module.config.get('visualization') == True :
print("Creating Image")
folderName = str(self._module).replace("'","").split(" ")[1]
path = self._env.get_env('views101dir')
if(os.path.isdir(path + os.sep + folderName)):
shutil.rmtree(path + os.sep + folderName)
self._module.visualize(self._env)
##############################################

class AllFullSweepExecutor(Executor):

Expand All @@ -52,3 +71,12 @@ def _exec(self):

def run(self, changes):
self._exec()
####### added to create Image ################
if self._module.config.get('visualization') == True :
print("Creating Image")
folderName = str(self._module).replace("'","").split(" ")[1]
path = self._env.get_env('views101dir')
if(os.path.isdir(path + os.sep + folderName)):
shutil.rmtree(path + os.sep + folderName)
self._module.visualize(self._env)
##############################################
2 changes: 1 addition & 1 deletion bin/worker_lib/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def import_module(module_name):
'moretagclouds',
'plainTextWikiDump',
'zip',
'mongodump'
'mongodump'
]

modules = [import_module(module) for module in modules]
167 changes: 167 additions & 0 deletions bin/worker_lib/visualiser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import os
import json
import csv
import shutil


###################
# Service methods #
###################
#
# check if folder exists or create
def check_path(path):
if not os.path.exists(path):
os.makedirs(path)
#
###################



########
# d3JS #
########
#
# Write CSV file
def write_csv(target,csvData,name):
d = os.path.join(target, name + '.csv')
with open(d, 'w') as f:
wr = csv.writer(f)
for item in csvData:
wr.writerow(item)
return name + '.csv'
#
# create pieChart
def create_piechart(name,moduleName,xName,yName,xValues,yValues,path):
dataPath = os.path.join(path,moduleName)
check_path(dataPath)
templateName = "pie"
csvData = []
labels = ['age','population']
csvData.append(labels)
for x,y in zip(xValues,yValues):
csvData.append([x,y])
csvname = write_csv(dataPath,csvData, name)
copyTemplateToTarget(path,name,moduleName, csvname,templateName)
folderIterator(path)
#
# copy template to file
def copyTemplateToTarget(path,name,moduleName, dataname, templateName):
#hard-code template folder path??
templatePath = os.path.join('templates',templateName+'.html')
targetPath = os.path.join(path,moduleName, name + '.html')
insertTemplate(templatePath, targetPath, dataname)
#
# insetr template
def insertTemplate(template, targetpath, dataname):
inputfile = open(template)
outputfile = open(targetpath, 'w')
for line in inputfile:
if line.find('enterDataHere'):
line = line.replace('enterDataHere', dataname)
outputfile.writelines(line)
#
########


#################
# Google Charts #
#################
#
# GOOGLE-Chart
def create_googleChart(chartType, moduleName, fileName, path, data, options):

sourcePath = os.path.join('templates', 'googleCharts', chartType + '.html')

if not os.path.isfile(sourcePath):
raise FileNotFoundError('Could not find template: ' + '\'' + sourcePath + '\'\nPlease check the charttype.')

targetFolder = os.path.join(path, moduleName)
targetPath = os.path.join(path, moduleName, fileName.replace(' ', '_') + '.html')
inputFile = open(sourcePath, 'r')
check_path(targetFolder)
outputFile = open(targetPath, 'w')
for line in inputFile:
if line.find('INSERT_DATA'):
line = line.replace('INSERT_DATA', str(data))
if line.find('INSERT_OPTIONS'):
if options != None:
line = line.replace('INSERT_OPTIONS', options)
else:
line = line.replace('INSERT_OPTIONS', '')
outputFile.writelines(line)
folderIterator(path)
#
#################


##################
# Index Creation #
##################
#
# folderIterator
def folderIterator(path):
data = {}
for dirs in os.listdir(path):
htmlfiles = []
if dirs.endswith('index.html'):
continue
for files in os.listdir(path + os.sep + dirs):
if files.endswith('.html'):
htmlfiles.append(files)
data[dirs] = htmlfiles
updateIndex(path, data)
#
# Index update
def updateIndex(path, data):

targetpath = path + os.sep + 'index.html'
templatepath = os.path.join('templates','index.html')
shutil.copyfile(templatepath, targetpath)
for key in data.keys():
skiplines = False
inputfile = open(targetpath, 'r')
tempfile = open(path + os.sep + 'temp', 'w')
keyfound = False

for line in inputfile:
if line.find('<!--'+ key + '-->') != -1:
skiplines = True
keyfound = True
tempfile.writelines(line)
if line.find('<!--'+key+'-END-->') != -1:
skiplines = False
line = ""
if not skiplines:
tempfile.writelines(line)

if not keyfound:
os.remove(path + os.sep + 'temp')
inputfile = open(path + os.sep + 'index.html', 'r')
tempfile = open(path + os.sep + 'temp', 'w')
for line in inputfile:
if line.find('<!-- xxx -->') != -1:
line = '<!--'+ key + '-->' + "\n" + '<!--'+key+'-END-->' + "\n<!-- xxx -->\n"
tempfile.writelines(line)
tempfile = open(path + os.sep + 'temp', 'r')
inputfile = open(path + os.sep + 'index.html', 'w')
for line in tempfile:
if line.find('<!--'+ key + '-->') != -1:
line = createHtmlTag(key, data[key])
inputfile.writelines(line)
os.remove(path + os.sep + 'temp')
#
# HTML tag creation
def createHtmlTag(key, array):
htmlNote = '<!--'+ key + '-->' + "\n"
header = "<details>\n<summary>"+key+"</summary>\n<ul>\n"
fullCode = htmlNote + header
for item in array:
linkperitem = "<li><a href="+key+os.sep+item+" target=\'content_frame\'>"+item+"</a></li>\n"
fullCode = fullCode + linkperitem
endNode = "\n</ul>\n</details>\n"+"<!--"+key+"-END--> \n"
fullcode = fullCode + endNode
return fullcode
#
##################


1 change: 1 addition & 0 deletions config/test_folders.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
contributions/py3k
contributions/ruby
contributions/javaTree
contributions/cppMpl
12 changes: 12 additions & 0 deletions modules/commentSentimentPerLanguage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# commentSentimentPerLanguage

Min, max, median and mean sentiment of comments per language

# Description

This module calculates the minimum, maximum, median and mean Sentiment of comments per language. The results are saved as a sentimentsPerLanguage dump.
Additionally a sentimentsPerContribution dump is created containing the comment sentiment per file grouped by language and contribution.

# Requirements

This module requires simpleSentiment to be run first.
Loading