Skip to content

Instantly share code, notes, and snippets.

View akoskadar's full-sized avatar

Ákos Kádár akoskadar

View GitHub Profile
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
import string
import csv
"""
fil = open('C:\\Python27\\README.txt')
new_file = open('C:\Python27\\freq_list.txt', 'w')
"""
fil = open("/Users/StefanCelMare/Desktop/PythonReadme.txt")
@akoskadar
akoskadar / Document Term Frequency
Created November 7, 2013 17:42
This piece of Pyhton code counts the number of times words occur in a text file, and writes the result in a separate text file.
import string
fil = open('C:\\Python27\\elo.txt' , "r")
new_file = open('C:\Python27\\freq_list.txt', 'w')
text = fil.read()
fil.close()
textClean = ''