From f866e78289247707793710d41a94b26a9eac2ec1 Mon Sep 17 00:00:00 2001 From: Alice BRENON <alice.brenon@ens-lyon.fr> Date: Wed, 20 Mar 2024 12:11:12 +0100 Subject: [PATCH] Add the function used to reduce the size of ENE events by grouping them byArticle (format required by ENEDensity) --- GEODE/ENE/Detector.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/GEODE/ENE/Detector.py b/GEODE/ENE/Detector.py index 5e31d67..02ac4df 100644 --- a/GEODE/ENE/Detector.py +++ b/GEODE/ENE/Detector.py @@ -23,3 +23,10 @@ def detector(model, corpus): for paragraph in paragraphs: eventsOfAnnotation(currentPosition, common, model(paragraph)) currentPosition += len(paragraph) + +def byArticle(measures): + measures['count'] = 1 + counts = measures.groupby(articleKey + ['event']).count().reset_index() + return counts.pivot(articleKey, + columns='event', + values='count').fillna(0).astype(int).reset_index() -- GitLab