From 04ae4c37cbb21587fea4e4de0cfa529e31f99fb5 Mon Sep 17 00:00:00 2001 From: aarne Date: Tue, 31 May 2005 11:47:51 +0000 Subject: [PATCH] cf for restricted import; new API funs --- lib/resource/abstract/Clause.gf | 93 +++++++++++++++++++------------ lib/resource/abstract/Rules.gf | 8 +++ lib/resource/english/ClauseEng.gf | 26 +++++++-- lib/resource/english/LangEng.gf | 1 + lib/resource/english/RulesEng.gf | 3 +- src/GF/CF/CanonToCF.hs | 19 ++++--- src/GF/Embed/EmbedParsing.hs | 2 +- src/GF/UseGrammar/Parsing.hs | 8 +-- 8 files changed, 106 insertions(+), 54 deletions(-) diff --git a/lib/resource/abstract/Clause.gf b/lib/resource/abstract/Clause.gf index 03892943d..b4990a07f 100644 --- a/lib/resource/abstract/Clause.gf +++ b/lib/resource/abstract/Clause.gf @@ -11,52 +11,71 @@ abstract Clause = Categories ** { fun - SPredV : NP -> V -> Cl ; -- "John walks" - SPredPassV : NP -> V -> Cl ; -- "John is seen" - SPredV2 : NP -> V2 -> NP -> Cl ; -- "John sees Mary" - SPredV3 : NP -> V3 -> NP -> NP -> Cl ; -- "John tells Mary everything" - SPredReflV2 : NP -> V2 -> Cl ; -- "John loves himself" - SPredVS : NP -> VS -> S -> Cl ; -- "John says that Mary runs" - SPredVV : NP -> VV -> VPI -> Cl ; -- "John must walk" - SPredVQ : NP -> VQ -> QS -> Cl ; -- "John asks who will come" - SPredVA : NP -> VA -> AP -> Cl ; -- "John looks ill" - SPredV2A : NP -> V2A -> NP ->AP ->Cl ; -- "John paints the house red" - SPredSubjV2V : NP -> V2V -> NP ->VPI ->Cl ; -- "John promises Mary to leave" + SPredV : NP -> V -> Cl ; -- "John walks" + SPredPassV : NP -> V -> Cl ; -- "John is seen" + SPredV2 : NP -> V2 -> NP -> Cl ; -- "John sees Mary" + SPredV3 : NP -> V3 -> NP -> NP -> Cl ; -- "John tells Mary everything" + SPredReflV2 : NP -> V2 -> Cl ; -- "John loves himself" + SPredVS : NP -> VS -> S -> Cl ; -- "John says that Mary runs" + SPredVV : NP -> VV -> VPI -> Cl ; -- "John must walk" + SPredVQ : NP -> VQ -> QS -> Cl ; -- "John asks who will come" + SPredVA : NP -> VA -> AP -> Cl ; -- "John looks ill" + SPredV2A : NP -> V2A -> NP ->AP ->Cl ; -- "John paints the house red" + SPredSubjV2V : NP -> V2V -> NP ->VPI ->Cl ; -- "John promises Mary to leave" SPredObjV2V : NP -> V2V -> NP -> VPI -> Cl ; -- "John asks me to come" SPredV2S : NP -> V2S -> NP -> S -> Cl ; -- "John told me that it is good" SPredV2Q : NP -> V2Q -> NP -> QS -> Cl ; -- "John asked me if it is good" - SPredAP : NP -> AP -> Cl ; -- "John is old" - SPredCN : NP -> CN -> Cl ; -- "John is a man" - SPredNP : NP -> NP -> Cl ; -- "John is Bill" - SPredAdv : NP -> Adv -> Cl ; -- "John is in France" + SPredAP : NP -> AP -> Cl ; -- "John is old" + SPredCN : NP -> CN -> Cl ; -- "John is a man" + SPredNP : NP -> NP -> Cl ; -- "John is Bill" + SPredAdv : NP -> Adv -> Cl ; -- "John is in France" - SPredProgVP : NP -> VPI -> Cl ; -- "he is eating" + SPredProgVP : NP -> VPI -> Cl ; -- "he is eating" + QPredV : IP -> V -> QCl ; -- "who walks" + QPredPassV : IP -> V -> QCl ; -- "who is seen" + QPredV2 : IP -> V2 -> NP -> QCl ; -- "who sees Mary" + QPredV3 : IP -> V3 -> NP -> NP -> QCl ; -- "who gives Mary food" + QPredReflV2 : IP -> V2 -> QCl ; -- "who loves himself" + QPredVS : IP -> VS -> S -> QCl ; -- "who says that Mary runs" + QPredVV : IP -> VV -> VPI -> QCl ; -- "who must walk" + QPredVQ : IP -> VQ -> QS -> QCl ; -- "who asks who will come" + QPredVA : IP -> VA -> AP -> QCl ; -- "who looks ill" + QPredV2A : IP -> V2A -> NP ->AP ->QCl ; -- "who paints the house red" + QPredSubjV2V : IP -> V2V -> NP ->VPI ->QCl ; -- "who promises Mary to leave" + QPredObjV2V : IP -> V2V -> NP -> VPI -> QCl ; -- "who asks me to come" + QPredV2S : IP -> V2S -> NP -> S -> QCl ; -- "who told me that it is good" + QPredV2Q : IP -> V2Q -> NP -> QS -> QCl ; -- "who asked me if it is good" - QPredV : IP -> V -> QCl ; -- "who walks" - QPredPassV : IP -> V -> QCl ; -- "who is seen" - QPredV2 : IP -> V2 -> NP -> QCl ; -- "who sees Mary" ----- QPredV3 : IP -> V3 -> NP -> NP -> QCl ; -- "who gives Mary food" - QPredReflV2 : IP -> V2 -> QCl ; -- "who loves himself" - QPredVS : IP -> VS -> S -> QCl ; -- "who says that Mary runs" - QPredVV : IP -> VV -> VPI -> QCl ; -- "who must walk" - QPredVQ : IP -> VQ -> QS -> QCl ; -- "who asks who will come" - QPredVA : IP -> VA -> AP -> QCl ; -- "who looks ill" - QPredV2A : IP -> V2A -> NP ->AP ->QCl ; -- "who paints the house red" - QPredSubjV2V : IP -> V2V -> NP ->VPI ->QCl ; -- "who promises Mary to leave" - QPredObjV2V : IP -> V2V -> NP -> VPI -> QCl ; -- "who asks me to come" - QPredV2S : IP -> V2S -> NP -> S -> QCl ; -- "who told me that it is good" - QPredV2Q : IP -> V2Q -> NP -> QS -> QCl ; -- "who asked me if it is good" + QPredAP : IP -> AP -> QCl ; -- "who is old" + QPredCN : IP -> CN -> QCl ; -- "who is a man" + QPredNP : IP -> NP -> QCl ; -- "who is Bill" + QPredAdv : IP -> Adv -> QCl ; -- "who is in France" - QPredAP : IP -> AP -> QCl ; -- "who is old" - QPredCN : IP -> CN -> QCl ; -- "who is a man" - QPredNP : IP -> NP -> QCl ; -- "who is Bill" - QPredAdv : IP -> Adv -> QCl ; -- "who is in France" + QPredProgVP : IP -> VPI -> QCl ; -- "who is eating" - IPredV : Ant -> V -> VPI ; -- "walk" - IPredV2 : Ant -> V2 -> NP -> VPI ; -- "see Mary" - IPredAP : Ant -> AP -> VPI ; -- "be old" + IPredV : Ant -> V -> VPI ; -- "walk" + IPredPassV : Ant -> V -> VPI ; -- "be seen" + IPredV2 : Ant -> V2 -> NP -> VPI ; -- "see Mary" + IPredV3 : Ant -> V3 -> NP -> NP -> VPI ; -- "give Mary food" + IPredReflV2 : Ant -> V2 -> VPI ; -- "love himself" + IPredVS : Ant -> VS -> S -> VPI ; -- "say that Mary runs" + IPredVV : Ant -> VV -> VPI -> VPI ; -- "want to walk" + IPredVQ : Ant -> VQ -> QS -> VPI ; -- "ask who will come" + IPredVA : Ant -> VA -> AP -> VPI ; -- "look ill" + IPredV2A : Ant -> V2A -> NP ->AP ->VPI ; -- "paint the house red" + IPredSubjV2V : Ant -> V2V -> NP ->VPI ->VPI ; -- "promise Mary to leave" + IPredObjV2V : Ant -> V2V -> NP -> VPI ->VPI ; -- "ask me to come" + IPredV2S : Ant -> V2S -> NP -> S -> VPI ; -- "tell me that it is good" + IPredV2Q : Ant -> V2Q -> NP -> QS -> VPI ; -- "ask me if it is good" + + IPredAP : Ant -> AP -> VPI ; -- "be old" + IPredCN : Ant -> CN -> VPI ; -- "be a man" + IPredNP : Ant -> NP -> VPI ; -- "be Bill" + IPredAdv : Ant -> Adv -> VPI ; -- "be in France" + + IPredProgVP : Ant -> VPI -> VPI ; -- "be eating" {- diff --git a/lib/resource/abstract/Rules.gf b/lib/resource/abstract/Rules.gf index e5c757048..cd12423dc 100644 --- a/lib/resource/abstract/Rules.gf +++ b/lib/resource/abstract/Rules.gf @@ -111,9 +111,11 @@ fun PrepNP : Prep -> NP -> PP ; -- "in London", "after the war" AdvCN : CN -> PP -> CN ; -- "house in London" + AdvPN : PN -> PP -> NP ; -- "x to the power of k" AdvAP : AdA -> AP -> AP ; -- "very good" AdvAdv : AdA -> Adv -> Adv ; -- "very well" + --! --3 Sentences and relative clauses -- @@ -195,6 +197,12 @@ fun SubjImper : Subj -> S -> Imp -> Imp ; -- "if it is hot, use a glove!" SubjQS : Subj -> S -> QS -> QS ; -- "if you are new, who are you?" +-- This rule makes a subordinate clause into a sentence adverb, which +-- can be attached to e.g. noun phrases. It might even replace the +-- previous subjunction rules. + + AdvSubj : Subj -> S -> Adv ; -- "when he arrives" + --! --2 One-word utterances -- diff --git a/lib/resource/english/ClauseEng.gf b/lib/resource/english/ClauseEng.gf index 08080faa0..c6e794d18 100644 --- a/lib/resource/english/ClauseEng.gf +++ b/lib/resource/english/ClauseEng.gf @@ -33,15 +33,14 @@ concrete ClauseEng of Clause = CategoriesEng ** QPredPassV np v = predBeGroupQ np (passVerb v) ; QPredV2 np v x = intVerbClause np v (complTransVerb v x) ; QPredReflV2 np v = intVerbClause np v (reflTransVerb v) ; + QPredV3 np v x y = intVerbClause np v (complDitransVerb v x y) ; QPredVS np v x = intVerbClause np v (complSentVerb v x) ; QPredVV np v x = intVerbClause np (aux2verb v) (complVerbVerb v x) ; QPredVQ np v x = intVerbClause np v (complQuestVerb v x) ; QPredVA np v x = intVerbClause np v (complAdjVerb v x) ; QPredV2A np v x y = intVerbClause np v (complDitransAdjVerb v x y) ; - QPredSubjV2V np v x y = intVerbClause np v (complDitransVerbVerb - False v x y) ; - QPredObjV2V np v x y = intVerbClause np v (complDitransVerbVerb - True v x y) ; + QPredSubjV2V np v x y = intVerbClause np v (complDitransVerbVerb False v x y) ; + QPredObjV2V np v x y = intVerbClause np v (complDitransVerbVerb True v x y) ; QPredV2S np v x y = intVerbClause np v (complDitransSentVerb v x y) ; QPredV2Q np v x y = intVerbClause np v (complDitransQuestVerb v x y) ; @@ -50,10 +49,29 @@ concrete ClauseEng of Clause = CategoriesEng ** QPredNP np v = predBeGroupQ np (complNounPhrase v) ; QPredAdv np v = predBeGroupQ np (complAdverb v) ; + QPredProgVP np vp = predBeGroupQ np (vp.s ! VIPresPart) ; + IPredV a v = predVerbI True a v (complVerb v) ; + IPredPassV a v = predVerbI True a v (passVerb v) ; IPredV2 a v x = predVerbI True a v (complTransVerb v x) ; + IPredReflV2 a v = predVerbI True a v (reflTransVerb v) ; + IPredV3 a v x y = predVerbI True a v (complDitransVerb v x y) ; + IPredVS a v x = predVerbI True a v (complSentVerb v x) ; + IPredVV a v x = predVerbI True a (aux2verb v) (complVerbVerb v x) ; + IPredVQ a v x = predVerbI True a v (complQuestVerb v x) ; + IPredVA a v x = predVerbI True a v (complAdjVerb v x) ; + IPredV2A a v x y = predVerbI True a v (complDitransAdjVerb v x y) ; + IPredSubjV2V a v x y = predVerbI True a v (complDitransVerbVerb False v x y) ; + IPredObjV2V a v x y = predVerbI True a v (complDitransVerbVerb True v x y) ; + IPredV2S a v x y = predVerbI True a v (complDitransSentVerb v x y) ; + IPredV2Q a v x y = predVerbI True a v (complDitransQuestVerb v x y) ; IPredAP a v = predBeGroupI True a v.s ; + IPredCN a v = predBeGroupI True a (complCommNoun v) ; + IPredNP a v = predBeGroupI True a (complNounPhrase v) ; + IPredAdv a v = predBeGroupI True a (complAdverb v) ; + + IPredProgVP a vp = predBeGroupI True a (vp.s ! VIPresPart) ; {- -- Use VPs diff --git a/lib/resource/english/LangEng.gf b/lib/resource/english/LangEng.gf index 97dd73c73..3187ecaf9 100644 --- a/lib/resource/english/LangEng.gf +++ b/lib/resource/english/LangEng.gf @@ -19,4 +19,5 @@ lin PNCountry x = x ; ANationality x = x ; NLanguage x = x ; + } \ No newline at end of file diff --git a/lib/resource/english/RulesEng.gf b/lib/resource/english/RulesEng.gf index f71b18f14..025da26b7 100644 --- a/lib/resource/english/RulesEng.gf +++ b/lib/resource/english/RulesEng.gf @@ -111,7 +111,7 @@ lin AdvCN = advCommNounPhrase ; AdvAP = advAdjPhrase ; AdvAdv = cc2 ; - + AdvPN pn pp = nameNounPhrase {s = \\c => pn.s ! c ++ pp.s ; g = pn.g} ; --3 Sentences and relative clauses -- @@ -180,6 +180,7 @@ lin SubjS = subjunctSentence ; SubjImper = subjunctImperative ; SubjQS = subjunctQuestion ; + AdvSubj if A = ss (if.s ++ A.s) ; PhrNP = useNounPhrase ; PhrOneCN = useCommonNounPhrase singular ; diff --git a/src/GF/CF/CanonToCF.hs b/src/GF/CF/CanonToCF.hs index 6c00da042..a0ec72cd9 100644 --- a/src/GF/CF/CanonToCF.hs +++ b/src/GF/CF/CanonToCF.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/21 16:21:11 $ --- > CVS $Author: bringert $ --- > CVS $Revision: 1.13 $ +-- > CVS $Date: 2005/05/31 12:47:52 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.14 $ -- -- AR 27\/1\/2000 -- 3\/12\/2001 -- 8\/6\/2003 ----------------------------------------------------------------------------- @@ -42,17 +42,22 @@ canon2cf opts gr c = tracePrt "#size of CF" (err id (show.length.rulesOfCF)) $ d a <- M.abstractOfConcrete gr c let cncs = [m | (n, M.ModMod m) <- M.modules gr, elem n ms] let mms = [(a, tree2list (M.jments m)) | m <- cncs] - rules0 <- liftM concat $ mapM (uncurry (cnc2cfCond opts)) mms + cnc <- liftM M.jments $ M.lookupModMod gr c + rules0 <- liftM concat $ mapM (uncurry (cnc2cfCond opts cnc)) mms let bindcats = map snd $ allBindCatsOf gr let rules = filter (not . isCircularCF) rules0 ---- temporarily here let grules = groupCFRules rules let predef = mkCFPredef opts bindcats grules return $ CF predef -cnc2cfCond :: Options -> Ident -> [(Ident,Info)] -> Err [CFRule] -cnc2cfCond opts m gr = +cnc2cfCond :: Options -> BinTree Ident Info -> + Ident -> [(Ident,Info)] -> Err [CFRule] +cnc2cfCond opts cnc m gr = liftM concat $ - mapM lin2cf [(m,fun,cat,args,lin) | (fun, CncFun cat args lin _) <- gr] + mapM lin2cf [(m,fun,cat,args,lin) | + (fun, CncFun cat args lin _) <- gr, is fun] + where + is f = isInBinTree f cnc type IFun = Ident type ICat = CIdent diff --git a/src/GF/Embed/EmbedParsing.hs b/src/GF/Embed/EmbedParsing.hs index 485fa2379..40378c491 100644 --- a/src/GF/Embed/EmbedParsing.hs +++ b/src/GF/Embed/EmbedParsing.hs @@ -83,7 +83,7 @@ trees2trms opts sg cn as ts0 info = do ,checkWarn (unlines ("Raw CF trees:":(map prCFTree ts0))) >> return [] ] _ -> do - let num = optIntOrN opts flagRawtrees 99999 + let num = optIntOrN opts flagRawtrees 999999 let (ts01,rest) = splitAt num ts0 if null rest then return () else checkWarn ("Warning: only" +++ show num +++ "raw parses out of" +++ diff --git a/src/GF/UseGrammar/Parsing.hs b/src/GF/UseGrammar/Parsing.hs index bdf179987..7620bb4ab 100644 --- a/src/GF/UseGrammar/Parsing.hs +++ b/src/GF/UseGrammar/Parsing.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/05/11 10:28:16 $ --- > CVS $Author: peb $ --- > CVS $Revision: 1.23 $ +-- > CVS $Date: 2005/05/31 12:47:52 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.24 $ -- -- (Description of the module) ----------------------------------------------------------------------------- @@ -104,7 +104,7 @@ trees2trms opts sg cn as ts0 info = do ,checkWarn (unlines ("Raw CF trees:":(map prCFTree ts0))) >> return [] ] _ -> do - let num = optIntOrN opts flagRawtrees 99999 + let num = optIntOrN opts flagRawtrees 999999 let (ts01,rest) = splitAt num ts0 if null rest then return () else raise ("Warning: only" +++ show num +++ "raw parses out of" +++