marksonad={} tekstiaastad={} for rida in open("marksonad.csv", encoding="utf-8"): m=rida.strip().split(",") marksonad[m[0]]=m[1] 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("seosed4.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("failid4.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()