stat; type of imperatives in lib/resource

This commit is contained in:
aarne
2005-09-04 10:45:37 +00:00
parent e5490a113d
commit 9cb3b65b84
14 changed files with 100 additions and 38 deletions

View File

@@ -14,6 +14,12 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2
<p>
4/9 (AR) Added the option <tt>pg -printer=stat</tt> to show
statistics of gfc compilation result. To be extended with new information.
The most important stats now are the top-40 sized definitions.
<p>
1/7 <b>Release of GF 2.3</b>.
<p>

View File

@@ -146,7 +146,7 @@ fun
IntSlash : IP -> Slash -> QCl ; -- "whom does John see"
QuestAdv : IAdv -> Cl -> QCl ; -- "why do you walk"
PosImpVP, NegImpVP : VPI -> Imp ; -- "(don't) be a man"
PosImpVP, NegImpVP : VCl -> Imp ; -- "(don't) be a man"
----rename these ??
IndicPhrase : S -> Phr ; -- "I walk."

View File

@@ -1278,13 +1278,13 @@ oper
Imperative = SS1 Number ;
imperVerbPhrase : Bool -> VerbPhrase -> Imperative = \b,walk ->
imperVerbPhrase : Bool -> VerbClause -> Imperative = \b,walk ->
{s = \\n =>
let
a = toAgr n P2 human ;
dont = if_then_Str b [] "don't"
in
dont ++ walk.s ! VIInfinit ! a
dont ++ walk.s ! b ! Simul ! VIInfinit ! a
} ;
imperUtterance : Number -> Imperative -> Utterance = \n,I ->

View File

@@ -47,8 +47,8 @@ lincat
V = Verb1 ;
-- = {s : VForm => Str}
---- VP = {s,s2 : Bool => SForm => Agr => Str ; isAux : Bool} ;
VPI = {s : Bool => VIForm => Str ; sc : Case} ;
VPI = {s : VIForm => Number => Str ; sc : Case} ;
VCl = {s : Bool => Anteriority => VIForm => Number => Str ; sc : Case} ;
----- VP = Verb ** {s2 : VForm => Str ; c : ComplCase} ;
---- VG = {s,s2 : Bool => VForm => Str ; c : ComplCase} ;
V2 = TransVerb ;
@@ -67,6 +67,7 @@ lincat
TP = {s : Str ; b : Bool ; t : Tense ; a : Anteriority} ; --- the Str field is dummy
Tense = {s : Str ; t : Tense} ;
Pol = {s : Str ; p : Bool} ;
Ant = {s : Str ; a : Anteriority} ;
PP = {s : Str} ;

View File

@@ -39,7 +39,7 @@ lin
DetNP = detNounPhrase ;
NDetNP = numDetNounPhrase ;
---- NDetNum = justNumDetNounPhrase ;
NDetNum d n = numDetNounPhrase d n emptyCommNounPhrase ;
MassNP = partNounPhrase singular ;
AppN2 = appFunComm ;
@@ -81,7 +81,7 @@ lin
---- ComplA2S = predAdjSent2 ;
---- AdjPart = adjPastPart ;
AdjPart verb = {s = \\a => verb.s ! PastPartPass a} ;
---- UseV2V x = verb2aux x ** {isAux = False} ;
@@ -92,7 +92,7 @@ lin
UseCl tp cl = {s = tp.s ++ cl.s ! tp.b ! VFinite SDecl tp.t tp.a} ;
UseQCl tp cl = {s = tp.s ++ cl.s ! tp.b ! VFinite SQuest tp.t tp.a} ;
---- UseRCl tp cl = {s = \\a => tp.s ++ cl.s ! tp.b ! VFinite tp.t tp.a ! a} ;
UseRCl tp cl = {s = \\n => tp.s ++ cl.s ! tp.b ! VFinite SDecl tp.t tp.a ! n} ;
PosTP t a = {s = t.s ++ a.s ; b = True ; t = t.t ; a = a.a} ;
NegTP t a = {s = t.s ++ a.s ; b = False ; t = t.t ; a = a.a} ;
@@ -101,6 +101,9 @@ lin
TPast = {s = [] ; t = Past} ;
TFuture = {s = [] ; t = Future} ;
TConditional = {s = [] ; t = Conditional} ;
PPos = {s = [] ; p = True} ;
PNeg = {s = [] ; p = False} ;
ASimul = {s = [] ; a = Simul} ;
AAnter = {s = [] ; a = Anter} ;

View File

@@ -42,6 +42,8 @@ oper
CommNounPhrase = {s : Bool => Number => Case => Str ; g : Gender} ;
emptyCommNounPhrase : CommNounPhrase = {s = \\_,_,_ => [] ; g = NonHuman} ;
noun2CommNounPhrase : CommNoun -> CommNounPhrase = \man ->
useCN man ** {g = man.g} ;
@@ -323,7 +325,6 @@ oper
adj2adjPhrase : Adjective -> AdjPhrase = \uusi ->
{s = \\_ => uusi.s} ;
--3 Comparison adjectives
--
-- Each of the comparison forms has a characteristic use:
@@ -503,8 +504,8 @@ oper
SType = SDecl | SQuest ;
VIForm =
VIInfinit Anteriority
| VIImperat Number
VIInfinit
| VIImperat
| VIInf3Iness
| VIInf3Elat
| VIInf3Illat
@@ -517,7 +518,8 @@ oper
oper
Clause : Type = {s : Bool => SForm => Str} ;
VerbPhraseInf : Type = {s : Bool => VIForm => Str ; sc : Case} ;
VerbPhraseInf : Type = {s : VIForm => Number => Str ; sc : Case} ;
VerbClauseInf : Type = {s : Bool => Anteriority => VIForm => Number => Str ; sc : Case} ;
Sats : Type = {
subj : Str ;
@@ -527,7 +529,7 @@ oper
} ;
obj : Bool => SVIForm => Str ;
comp : Str ;
vpi : VerbPhraseInf
vpi : Bool => VerbPhraseInf
} ;
sats2clause : Sats -> Clause = \sats ->
@@ -546,7 +548,8 @@ oper
}
} ;
sats2verbPhrase : {s : Str ; a : Anteriority} -> Sats -> VerbPhraseInf = \a,sats ->
{-
sats2verbClause : {s : Str ; a : Anteriority} -> Sats -> VerbPhraseInf = \a,sats ->
{s = \\b,vi =>
let
inf = sats.vpi.s ! b ! vi ;
@@ -556,7 +559,7 @@ oper
a.s ++ inf ++ obj ++ comp ;
sc = sats.vpi.sc
} ;
-}
questPart : Str -> Str = \s -> glueParticle s "ko" ; --- "kö"
mkSats : NounPhrase -> Verb1 -> Sats = \subj,verb ->
@@ -572,12 +575,12 @@ oper
pred = \\b,sf => vi b (SCl sf) ;
obj = \\_,_ => [] ;
comp = [] ;
vpi = {
s = \\b,f => let vp = vi b (SVI f) in vp.fin ++ vp.inf ;
vpi = \\b => {
s = \\f,n => let vp = vi b (SVI f) in vp.fin ++ vp.inf ;
sc = sc
}
} ;
{- ----
progressiveSats : NounPhrase -> VerbPhraseInf -> Sats = \subj,vp ->
let
np = case vp.sc of {
@@ -590,12 +593,12 @@ oper
pred = \\b,sf => vi b (SCl sf) ;
obj = \\_,_ => [] ;
comp = vp.s ! True ! VIInf3Iness ;
vpi = {
s = \\b,f => let vv = vi b (SVI f) in vv.fin ++ vv.inf ;
vpi = \\b => {
s = \\f => let vv = vi b (SVI f) in vv.fin ++ vv.inf ;
sc = Nom
}
} ;
-}
mkSatsObject : NounPhrase -> TransVerb -> NounPhrase -> Sats = \subj,verb,obj ->
insertObject (mkSats subj verb) verb.c verb.s3 verb.p obj ;
@@ -691,7 +694,7 @@ oper
SCl (VFinite _ Conditional a) => ei a (Cond n p) (Cond Sg P3) ;
SCl (VFinite _ Present a) => ei a (Pres n p) (Imper Sg) ;
SCl (VFinite _ Future a) => fut a (Pres n p) (Imper Sg) ;
SVI (VIImperat n ) => älä n ;
SVI (VIImperat ) => älä n ;
SVI i => inf i Simul ---- Anter
} ;
@@ -1133,8 +1136,8 @@ oper
Imperative = SS1 Number ;
imperVerbPhrase : Bool -> VerbPhraseInf -> Imperative = \b,ui ->
{s = \\n => ui.s ! b ! VIImperat n} ;
imperVerbPhrase : Bool -> VerbClauseInf -> Imperative = \b,ui ->
{s = ui.s ! b ! Simul ! VIImperat} ;
imperUtterance : Number -> Imperative -> Utterance = \n,I ->
ss (I.s ! n ++ exclPunct) ;

View File

@@ -927,8 +927,8 @@ oper
Imperative = {s : Gender => Number => Str} ;
imperVerbPhrase : Bool -> VerbPhrase -> Imperative = \b,dormir ->
{s = \\g,n => dormir.s ! VIImperat b n ! g ! n ! P2
imperVerbPhrase : Bool -> VerbClause -> Imperative = \b,dormir ->
{s = \\g,n => dormir.s ! b ! Simul ! VIImperat b n ! g ! n ! P2
} ;
imperUtterance : Number -> Imperative -> Utterance = \n,I ->

View File

@@ -1427,9 +1427,9 @@ oper
Imperative = {s : Number => Str} ;
imperVerbPhrase : Bool -> VerbPhrase -> Imperative = \b,titta ->
imperVerbPhrase : Bool -> VerbClause -> Imperative = \b,titta ->
{s = \\n =>
titta.s ! VIImperat b ! utrum ! n ! P2
titta.s ! b ! Simul ! VIImperat b ! utrum ! n ! P2
} ;
imperUtterance : Number -> Imperative -> Utterance = \n,I ->

View File

@@ -5,16 +5,16 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/05/30 21:08:14 $
-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.15 $
-- > CVS $Revision: 1.16 $
--
-- (Description of the module)
-----------------------------------------------------------------------------
module GF.Canon.MkGFC (prCanonModInfo, prCanon, prCanonMGr,
canon2grammar, grammar2canon, -- buildCanonGrammar,
info2mod,
info2mod,info2def,
trExp, rtExp, rtQIdent) where
import GF.Canon.GFC

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/05/30 18:39:44 $
-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.15 $
-- > CVS $Revision: 1.16 $
--
-- AR 7\/12\/1999 - 1\/4\/2000 - 10\/5\/2003
--
@@ -107,6 +107,7 @@ instance Print A.Case where prt = C.printTree
instance Print A.CType where prt = C.printTree
instance Print A.Label where prt = C.printTree
instance Print A.Module where prt = C.printTree
instance Print A.Def where prt = C.printTree
instance Print A.Canon where prt = C.printTree
instance Print A.Sort where prt = C.printTree

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/07/01 19:54:09 $
-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.9 $
-- > CVS $Revision: 1.10 $
--
-- Help on shell commands. Generated from HelpFile by 'make help'.
-- PLEASE DON'T EDIT THIS FILE.
@@ -523,6 +523,7 @@ txtHelpFile =
"\n -printer=fullform full-form lexicon, short format" ++
"\n *-printer=xml XML: DTD for the pg command, object for st" ++
"\n -printer=old old GF: file readable by GF 1.2" ++
"\n -printer=stat show some statistics of generated GFC" ++
"\n" ++
"\n-startcat, like -cat, but used in grammars (to avoid clash with keyword cat)" ++
"\n" ++

View File

@@ -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)

View 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

View File

@@ -494,6 +494,7 @@ q, quit: q
-printer=fullform full-form lexicon, short format
*-printer=xml XML: DTD for the pg command, object for st
-printer=old old GF: file readable by GF 1.2
-printer=stat show some statistics of generated GFC
-startcat, like -cat, but used in grammars (to avoid clash with keyword cat)