def rank_images(images, blockedWords): print(blockedWords) badfile = open("bad_images.txt", "a") goodfile = open("good_images.txt", "a") imageObjects = [] for image in images: tempObject = imageObject(image) imageObjects.append(tempObject) i = 0 import json words = {good: [], bad: []} for iO in imageObjects: print(i, end="") i += 1 words = get_words_url(iO.get_path()) for word in words: # print(word) if word in blockedWords: # print("IMAGE CONTAINS EVIL WORD :O", word) # print(iO.get_path, file=badfile) words["bad"].append(iO.get_path) break # Subtracts the image weight from the score # image.score -= words[word] else: # print(iO.get_path, file=goodfile) words["good"].append(iO.get_path) rankedImages = sorted(imageObject, key=imageObject.get) print(rankedImages)
def rank_images(images, blockedWords): print(blockedWords) badfile=open('bad_images.txt', 'a') goodfile=open('good_images.txt', 'a') imageObjects = [] for image in images: tempObject = imageObject(image) imageObjects.append(tempObject) i=0 for iO in imageObjects: print(i, end='') i+=1 words = get_words_url(iO.get_path()) for word in words: #print(word) if word in blockedWords: #print("IMAGE CONTAINS EVIL WORD :O", word) print(iO.get_path, file=badfile) break # Subtracts the image weight from the score # image.score -= words[word] else: print(iO.get_path, file=goodfile) rankedImages = sorted(imageObject, key=imageObject.get) print (rankedImages)