Python 在循环中不正确地继续

Python 在循环中不正确地继续,python,arabic,lsa,Python,Arabic,Lsa,我有Python2.7,这是我的代码,当我运行它时,我得到了这个错误:“continue”在循环中不正确 我知道“continue”应该在for的循环中,但是我在中使用它,如果,那么我必须做什么 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

我有Python2.7,这是我的代码,当我运行它时,我得到了这个错误:“continue”在循环中不正确

我知道“continue”应该在for的循环中,但是我在
中使用它,如果
,那么我必须做什么

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

在该上下文中完全没有必要使用
continue
,只需使用
pass

此错误是由
continue
for
while
循环之外引起的。也就是说:
continue
只允许在
for
while
循环中使用。

缩进严重混乱。一致地缩进代码以解决错误。如上所述,if语句实际上不在for循环中,请再缩进一个语句作为它的一部分。如前所述,
parse
函数只处理
stem
的最后一个值。这是故意的吗?如果没有,则将
If
语句缩进到与
stem=ar_stemmer.stemWord(word)
相同的级别。