0

There are two text file tags and MobyDick , i have to check how many times a word extracted from the tag file is present in the mobydick.

I have just extracted the words from the text file and saved it in a list, can anyone help with the function to check the frequency of the extracted words of tag file present in mobyDick

below is the code i have written:

with open('tags.txt','r') as f:

   words = f.read().split()

 #print(words)

with open('MobyDick.txt',encoding='utf8') as g:

text = g.read().split()
  • 1
    you can try using `nltk` library which provides a direct function to achieve this `FreqDist`. – Arpit Goyal Oct 22 '17 at 12:59
  • Use list comprehension: sl = ["era","byte","ai","era","byt","ai","python","python"] {(s,sl.count(s)) for s in set(sl)} – skrubber Oct 22 '17 at 13:12
  • arpit but does freqdist can extract a word from a list and check the freq of the word in another list , if so can you tell me how??? – Pratik Swain Oct 22 '17 at 13:29

0 Answers0