Hellow friends;
I need your help in solving my problem of ngram results. I imported all required liberary files first than processed zipped file and than processed querty to get ngram results but it does not show results. Plz help. The coding is as below:
with zipfile.ZipFile('D:\Sindhicorpus.zip') as z:
print (len(z.namelist()))
for filename in z.namelist():
if not os.path.isdir(filename):
# read the file
with z.open(filename, 'rU') as rf:
line = rf.readline().decode('utf8')
# print(line)
(Above coding works fine)
import nltk
from nltk.collocations import *
line = ""
for val in filename:
line += val
tokens = line.split()
bigram_measures = nltk.collocations.BigramAssocMeasures()
finder = BigramCollocationFinder.from_words(tokens)
finder.apply_freq_filter(3)
print(finder.nbest(bigram_measures.pmi, 100))
shows results only empty empty brackets like [ ]
Then I processed following code
from nltk import ngrams
n = 2
sixgrams = ngrams(filename.split(), n)
for grams in sixgrams:
print(grams)
But it is also not showing any result.
plz resolve my problem.
Mazhar Ali