From 4f3b38843ed4a2626f3c75d6043542deb3daf74a Mon Sep 17 00:00:00 2001 From: leoalenc Date: Tue, 4 Jan 2022 16:11:26 -0300 Subject: [PATCH] adding function to compute frame lengths #39 --- etc/valence_script/ValenceExtractor.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/etc/valence_script/ValenceExtractor.py b/etc/valence_script/ValenceExtractor.py index d473652..29cd6f6 100644 --- a/etc/valence_script/ValenceExtractor.py +++ b/etc/valence_script/ValenceExtractor.py @@ -16,6 +16,21 @@ FRAMES=list(VALENCES.keys()) MAPPING=from_frames_to_types() +def compute_stats(frames=FRAMES): + frame_lens=[(frame,len(frame.split(","))) for frame in frames] + max_len=max(flen for f,flen in frame_lens) + dic={} + for n in range(1,max_len+1): + for f,flen in frame_lens: + if flen == n: + if dic.get(flen): + dic[n]+=1 + else: + dic[n]=1 + for k,v in dic.items(): + print(k,v) + + def parse_frame(frame): match=re.match(r"<(.+)>",frame) if match: