Skip to content

Instantly share code, notes, and snippets.

View vineetrok's full-sized avatar

Vineet Chopdekar vineetrok

View GitHub Profile
@vineetrok
vineetrok / AffineTransformGUI.java
Created October 11, 2012 13:14
GUI program which performs Shear , Scale, Translate and Rotate affineTransforms on an image
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package assignment11;
import images.*;
import assignment11.ImagePreviewPanel;
import java.awt.Graphics;
import java.awt.Window;
@vineetrok
vineetrok / soundex
Created November 25, 2011 00:43
soundex
soundex=[0,1,2,3,0,1,2,0,0,2,2,4,5,5,0,1,2,6,2,3,0,1,0,2,0,2]
print "Enter the word to be hashed"
word=raw_input()
word=word.upper()
coded=word[0]
for c in word[1:len(word)]:
@vineetrok
vineetrok / boyerMoore
Created November 25, 2011 00:42
boyer moore
print "Enter the Line"
line=raw_input()
print "Now enter the string to be seached"
search=raw_input()
old_len=len(search)
found=False
try:
while(len(search)<=len(line)):
@vineetrok
vineetrok / bruteForce.py
Created November 25, 2011 00:40
brute force
import re
import os
String = "ABRACADABRA"
pat = "DA"
pat1 = pat
if len(String) < len(pat):
print "Enter Correct Pattern"
for i in range(0,(len(String)-len(pat))+1):
@vineetrok
vineetrok / tf_idf.py
Created November 24, 2011 18:13
Python program to determine Term-Frequencey and Inverse Document Frequency
import glob
import math
line=''
s=set()
flist=glob.glob(r'E:\PROGRAMMING\PYTHON\programs\corpus2\*.txt') #get all the files from the d`#open each file >> tokenize the content >> and store it in a set
for fname in flist:
tfile=open(fname,"r")
line=tfile.read() # read the content of file and store in "line"
tfile.close() # close the file
s=s.union(set(line.split(' '))) # union of common words
@vineetrok
vineetrok / hCluster.py
Created November 24, 2011 18:10
Python program to calculate clusters using Hierarchical Clustering method
import math
def distance(a,b):
x=float(a[0])-float(b[0])
x=x*x
y=float(a[1])-float(b[1])
y=y*y
dist=round(math.sqrt(x+y),2)
return dist
@vineetrok
vineetrok / kMeans.py
Created November 24, 2011 18:08
Python Program to calculat clusters using K-Means
import math
from operator import add
def inp():
pts=raw_input('Enter Number of Points.: ')
i=0
global points
points=[]
b=[]
while(i<int(pts)):
@vineetrok
vineetrok / trieDS.py
Created November 24, 2011 18:06
Illustration of Trie Data Structure in Python
class Node:
def __init__(self):
self.next = {}
self.word_marker = False
def add(self, string):
if len(string) == 0:
self.word_marker = True