thisLang = 'en' if (thisLang != ''): #TRANSLATE TO ENGLISH en try: thisWords = Translator().translate(text=thisWords, dest='en').text #print("translating") except: print("failed to translate") print("AFTER") print(thisWords) allWords = allWords + thisWords #dump to country file.. for testing yo f.write(json.dumps(thisWords)) thisList = {} #words per country for x in thisWords.split(): #print(x) #clouds[(country['country']] x = removeSymbols(x) if x in thisList: thisList[x] = thisList[x] + 1 else: thisList[x] = 1 #print(thisList) clouds[country['country']] = thisList allList = {} #global word list for x in allWords.split(): x = removeSymbols(x) if x in allList:
}}, upsert=True) except: print(f"{countries[i]}: failed to translate") print(untranslated) #add translated string to string of all titles allWords = allWords + translated + ' ' #unRaked word list collectionBlob = db["countries_wordblob"] zz = collectionBlob.find_one({"country": countries[i]}) #print(type(zz)) splitWords = translated.split() if splitWords is None: print("alerttttt EMPLY WORD LIST") # print(splitWords) if zz is not None: print(countries[i] + " country exists") #print(zz) #print(zz['words']) if zz["words"] != None: print("WORDS TO ADD FROM DATABASE:") print(zz["words"]) print("NEW WORDS TO ADD:") print(splitWords) newWordGroup = zz["words"] + splitWords print('checking comparison for dups') if (zz['words'][-len(splitWords):] == splitWords):