Python Forum
Counting number of words and organize for the bigger frequencies to the small ones.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Counting number of words and organize for the bigger frequencies to the small ones.
#1
Hi, everybody
I am doing a systematic literature review and I copied all the references used in my sample. I would like to identify the most common words in order to identify the authors most citted. I did this so far:
import sys


print(sys.argv[1])

f = open(sys.argv[1])
my_file_contents = f.read()

#print(f.read())

def word_count(str):
    counts = dict()
    words = str.split()

    for word in words:
        if word in counts:
            counts[word] += 1
        else:
            counts[word] = 1

    return counts

print(word_count(my_file_contents))
I was able to identify every word's number, but I do not know how to present from the terms with the most frequent to the fewer ones. Can somebody help me?
nilamo write Feb-05-2021, 08:30 PM:
Please use python tags in the future
Reply


Messages In This Thread
Counting number of words and organize for the bigger frequencies to the small ones. - by valeriorsneto - Feb-05-2021, 03:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I organize my simple ftp modules? blobdx7 3 509 Jan-05-2024, 01:23 PM
Last Post: Gribouillis
  How can I organize my code according to output that I want ilknurg 1 1,164 Mar-11-2022, 09:24 AM
Last Post: perfringo
  Making a plot with secondary y-axis bigger snkm 0 1,128 Feb-10-2022, 09:40 AM
Last Post: snkm
  Generate a string of words for multiple lists of words in txt files in order. AnicraftPlayz 2 2,792 Aug-11-2021, 03:45 PM
Last Post: jamesaarr
Star Split and organize my Pandas Dataframe brunolelli 4 2,688 Apr-18-2021, 03:00 AM
Last Post: brunolelli
  Counting Number of Element in a smart way quest 2 2,004 Nov-09-2020, 10:24 PM
Last Post: quest
  Find frequencies of an audio file at a specific time via librosa jberesford123__ 0 2,328 Oct-21-2020, 01:18 PM
Last Post: jberesford123__
  Counting the most relevant words in a text file caiomartins 2 2,477 Sep-21-2020, 08:39 AM
Last Post: caiomartins
  Best way(s) to organize and use "global" values? pjfarley3 6 2,628 Sep-03-2020, 12:27 AM
Last Post: pjfarley3
  get method not counting number of strings in dictionary LearningTocode 2 2,092 Jun-13-2020, 11:17 PM
Last Post: LearningTocode

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020