Skip to content

Add WhatsApp keyword Occurrence per user finder #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
14 changes: 14 additions & 0 deletions scripts/WhatsApp Word Occurrence per user find/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This is a python script which will find how many times a word is used per person in an WhatsApp group conversation.

To use this script you have to generate a text(.txt) file from whatapp application which can be done via Group chat>more>export_chat>without_media

Copy that file to your PC,copy the file's(.txt) path for later use

install matplotlib by excuting pip install matplotlib

Excecute the script

Paste the path to your text file,press enter

Find the Keyword you want to find.
A plot showing the bar graph of the use cases of the entered keyword would be displayed if everything goes right!
64 changes: 64 additions & 0 deletions scripts/WhatsApp Word Occurrence per user find/Whasapp analyze.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import matplotlib.pyplot as plt

#This script can be used to find how many times a particular word is used and by which user.
#This can be particularly userful for a group conversation,just for fun😁

filename = input('Enter the file Name : ')

#Ensure the file is in same path to the script
#or you can enter path to the file

word_to_find = input('which word you want to find? :')


chat = open(str(filename), 'r', encoding='utf_8')
data = chat.readlines()
Names_duplicate = []

for n in range(1, 2000):

start = data[n].find('-')
end = -1
occurrence = 2
for i in range(0, occurrence):
end = data[n].find(':', end + 1)
name = data[n][start+1:end]
Names_duplicate += [name]


Names = []
for i in Names_duplicate:
if i not in Names and i.startswith(' '):
Names.append(i)

count = []
for i in Names:
rep = 0
for j in data:
if str(j.find(str(word_to_find))) != '-1' and str(j.find(i)) != '-1':
rep = rep + 1
count.append(i)
count.append(rep)
textfile = open("a_file.txt", "w")
for element in count:
textfile. write(str(element)+'\n')

textfile.close()

plot_Name = []
plot_instances = []
plot_data = {}
for i in range(0, len(count)-1):
if i % 2 == 0:
plot_Name.append(count[i])
if i % 2 != 0:
plot_instances.append(count[i])

for plot in range(0, 16):
plot_data[plot_Name[plot]] = plot_instances[plot]
x = list(plot_data.keys())
y = list(plot_data.values())
fig = plt.figure(figsize=(400, 5))

plt.bar(x, y)
plt.show()