I have python 2.7, this is my code and when I run it, I get this error: 'continue' not properly in loop.
I know that 'continue' should be inside the loop for, but I use it inside if
, then what i have to do?
from numpy import zeros
from scipy.linalg import svd
from math import log
from numpy import asarray, sum
#from nltk.corpus import stopwords
from sklearn.metrics.pairwise import cosine_similarity
#from nltk.stem import PorterStemmer
#from nltk.stem.isri import ISRIStemmer
import nltk
#from matplotlib import pyplot as plt
from snowballstemmer import stemmer
titles = [" ذهبت الاخت الى المدرسة","تقع المدرسة في الجبال",
"ذهب الام لزيارة ابنتها في المدرسة ","تحضر الام الكعكة" ]
ar_stemmer = stemmer("arabic")
stopwords = ['ثم','و','حتى','الى','على','في']
ignorechars = ''',:'!'''
class LSA(object):
def __init__(self, stopwords, ignorechars):
self.stopwords = stopwords
self.ignorechars = ignorechars
self.wdict = {}
self.dcount = 0
def parse(self, doc):
#tokens=nltk.word_tokenise(titles)
#words = doc.split();
#ar_stemmer = stemmer("arabic")
for word in titles.split(" "):
# w = w.lower()
#for w in titles.split(" "):
stem = ar_stemmer.stemWord(word)
#st = ISRIStemmer()
#for w in words :
#join = w.decode('Windows-1256')
# w= st.stem(w.decode('utf-8'))
if stem in self.stopwords:
continue
elif stem in self.wdict:
self.wdict[stem].append(self.dcount)
else:
self.wdict[stem] = [self.dcount]
self.dcount += 1