From 7e90dfce6e56fe27e769a90b44f5e7d9c6475813 Mon Sep 17 00:00:00 2001 From: Alice BRENON <alice.brenon@ens-lyon.fr> Date: Thu, 8 Feb 2024 14:52:58 +0100 Subject: [PATCH] Adapt compute-profile to latest changes in Conllu.Tree* --- scripts/textometry/compute-profile.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/textometry/compute-profile.hs b/scripts/textometry/compute-profile.hs index 4ac3480..04aa4e2 100755 --- a/scripts/textometry/compute-profile.hs +++ b/scripts/textometry/compute-profile.hs @@ -2,11 +2,12 @@ {-# LANGUAGE DeriveGeneric, ExplicitNamespaces #-} import Conllu.Tree - ( Feat(..), IndexedDocument(..), IndexedSentence(..), IndexedWord(..) + ( Feat(..), IndexedDocument(..), IndexedSentence(..), IndexedToken(..) , positions ) import Control.Applicative ((<**>)) import Control.Monad.IO.Class (liftIO) import Control.Monad.Reader (ReaderT, asks, runReaderT) +import Conllu.Tree.Count (Count(..)) import Data.Csv (DefaultOrdered(..), ToNamedRecord(..)) import Data.ByteString as ByteString (readFile) import Data.List (sort) @@ -63,11 +64,13 @@ profile articleRecord = do analyse = pure . fmap (glue articleRecord) . findOccurrences findOccurrences :: IndexedDocument -> [Occurrence] -findOccurrences (IndexedDocument {_total, _sentences}) = +findOccurrences (IndexedDocument {_total = Count {tokens}, _sentences}) = groupOccurrences [] (_sentences >>= imperativeVerb) where + occurrence (position, size) = + Occurrence {event = "Imperative", position, size, totalSize = tokens} groupOccurrences :: [(Int, Int)] -> [Int] -> [Occurrence] - groupOccurrences stack [] = uncurry (Occurrence _total) <$> reverse stack + groupOccurrences stack [] = occurrence <$> reverse stack groupOccurrences [] (p:ps) = groupOccurrences [(p, 1)] ps groupOccurrences (tmp@(first, tmpLength):stack) (p:ps) | p == first + tmpLength = -- GitLab