我创建了一个urdu向量numpy数组,并将urdu文本保存在文件中。我创建了一个positiveFiles数组,我试图找出文件中每个单词的索引。当我很难引用文字时,它会起作用,但是当我在每一行中拆分单词时,它会不起作用
def findIndex(wordsArray,value):
for i in range(len(wordsList)):
if wordsList[i] == value:
return i
ids = np.zeros((numFiles, maxSeqLength), dtype='int32')
fileCounter = 0
for pf in positiveFiles:
with open(pf, "r",encoding="utf-8") as f:
indexCounter = 0
line=f.readline()
split = line.split()
print(split)
print(findIndex(wordsList,"پاکستان"))
它给出"پاکستان"
内的单词wordsList
的索引,
但是当我使用此命令
print(findIndex(wordsList,split))
它正在给NONE