-2

私はpython 2.7を持っています。これは私のコードで、実行すると、次のエラーが表示されます:「続行」がループで適切に行われません。

'continue' は for ループ内にある必要があることはわかっていますが、 内ifで使用しています。

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
4

2 に答える 2