From 55f914f4446f04b666884dba02de8be830001975 Mon Sep 17 00:00:00 2001 From: Aarne Ranta Date: Tue, 22 Aug 2017 12:39:17 +0300 Subject: [PATCH] started automated documentation of Extend module --- doc/DocExtend.hs | 45 +++++++++++++++++++++++++++++++++++++ src/abstract/Extend.gf | 8 +++---- src/common/ExtendFunctor.gf | 8 +++---- src/english/ExtendEng.gf | 13 ++++++++++- 4 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 doc/DocExtend.hs diff --git a/doc/DocExtend.hs b/doc/DocExtend.hs new file mode 100644 index 000000000..bbaecf340 --- /dev/null +++ b/doc/DocExtend.hs @@ -0,0 +1,45 @@ +main = docExtend + +docExtend = do + + -- read the abstract syntax file + funds <- readFile "../src/abstract/Extend.gf" >>= return . map words . lines + + -- function format: + -- GenNP : NP -> Quant ; -- this man's + let funs = [[fu,unwords ty,unwords co] | fu:":":ws <- funds, (ty,_:_:co) <- [break (==";") ws]] + --- mapM print funs + + -- read the concrete syntax functor + funcs <- readFile "../src/common/ExtendFunctor.gf" >>= return . map words . lines + + -- definition format: one of + -- GenNP = variants {} ; -- NP -> Quant ; -- this man's + -- UttDatIP ip = UttAccIP (lin IP ip) ; -- whom (dative) ; DEFAULT who + let defs = [[[fu],de,co] | fuws <- funcs, (fu:_,_:ws) <- [break (=="=") fuws], (de,_:_:co) <- [break (==";") ws]] + let undef de co = if de == ["variants", "{}"] then "-" else unwords (tail (dropWhile (/="DEFAULT") co)) + let fundefs = [[fu,ty,co,undef d c] | fu:ty:co:_ <- funs, [f]:d:c:_ <- defs, f==fu] + --- mapM print fundefs + + -- read the functor exclusion lists for each language + let langs = [("Eng","english"),("Dut","dutch"),("Spa","spanish")] --,("Swe","swedish")] + funss <- mapM getExclusions langs + mapM_ print funss + let langfuns = zip (map fst langs) funss + let funlangs = [(fu,[lang | (lang,fs) <- langfuns, elem fu fs]) | fu:_ <- funs] + let fundeflangs = [[fu,ty,co,de,unwords ls] | fu:ty:co:de:_ <- fundefs, (f,ls) <- funlangs, f==fu] + mapM print fundeflangs + +-- exclusion format: +-- concrete ExtendEng of Extend = +-- CatEng ** ExtendFunctor - +-- [ +-- VPS, ListVPS, RNP, RNPList --- lines between the first [ and ] lines are read +-- ] + +getExclusions (lan,language) = do + rs <- readFile ("../src/" ++ language ++ "/Extend" ++ lan ++ ".gf") >>= return . map words . lines + let excls = case dropWhile (/=["["]) rs of + [] -> [] + _:es -> map (filter (/=',')) $ concat $ takeWhile (/= ["]"]) es + return excls \ No newline at end of file diff --git a/src/abstract/Extend.gf b/src/abstract/Extend.gf index 9327743fa..05323db74 100644 --- a/src/abstract/Extend.gf +++ b/src/abstract/Extend.gf @@ -182,9 +182,9 @@ abstract Extend = Cat ** { youPolFem_Pron : Pron ; -- vous (ĂȘtes vieille) -- German - UttAccNP : NP -> Utt ; -- mich - UttDatNP : NP -> Utt ; -- mir - UttAccIP : NP -> Utt ; -- wen - UttDatIP : NP -> Utt ; -- wem + UttAccNP : NP -> Utt ; -- him (accusative) + UttDatNP : NP -> Utt ; -- him (dative) + UttAccIP : NP -> Utt ; -- whom (accusative) + UttDatIP : NP -> Utt ; -- whom (dative) } diff --git a/src/common/ExtendFunctor.gf b/src/common/ExtendFunctor.gf index a054c9270..fdb56a4de 100644 --- a/src/common/ExtendFunctor.gf +++ b/src/common/ExtendFunctor.gf @@ -85,9 +85,9 @@ lin youPlFem_Pron = youPl_Pron ; theyFem_Pron = they_Pron ; youPolFem_Pron = youPol_Pron ; - UttAccNP = UttNP ; - UttDatNP = UttNP ; - UttAccIP = UttIP ; - UttDatIP = UttIP ; + UttAccNP = UttNP ; -- him (accusative) ; DEFAULT he + UttDatNP np = UttAccNP (lin NP np) ; -- him(dative) ; DEFAULT he + UttAccIP = UttIP ; -- whom (accusative) ; DEFAULT who + UttDatIP ip = UttAccIP (lin IP ip) ; -- whom (dative) ; DEFAULT who } \ No newline at end of file diff --git a/src/english/ExtendEng.gf b/src/english/ExtendEng.gf index dbf2582c5..be33370d6 100644 --- a/src/english/ExtendEng.gf +++ b/src/english/ExtendEng.gf @@ -1,7 +1,18 @@ --# -path=.:../common:../abstract concrete ExtendEng of Extend = - CatEng ** ExtendFunctor [ProDrop] + CatEng ** ExtendFunctor - + [ + VPS, ListVPS, RNP, RNPList, + AdAdV, AdjAsCN, AdjAsNP, ApposNP, BaseVPS, Base_nr_RNP, Base_rn_RNP, Base_rr_RNP, ByVP, CompBareCN, + CompIQuant, CompQS, CompS, CompVP, ComplBareVS, ComplGenVV, ComplSlashPartLast, ComplVPSVV, CompoundAP, + CompoundN, ConjRNP, ConjVPS, ConsVPS, Cons_nr_RNP, Cons_rr_RNP, DetNPFem, EmbedPresPart, EmptyRelSlash, + ExistsNP, FocusAP, FocusAdV, FocusAdv, FocusObj, FrontExtPredVP, GenIP, GenModIP, GenModNP, GenNP, GenRP, + GerundAdv, GerundCN, GerundNP, IAdvAdv, ICompAP, InOrderToVP, InvFrontExtPredVP, MkVPS, NominalizeVPSlashNP, + PassAgentVPSlash, PassVPSlash, PastPartAP, PastPartAgentAP, PositAdVAdj, PredVPS, PredVPSVV, PredetRNP, PrepCN, + PresPartAP, PurposeVP, ReflPoss, ReflPron, ReflRNP, SlashBareV2S, SlashV2V, StrandQuestSlash, StrandRelSlash, + UncontractedNeg, UttAccIP, UttAccNP, UttAdV, UttDatIP, UttDatNP, UttVPShort, WithoutVP + ] with (Grammar = GrammarEng) **