You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if:ets.info(:corpus_index)!=:undefineddo:ets.delete(:corpus_index)end# contents should be {annotation_id, eaf_filename, [start_ms, end_ms]}:ets.new(:corpus_index,[:bag,:public,:named_table])
importMeeseeks.CSSdefmoduleCorpusStatsdo@eafs_path"/Users/rsmi0037/Data/ a-Latest eafs/"@eafs@eafs_path|>File.ls!()|>Enum.filter(&(String.ends_with?(&1,"eaf")))@tiers_of_interest["LH-IDgloss","RH-IDgloss"]@annotation_selector@tiers_of_interest|>Enum.map(fntier_name->"[TIER_ID=\"#{tier_name}\"] ALIGNABLE_ANNOTATION"end)|>Enum.join(",")|>css()defannotation_selector,do: @annotation_selectordefeafs,do: @eafsdefget_example_for_sign(%Dictionary.Sign{}=sign)do:ets.lookup(:corpus_index,sign.id_gloss_annotation)enddefget_timecode(timeslots,timecode_id)dotimecode=Enum.find(timeslots,&(&1.id==timecode_id)).valueString.to_integer(timecode)enddefprocess_eaf(eaf)docontents=File.read!(@eafs_path<>eaf)|>Meeseeks.parse(:xml)timeslots=fortimeslot<-Meeseeks.all(contents,css("TIME_SLOT"))do%{id: Meeseeks.attr(timeslot,"TIME_SLOT_ID"),value: Meeseeks.attr(timeslot,"TIME_VALUE")}endforannotation<-Meeseeks.all(contents,@annotation_selector)do# title = Meeseeks.one(annotation, css(".title a"))text=Meeseeks.text(annotation)start_time=get_timecode(timeslots,Meeseeks.attr(annotation,"TIME_SLOT_REF1"))end_time=get_timecode(timeslots,Meeseeks.attr(annotation,"TIME_SLOT_REF2"))# only add annotation ids, ignore free text translations etc:ets.insert(:corpus_index,{text,eaf,[start_time,end_time]})end|>Enum.count()# TODO: handle failures and return {:ok, num_of_hits}enddefprocess_eaf_without_saving(eaf)docontents=File.read!(@eafs_path<>eaf)|>Meeseeks.parse(:xml)timeslots=fortimeslot<-Meeseeks.all(contents,css("TIME_SLOT"))do%{id: Meeseeks.attr(timeslot,"TIME_SLOT_ID"),value: Meeseeks.attr(timeslot,"TIME_VALUE")}endforannotation<-Meeseeks.all(contents,@annotation_selector)do# title = Meeseeks.one(annotation, css(".title a"))%{text: Meeseeks.text(annotation),start_time: get_timecode(timeslots,Meeseeks.attr(annotation,"TIME_SLOT_REF1")),end_time: get_timecode(timeslots,Meeseeks.attr(annotation,"TIME_SLOT_REF2")),}endenddefasync_process_eaf(eaf)docaller=self()spawn(fn->send(caller,{:result,process_eaf(eaf)})end)enddefasync_process_eafsdoforeaf<-@eafsdoasync_process_eaf(eaf)endenddefprocess_eafsdoCorpusStats.eafs()|>Task.async_stream(fni->CorpusStats.process_eaf(i)end)|>Stream.run()endend
if:ets.info(:corpus_index)!=:undefineddo:ets.delete(:corpus_index)end# contents should be {annotation_id, eaf_filename, [start_ms, end_ms]}:ets.new(:corpus_index,[:bag,:public,:named_table])CorpusStats.eafs()|>Stream.map(fni->CorpusStats.process_eaf(i)end)|>Enum.to_list()