#!/usr/bin/python
## coding: utf-8

import sys, os, codecs, csv, MySQLdb
   
def getIndex(a):
    return (a * 2) + 3

# -------------------------------------------------------------------------------------- #
# 
# -------------------------------------------------------------------------------------- #

inF = codecs.open(sys.argv[1], "r", encoding="utf-8")
inLines = inF.read().split("\n")
inF.close()

inData = []
totalsForNovels = {}

for line in inLines:
    if len(line.split(",")) > 1:
        
        c = line.split(",")
        a = c[1].replace("Text_Files/germanNovelsAndEnlightment_1000/", "").replace(".txt", "")
        
        aParts = a.split("_")
        
        fixedName = ""
        for b in range(0, len(aParts) - 1):
            if fixedName > "":
                fixedName = fixedName + "_"
            fixedName = fixedName + aParts[b]
           
        try:
            noop = totalsForNovels[fixedName]
        except KeyError:

            countArray = []
            for a in range(0, 100):
                countArray.append(0)
            
            totalsForNovels[fixedName] = countArray
        
        for a in range(0, 100):
            offsetA = (a * 2) + 1 + 2
            
            topicValue = float(c[offsetA])
            
            if topicValue > 0.20:
                totalsForNovels[fixedName][a] = totalsForNovels[fixedName][a] + 1
            
outString = ","
for a in range(0, 100):
    outString = outString + str(a) + ","
print outString

keys = sorted(totalsForNovels.keys())
for k in keys:
    outString = k + ","
    for a in range(0, 100):
        outString = outString + str(totalsForNovels[k][a]) + ","
    print outString

    
