mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-21 02:39:31 -06:00
stat; type of imperatives in lib/resource
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
-- Stability : (stable)
|
||||
-- Portability : (portable)
|
||||
--
|
||||
-- > CVS $Date: 2005/09/01 09:53:19 $
|
||||
-- > CVS $Author: peb $
|
||||
-- > CVS $Revision: 1.69 $
|
||||
-- > CVS $Date: 2005/09/04 11:45:38 $
|
||||
-- > CVS $Author: aarne $
|
||||
-- > CVS $Revision: 1.70 $
|
||||
--
|
||||
-- A database for customizable GF shell commands.
|
||||
--
|
||||
@@ -61,6 +61,7 @@ import GF.Speech.PrSLF (slfPrinter)
|
||||
|
||||
import GF.Data.Zipper
|
||||
|
||||
import GF.UseGrammar.Statistics
|
||||
import GF.UseGrammar.Morphology
|
||||
import GF.API.GrammarToHaskell
|
||||
-----import GrammarToCanon (showCanon, showCanonOpt)
|
||||
@@ -249,6 +250,7 @@ customGrammarPrinter =
|
||||
,(strCI "opts", prOpts . stateOptions)
|
||||
,(strCI "words", unwords . stateGrammarWords)
|
||||
,(strCI "printnames", C.prPrintnamesGrammar . stateGrammarST)
|
||||
,(strCI "stat", prStatistics . stateGrammarST)
|
||||
{- ----
|
||||
(strCI "gf", prt . st2grammar . stateGrammarST) -- DEFAULT
|
||||
,(strCI "canon", showCanon "Lang" . stateGrammarST)
|
||||
|
||||
44
src/GF/UseGrammar/Statistics.hs
Normal file
44
src/GF/UseGrammar/Statistics.hs
Normal file
@@ -0,0 +1,44 @@
|
||||
----------------------------------------------------------------------
|
||||
-- |
|
||||
-- Module : Statistics
|
||||
-- Maintainer : AR
|
||||
-- Stability : (stable)
|
||||
-- Portability : (portable)
|
||||
--
|
||||
-- > CVS $Date: 2005/09/04 11:45:38 $
|
||||
-- > CVS $Author: aarne $
|
||||
-- > CVS $Revision: 1.1 $
|
||||
--
|
||||
-- statistics on canonical grammar: amounts of generated code
|
||||
-- AR 4\/9\/2005.
|
||||
-- uses canonical grammar
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module GF.UseGrammar.Statistics (prStatistics) where
|
||||
|
||||
import GF.Infra.Modules
|
||||
import GF.Infra.Option
|
||||
import GF.Grammar.PrGrammar
|
||||
import GF.Canon.GFC
|
||||
import GF.Canon.MkGFC
|
||||
|
||||
import GF.Data.Operations
|
||||
|
||||
import Data.List (sortBy)
|
||||
|
||||
-- | the top level function
|
||||
prStatistics :: CanonGrammar -> String
|
||||
prStatistics can = unlines $ [
|
||||
show (length mods) ++ "\t\t modules",
|
||||
show chars ++ "\t\t gfc size",
|
||||
"",
|
||||
"Top 40 definitions"
|
||||
] ++
|
||||
[show d ++ "\t\t " ++ f | (d,f) <- tops]
|
||||
where
|
||||
tops = take 40 $ reverse $ sortBy (\ (i,_) (j,_) -> compare i j) defs
|
||||
defs = [(length (prt (info2def j)), name m j) | (m,j) <- infos]
|
||||
infos = [(m,j) | (m,ModMod mo) <- mods, j <- tree2list (jments mo)]
|
||||
name m (f,_) = prt m ++ "." ++ prt f
|
||||
mods = modules can
|
||||
chars = length $ prCanon can
|
||||
Reference in New Issue
Block a user