I am trying to count how many times each word appear in whole corpus.
But i am getting the error :
corpus_root = os.path.abspath('../nlp_urdu/out1_data')
mycorpus = nltk.corpus.reader.TaggedCorpusReader(corpus_root,'.*')
noun=[]
count_freq = defaultdict(int)
for infile in (mycorpus.fileids()):
print(infile)
for i in (mycorpus.tagged_sents()):
texts = [word for word, pos in i if (pos == 'NN' )]
noun.append(texts)
count_freq[noun]+= 1
print(count_freq)
error which i am getting is :
count_freq[noun]+= 1
TypeError
: unhashable type: 'list'