#!/usr/bin/env python
import math
import string
#Parameter: 'out' where out is a file obtained from [ pestr -n 6 <file> > out ]
def stringHash(file):
	stringLen = {iter: 0 for iter in range(0x10)}
	stringHash = {iter: 0 for iter in range(0x10)}
	featureVector = {iter: 0 for iter in range(0x100)}

	fIn = open(file, 'rb')
	cnt = 0
	for line in fIn:
		cnt= cnt+1
		lineLength = len(line)
		logLength = math.log(lineLength, 1.5)
		strHash1 = lineLength % 16
		stringHash[strHash1] = stringHash[strHash1] + 1
		if logLength < 8:
			ind = 0
		elif logLength > 200:
			ind = 15
		else:
			ind = math.trunc(logLength/14) + 1
		stringLen[ind] = stringLen[ind] + 1
	

	for i in range(0, 16, 1):
		for j in range(0, 16, 1):
			featureVector[i*16 + j] = stringLen[i]*1000 + stringHash[j]

	fIn.close()
	print "hi stringHash"
	return featureVector
