import stanza import json kataloog="/mnt/c/jaagup/22/12/bfm/vastused_failiti_pikalt/" fnimed=open("vastus2.txt").readlines() fnimed=["j"+fnimi.strip() for fnimi in fnimed] koht=int(open("koht_stanza.txt").read()) nlp=stanza.Pipeline(lang="et") while koht=0: if lause[nr]["ner"]!="O": if lause[nr]["ner"]=="B-PER": vs.append(lause[nr]["word"]+sisu) sisu="" if lause[nr]["ner"]=="I-PER": sisu+=" "+lause[nr]["word"] nr-=1 for isik in vs: v=nlp(t) for lemma in [sona.lemma for lause in v.sentences for sona in lause.words if sona.xpos=="V"]: vsf.append(isik+","+lemma) if vsf: print(vsf) f2=open("/mnt/c/jaagup/22/12/bfm/isikud_tegevused_failiti/"+fnimed[koht], "w", encoding="utf-8") print("\n".join(vsf), file=f2) f2.close() koht+=1 print(koht, len(vsf)) print(koht, file=open("koht_stanza.txt", "w"))