From f283528094e284d6eb7b60893ad1d8ad8b1de488 Mon Sep 17 00:00:00 2001 From: aarne Date: Sun, 22 Jun 2008 18:33:15 +0000 Subject: [PATCH] Finnish negation particle stored in VP for vowel harmony --- lib/resource-1.4/finnish/CatFin.gf | 2 +- lib/resource-1.4/finnish/IdiomFin.gf | 8 +++++--- lib/resource-1.4/finnish/MorphoFin.gf | 3 ++- lib/resource-1.4/finnish/ParadigmsFin.gf | 11 +++++++---- lib/resource-1.4/finnish/QuestionFin.gf | 2 +- lib/resource-1.4/finnish/ResFin.gf | 25 +++++++++++++++++------- lib/resource-1.4/finnish/VerbFin.gf | 9 ++++++--- src-3.0/GF/Command/Commands.hs | 6 +++++- src-3.0/GF/Text/Lexing.hs | 2 ++ 9 files changed, 47 insertions(+), 21 deletions(-) diff --git a/lib/resource-1.4/finnish/CatFin.gf b/lib/resource-1.4/finnish/CatFin.gf index 9c937941e..62a90c06a 100644 --- a/lib/resource-1.4/finnish/CatFin.gf +++ b/lib/resource-1.4/finnish/CatFin.gf @@ -95,6 +95,6 @@ concrete CatFin of Cat = CommonX ** open ResFin, Prelude in { N3 = {s : NForm => Str} ** {c2,c3 : Compl} ; PN = {s : Case => Str} ; -oper Verb1 = {s : VForm => Str ; sc : NPForm} ; +oper Verb1 = {s : VForm => Str ; sc : NPForm ; qp : Str} ; } diff --git a/lib/resource-1.4/finnish/IdiomFin.gf b/lib/resource-1.4/finnish/IdiomFin.gf index 983cb1496..99b0e2080 100644 --- a/lib/resource-1.4/finnish/IdiomFin.gf +++ b/lib/resource-1.4/finnish/IdiomFin.gf @@ -41,7 +41,8 @@ concrete IdiomFin of Idiom = CatFin ** s = \\_ => vp.s ! VIPass ; s2 = vp.s2 ; ext = vp.ext ; - sc = vp.sc + sc = vp.sc ; + qp = vp.qp } ; ProgrVP vp = @@ -52,7 +53,8 @@ concrete IdiomFin of Idiom = CatFin ** s = on.s ; s2 = \\b,p,a => inf ++ vp.s2 ! b ! p ! a ; ext = vp.ext ; - sc = vp.sc + sc = vp.sc ; + qp = vp.qp } ; -- This gives "otetaan oluet" instead of "ottakaamme oluet". @@ -66,7 +68,7 @@ concrete IdiomFin of Idiom = CatFin ** } ; oper - olla = verbOlla ** {sc = NPCase Nom} ; + olla = verbOlla ** {sc = NPCase Nom ; qp = "ko"} ; noSubj : Polarity -> Str = \_ -> [] ; } diff --git a/lib/resource-1.4/finnish/MorphoFin.gf b/lib/resource-1.4/finnish/MorphoFin.gf index 6c918af7c..3c274a3de 100644 --- a/lib/resource-1.4/finnish/MorphoFin.gf +++ b/lib/resource-1.4/finnish/MorphoFin.gf @@ -683,7 +683,7 @@ resource MorphoFin = ResFin ** open Prelude in { 11 => lienee } ; - vforms2V : VForms -> Verb = \vh -> + vforms2V : VForms -> Verb ** {qp : Str} = \vh -> let tulla = vh ! 0 ; tulen = vh ! 1 ; @@ -748,6 +748,7 @@ resource MorphoFin = ResFin ** open Prelude in { Inf Inf3Abess => tulema + "tt" + a } ; sc = NPCase Nom ; + qp = Predef.dp 2 tulko ; lock_V = <> } ; diff --git a/lib/resource-1.4/finnish/ParadigmsFin.gf b/lib/resource-1.4/finnish/ParadigmsFin.gf index fcb042002..e71425aca 100644 --- a/lib/resource-1.4/finnish/ParadigmsFin.gf +++ b/lib/resource-1.4/finnish/ParadigmsFin.gf @@ -473,8 +473,11 @@ oper huusin,huusi,huusisi,huutanut,huudettu,huutanee : Str) -> V = mk12V ; } ; - mk1V : Str -> V = \s -> vforms2V (vForms1 s) ** {sc = NPCase Nom ; lock_V = <>} ; - mk2V : (_,_ : Str) -> V = \x,y -> vforms2V (vForms2 x y) ** {sc = NPCase Nom ; lock_V = <>} ; + mk1V : Str -> V = \s -> + let vfs = vforms2V (vForms1 s) in + vfs ** {sc = NPCase Nom ; lock_V = <>} ; + mk2V : (_,_ : Str) -> V = \x,y -> + let vfs = vforms2V (vForms2 x y) in vfs ** {sc = NPCase Nom ; lock_V = <>} ; mk3V : (huutaa,huudan,huusi : Str) -> V = \x,_,y -> mk2V x y ; ---- mk12V : ( huutaa,huudan,huutaa,huutavat,huutakaa,huudetaan, @@ -543,9 +546,9 @@ oper - caseV c v = {s = v.s ; sc = NPCase c ; lock_V = <>} ; + caseV c v = {s = v.s ; sc = NPCase c ; qp = v.qp ; lock_V = <>} ; - vOlla = verbOlla ** {sc = NPCase Nom ; lock_V = <>} ; + vOlla = verbOlla ** {sc = NPCase Nom ; qp = "ko" ; lock_V = <>} ; ---- lieneekö mk2V2 : V -> Prep -> V2 = \v,c -> v ** {c2 = c ; lock_V2 = <>} ; caseV2 : V -> Case -> V2 = \v,c -> mk2V2 v (casePrep c) ; diff --git a/lib/resource-1.4/finnish/QuestionFin.gf b/lib/resource-1.4/finnish/QuestionFin.gf index 149c35c29..f1dbc21f1 100644 --- a/lib/resource-1.4/finnish/QuestionFin.gf +++ b/lib/resource-1.4/finnish/QuestionFin.gf @@ -31,7 +31,7 @@ concrete QuestionFin of Question = CatFin ** open ResFin, Prelude in { QuestIComp icomp np = { s = \\t,a,p => let - vp = predV (verbOlla ** {sc = NPCase Nom}) ; + vp = predV (verbOlla ** {sc = NPCase Nom ; qp = "ko"}) ; cl = mkClause (subjForm np vp.sc) np.a vp ; in icomp.s ! np.a ++ cl.s ! t ! a ! p ! SDecl diff --git a/lib/resource-1.4/finnish/ResFin.gf b/lib/resource-1.4/finnish/ResFin.gf index 7f2cb9aae..5fc68384d 100644 --- a/lib/resource-1.4/finnish/ResFin.gf +++ b/lib/resource-1.4/finnish/ResFin.gf @@ -159,10 +159,11 @@ oper s : VIForm => Anteriority => Polarity => Agr => {fin, inf : Str} ; s2 : Bool => Polarity => Agr => Str ; -- talo/talon/taloa ext : Str ; - sc : NPForm + sc : NPForm ; + qp : Str } ; - predV : (Verb ** {sc : NPForm}) -> VP = \verb -> { + predV : (Verb ** {sc : NPForm ; qp : Str}) -> VP = \verb -> { s = \\vi,ant,b,agr => let @@ -220,21 +221,24 @@ oper s2 = \\_,_,_ => [] ; ext = [] ; - sc = verb.sc + sc = verb.sc ; + qp = verb.qp } ; insertObj : (Bool => Polarity => Agr => Str) -> VP -> VP = \obj,vp -> { s = vp.s ; s2 = \\fin,b,a => obj ! fin ! b ! a ++ vp.s2 ! fin ! b ! a ; ext = vp.ext ; - sc = vp.sc + sc = vp.sc ; + qp = vp.qp } ; insertExtrapos : Str -> VP -> VP = \obj,vp -> { s = vp.s ; s2 = vp.s2 ; ext = vp.ext ++ obj ; - sc = vp.sc + sc = vp.sc ; + qp = vp.qp } ; -- For $Sentence$. @@ -257,7 +261,7 @@ oper in case o of { SDecl => subj ++ verb.fin ++ verb.inf ++ compl ; - SQuest => questPart verb.fin ++ subj ++ verb.inf ++ compl + SQuest => questPart vp a b verb.fin ++ subj ++ verb.inf ++ compl } } ; @@ -266,7 +270,14 @@ oper subjForm : NP -> NPForm -> Polarity -> Str = \np,sc,b -> appCompl False b {s = [] ; c = sc ; isPre = True} np ; - questPart : Str -> Str = \on -> on ++ BIND ++ "ko" ; ---- + questPart : VP -> Anteriority -> Polarity -> Str -> Str = \vp,a,p,on -> on ++ BIND ++ + case p of { + Neg => "kö" ; -- eikö tule + _ => case a of { + Anter => "ko" ; -- onko mennyt + _ => vp.qp -- tuleeko, meneekö + } + } ; infVP : NPForm -> Polarity -> Agr -> VP -> InfForm -> Str = \sc,pol,agr,vp,vi -> diff --git a/lib/resource-1.4/finnish/VerbFin.gf b/lib/resource-1.4/finnish/VerbFin.gf index 7dbf9e218..0e6498a0b 100644 --- a/lib/resource-1.4/finnish/VerbFin.gf +++ b/lib/resource-1.4/finnish/VerbFin.gf @@ -23,7 +23,8 @@ concrete VerbFin of Verb = CatFin ** open Prelude, ResFin in { sc = case vp.sc of { NPCase Nom => v.sc ; -- minun täytyy pestä auto c => c -- minulla täytyy olla auto - } + } ; + qp = v.qp } ) ; @@ -51,7 +52,7 @@ concrete VerbFin of Verb = CatFin ** open Prelude, ResFin in { ComplSlash vp np = insertObj (\\fin,b,_ => appCompl fin b vp.c2 np) vp ; UseComp comp = - insertObj (\\_,_ => comp.s) (predV (verbOlla ** {sc = NPCase Nom})) ; + insertObj (\\_,_ => comp.s) (predV (verbOlla ** {sc = NPCase Nom ; qp = "ko"})) ; SlashVV v vp = insertObj @@ -60,7 +61,8 @@ concrete VerbFin of Verb = CatFin ** open Prelude, ResFin in { sc = case vp.sc of { NPCase Nom => v.sc ; -- minun täytyy pestä auto c => c -- minulla täytyy olla auto - } + } ; + qp = v.qp } ) ** {c2 = vp.c2} ; ---- correct ?? @@ -79,6 +81,7 @@ concrete VerbFin of Verb = CatFin ** open Prelude, ResFin in { s = \\_ => vp.s ! VIPass ; s2 = \\_,_,_ => [] ; ext = [] ; + qp = v.qp ; sc = v.c2.c -- minut valitaan ; minua rakastetaan ; minulle kuiskataan } ; ---- talon valitaan: should be marked like inf. diff --git a/src-3.0/GF/Command/Commands.hs b/src-3.0/GF/Command/Commands.hs index 6cdd82d7e..650b19693 100644 --- a/src-3.0/GF/Command/Commands.hs +++ b/src-3.0/GF/Command/Commands.hs @@ -343,6 +343,7 @@ allCommands pgf = Map.fromList [ exec = \opts -> return . fromString . stringOps opts . toString, options = [ ("bind","bind tokens separated by Prelude.BIND, i.e. &+"), + ("chars","lexer that makes every non-space character a token"), ("from_devanagari","from unicode to GF Devanagari transliteration"), ("from_thai","from unicode to GF Thai transliteration"), ("from_utf8","decode from utf8"), @@ -355,6 +356,7 @@ allCommands pgf = Map.fromList [ ("unlextext","text-like unlexer"), ("unlexcode","code-like unlexer"), ("unlexmixed","mixture of text and code (code between $...$)"), + ("unchars","unlexer that puts no spaces between tokens"), ("unwords","unlexer that puts a single space between tokens (default)"), ("words","lexer that assumes tokens separated by spaces (default)") ] @@ -499,7 +501,7 @@ allCommands pgf = Map.fromList [ _ | isOpt "treebank" opts -> treebank opts t _ -> unlines [linear opts lang t | lang <- optLangs opts] - linear opts lang = case opts of + linear opts lang = unlex opts lang . case opts of _ | isOpt "all" opts -> allLinearize pgf (mkCId lang) _ | isOpt "table" opts -> tableLinearize pgf (mkCId lang) _ | isOpt "term" opts -> termLinearize pgf (mkCId lang) @@ -510,6 +512,8 @@ allCommands pgf = Map.fromList [ (abstractName pgf ++ ": " ++ showTree t) : [lang ++ ": " ++ linear opts lang t | lang <- optLangs opts] + unlex opts lang = stringOps opts + optRestricted opts = restrictPGF (hasLin pgf (mkCId (optLang opts))) pgf optLangs opts = case valIdOpts "lang" "" opts of diff --git a/src-3.0/GF/Text/Lexing.hs b/src-3.0/GF/Text/Lexing.hs index 16391d183..beabf217b 100644 --- a/src-3.0/GF/Text/Lexing.hs +++ b/src-3.0/GF/Text/Lexing.hs @@ -9,11 +9,13 @@ import Data.Char stringOp :: String -> Maybe (String -> String) stringOp name = case name of + "chars" -> Just $ appLexer (filter (not . all isSpace) . map return) "lextext" -> Just $ appLexer lexText "lexcode" -> Just $ appLexer lexText "lexmixed" -> Just $ appLexer lexMixed "words" -> Just $ appLexer words "bind" -> Just $ appUnlexer bindTok + "uncars" -> Just $ appUnlexer concat "unlextext" -> Just $ appUnlexer unlexText "unlexcode" -> Just $ appUnlexer unlexCode "unlexmixed" -> Just $ appUnlexer unlexMixed