marksonad={} tekstiaastad={} m=open("jaotus1000_peateemaga.txt", encoding="utf-8").readlines() kogus=len(m)//4 for nr in range(kogus): ryhmanimi=m[nr*4+2].split()[0]+"-"+"-".join(m[nr*4+1].split()[:2]) rm=m[nr*4+1].strip().split() for marksona in rm: marksonad[marksona]=ryhmanimi for rida in open("tekstiaastad.txt", encoding="utf-8"): m=rida.strip().split() tekstiaastad[m[0]]=m[1] fnimeloend="Eri_Klas_files.txt" fkataloog="C:/jaagup/22/bfmkeel/tekstid_syntaks/" fnimed=[fnimi.strip() for fnimi in open(fnimeloend, encoding="utf-8").readlines()] seosed=[] for fnimi in fnimed: print(fnimi) fread=open(fkataloog+"s"+fnimi, encoding="utf-8").readlines() for rida in fread: lemma=rida.split(";")[3].replace("_", "").replace("=", "") if lemma in marksonad: marksona=marksonad[lemma].replace('"', "") seosed.append([fnimi.split(".")[0], marksona]) f2=open("seosed5.csv", "w", encoding="utf-8") print("Source,Target", file=f2) print("\n".join([",".join(rida) for rida in seosed]), file=f2) f2.close() f2=open("failid5.csv", "w") print("Id\tLabel\ttimeset", file=f2) for fnimi in fnimed: fnimi=fnimi.split(".")[0] aasta=tekstiaastad[fnimi] print(fnimi, fnimi, f"<[{aasta},{aasta}]>", sep="\t", file=f2) f2.close()