How do I improve the below code, which takes input from a file and does some word analysis. I? I find a lot of redundancy in it. I want to know a better way to implementof implementing it.
analysis = {}
wordanalysis = {}
found = True
for line in sys.stdin:
(n1,n2,n3,n4,n5,n6) = re.split("\t+",line.strip())
tweet = re.split("\s+", n6.strip().lower())
#adding tweet id to a dictionary
for i in range(0, len(tweet)):
print "{", n1, wordanalysis,"}"
wordanalysis["word"] = tweet[i]
wordanalysis["charcount"]= len(tweet[i])
if len(tweet[i]) > 7:
wordanalysis["longword"] = found
else:
wordanalysis["longword"] = not(found)
#if 1st char is UpperCase
if tweet[i].istitle():
wordanalysis["title"] = found
else:
wordanalysis["title"] = not(found)
if tweet[i].isupper():
wordanalysis["uppercase"] = found
else:
wordanalysis["uppercase"] = not(found)