Skip to content

Commit

Permalink
Add code comment
Browse files Browse the repository at this point in the history
  • Loading branch information
caramelWaffle committed May 19, 2019
1 parent 04455b5 commit 4548b37
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions TextSummarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# nltk.download('stopwords')

# Read comment from CSV file
path = 'C:\\Users\\Tanachart\\Desktop\\dataset\\'
filename = "1_Population.csv"
path = 'C:\\Users\\Tanachart\\Desktop\\dataset_with_like\\'
filename = "12_Cyprus.csv"
dataset = pd.read_csv(path + filename, header=None)
commentList = dataset[0]
likeList = dataset[1]
Expand Down Expand Up @@ -56,9 +56,10 @@
else:
sentence_scores[sent] += word_frequencies[word]

print("Default score")
print(sentence_scores)


print(sentence_scores.values())
print("\nlike score")
for i in range(len(commentList)):
for j in range(len(list(sentence_scores.keys()))):
if list(sentence_scores.keys())[j] in commentList[i]:
Expand All @@ -68,18 +69,16 @@
newValue = list(sentence_scores.values())[j] + likeWeight
sentence_scores[list(sentence_scores.keys())[j]] = newValue

print("\n")
print("\nSum with like")
print(sentence_scores)


# Calculate number of line to be display after summarization
numberOfLine = round(len(nltk.word_tokenize(formatted_article_text)) / 100)
if numberOfLine > 3:
numberOfLine = 3
summary_sentences = heapq.nlargest(4, sentence_scores, key=sentence_scores.get)



print("\n")
print(filename)
print("========== ORIGINAL SENTENCES ==========")
print(sentence_list)
Expand Down

0 comments on commit 4548b37

Please sign in to comment.