Skip to content

Instantly share code, notes, and snippets.

import twitter
client=twitter.Api()
def view_status ():
username= raw_input('Enter the username:')
latest=client.GetUserTimeline(username)
print [s.text for s in latest]
def update_status ():
username= raw_input('Enter the username:')
@russelnickson
russelnickson / Hyper-Linked Tag Cloud
Created January 17, 2010 21:24
Hyper-Linked Tag Cloud
# PROGRAM TO GENERATE HYPER-LINKED TAG CLOUD #
# Run at command line with three parameters
# Source File
# Noise File
# No.of Tags to Generate
import string,sys,os,webbrowser
@russelnickson
russelnickson / Generate a Tag Cloud
Created January 17, 2010 17:41
Generate a Tag Cloud
import string,sys
f1=open(sys.argv[1])
f2=open(sys.argv[2])
try:
count=int(sys.argv[3])
except IndexError:
count=20
content= string.lower(f1.read())
@russelnickson
russelnickson / most used words...
Created January 16, 2010 20:30
most used words in a file..
import string,sys
f1=open(sys.argv[1])
f2=open(sys.argv[2])
content= string.lower(f1.read())
noisecontent= string.lower(f2.read())
workinglist =string.split(content)
cleanlist =[]
for item in workinglist:
@russelnickson
russelnickson / word frequency with noise removed
Created January 14, 2010 21:57
Count Word Frequency2 (Eliminate Noise Words)
import string,sys
f1=open(sys.argv[1])
f2=open(sys.argv[2])
content= string.lower(f1.read())
noisecontent= string.lower(f2.read())
workinglist =string.split(content)
cleanlist =[]
for item in workinglist:
@russelnickson
russelnickson / Count Word Frequency
Created January 14, 2010 21:43
Count Word Frequency
import string,sys
f=open(sys.argv[1])
content= string.lower(f.read())
workinglist =string.split(content)
cleanlist =[]
for item in workinglist:
temp=item.strip(string.punctuation)
cleanlist=cleanlist+[temp,]
@russelnickson
russelnickson / parse words... my creation... yea..
Created January 14, 2010 20:46
parse words... my creation... yea..
import sys
import shlex
import string
f=open(sys.argv[1])
content=f.read()
sen=string.split(content,'.')
print sen
words=[]
@russelnickson
russelnickson / count words
Created January 14, 2010 20:23
count words
import sys
import shlex
f=open(sys.argv[1])
content=f.read()
words=shlex.split(content)
print 'word count = '+ str(len(words))
@russelnickson
russelnickson / Find the Longest Sentence
Created January 14, 2010 10:28
Find the Longest Sentence
import sys
from string import split
f=open(sys.argv[1])
content=f.read()
#print content
sentence=split(content,'.')
largest=smallest=len(sentence[0])
total=0
import sys
from string import split
f=open(sys.argv[1])
content=f.read()
print content
print 'the no.of sentences in file = '+ str(len(split(content,'.'))-1)
# we sub 1 is because split creates a null element after the last '.'