Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions count.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import read
import collections

hn_stories=read.load_data()
headline_str=""
for i in hn_stories["headline"]:
headline_str=headline_str+str(i)
headline_str= str.lower(headline_str)
hn_stories=read.load_data() # data is read from inbuilt dataset
headline_str="" # empty string is set
for i in hn_stories["headline"]:
headline_str=headline_str+str(i) #string is appended
headline_str= str.lower(headline_str) # change to lowe case
data=headline_str.split(" ")
print(collections.Counter(data).most_common(100))
print(collections.Counter(data).most_common(100)) # return the result
4 changes: 2 additions & 2 deletions domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

hn_stories=read.load_data()
domains=hn_stories["url"]
#print(collections.Counter(domains).most_common(100))


domains2=domains.tolist()
nosubdomains=[]
Expand All @@ -16,6 +16,6 @@
else:
nosubdomains.append(i)
#print(collections.Counter(nosubdomains).most_common(100))
#for name, row in domains.items():
for name, row in domains.items():
print("{0}: {1}".format(name, row))