from collections import defaultdict import urllib.request vasak=defaultdict(int) parem=defaultdict(int) ryhmasonad=set() vasakud=defaultdict(int) paremad=defaultdict(int) puuduvad=defaultdict(int) kogupuuduvad=defaultdict(int) molemad=defaultdict(int) ryhmitatuid=defaultdict(int) sonukokku=0 for rida in open("Andmed/noun_hypernyms_estwn_2.3.2.txt", encoding="utf-8"): m=rida.strip().split("<") vasak[m[0]]+=1 parem[m[1]]+=1 koos=set(vasak.keys()).intersection(set(parem.keys())) m0=urllib.request.urlopen("https://minitorn.tlu.ee/~jaagup/oma/too/23/05/word2vec/vastused/jaotus1000_marksonad.txt").read().decode("utf-8").split("\n") for nr in range(1000): for sona in m0[nr*3+1].strip().split(): ryhmasonad.add(sona) kokku=0 olemas=0 sees=set() valjas=set() for sona in ryhmasonad: kokku+=1 if sona in vasak or sona in parem: olemas+=1 sees.add(sona) else: valjas.add(sona) print(kokku, olemas) f2=open("puuduvad.txt", "w", encoding="utf-8") print(valjas, file=f2) f2.close()