From 9cc8eb6905aa737aea89420dff6a26577c379a1d Mon Sep 17 00:00:00 2001 From: aarne Date: Tue, 17 May 2005 11:37:17 +0000 Subject: [PATCH] ml and tl --- doc/tutorial/gf-tutorial2.html | 47 +++++++++++++++++++++++++++++++--- src/GF/Shell.hs | 14 +++++----- src/GF/Shell/HelpFile.hs | 17 +++++++----- src/GF/Shell/PShell.hs | 8 +++--- src/GF/Shell/ShellCommands.hs | 14 +++++----- src/HelpFile | 13 ++++++---- 6 files changed, 81 insertions(+), 32 deletions(-) diff --git a/doc/tutorial/gf-tutorial2.html b/doc/tutorial/gf-tutorial2.html index edf7d66c5..ba96d2cae 100644 --- a/doc/tutorial/gf-tutorial2.html +++ b/doc/tutorial/gf-tutorial2.html @@ -21,7 +21,7 @@

-12 May 2005 +17 May 2005 @@ -634,9 +634,9 @@ makes this in a subshell of GF. You can also generate a list of translation exercises and save it in a file for later use, by the command translation_list = tl

-  > translation_list PaleolithicEng PaleolithicIta 25
+  > translation_list -number=25 PaleolithicEng PaleolithicIta
 
-(The number 25 is the number of sentences generated.) +The number flag gives the number of sentences generated. @@ -1125,6 +1125,47 @@ lin + +

Hierarchic parameter types

+ +The reader familiar with a functional programming language such as +Haskell must have noticed the similarity +between parameter types in GF and algebraic datatypes (data definitions +in Haskell). The GF parameter types are actually a special case of algebraic +datatypes: the main restriction is that in GF, these types must be finite. +(This restriction makes it possible to invert linearization rules into +parsing methods.) + +

+ +However, finite is not the same thing as enumerated. Even in GF, parameter +constructors can take arguments, provided these arguments are from other +parameter types (recursion is forbidden). Such parameter types impose a +hierarchic order among parameters. They are often useful to define +linguistically accurate parameter systems. + +

+ +To give an example, Swedish adjectives +are inflected in number (singular or plural) and +gender (uter or neuter). These parameters would suggest 2*2=4 different +forms. However, the gender distinction is done only in the singular. Therefore, +it would be inaccurate to define adjective paradigms using the type +Gender => Number => Str. The following hierarchic definition +yields an accurate system of three adjectival forms. +

+  param AdjForm = ASg Gender | APl ;
+  param Gender  = Uter | Neuter ;
+
+In pattern matching, a constructor can have patterns as arguments. For instance, +the adjectival paradigm in which the two singular forms are the same, can be defined +
+  oper plattAdj : Str -> AdjForm => Str = \x -> table {
+    ASg _ => x ;
+    APl   => x + "a" ;
+    }
+
+

Topics still to be written

diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs index 7dca7b066..dd08e98bd 100644 --- a/src/GF/Shell.hs +++ b/src/GF/Shell.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/05/17 11:20:25 $ --- > CVS $Author: peb $ --- > CVS $Revision: 1.37 $ +-- > CVS $Date: 2005/05/17 12:37:17 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.38 $ -- -- GF shell command interpreter. ----------------------------------------------------------------------------- @@ -232,15 +232,17 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of CTranslationQuiz il ol -> do warnDiscont opts justOutput opts (teachTranslation opts (sgr il) (sgr ol)) sa - CTranslationList il ol n -> do - warnDiscont opts + CTranslationList il ol -> do + warnDiscont opts + let n = optIntOrN opts flagNumber 10 qs <- transTrainList opts (sgr il) (sgr ol) (toInteger n) returnArg (AString $ foldr (+++++) [] [unlines (s:ss) | (s,ss) <- qs]) sa CMorphoQuiz -> do warnDiscont opts justOutput opts (teachMorpho opts gro) sa - CMorphoList n -> do + CMorphoList -> do + let n = optIntOrN opts flagNumber 10 warnDiscont opts qs <- useIOE [] $ morphoTrainList opts gro (toInteger n) returnArg (AString $ foldr (+++++) [] [unlines (s:ss) | (s,ss) <- qs]) sa diff --git a/src/GF/Shell/HelpFile.hs b/src/GF/Shell/HelpFile.hs index 2723e5fbc..31da095aa 100644 --- a/src/GF/Shell/HelpFile.hs +++ b/src/GF/Shell/HelpFile.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/05/12 10:03:33 $ +-- > CVS $Date: 2005/05/17 12:37:17 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.3 $ +-- > CVS $Revision: 1.4 $ -- -- Help on shell commands. Generated from HelpFile by 'make help'. -- PLEASE DON'T EDIT THIS FILE. @@ -339,11 +339,13 @@ txtHelpFile = "\n examples:" ++ "\n tq -cat=NP TestResourceEng TestResourceSwe -- quiz for NPs" ++ "\n" ++ - "\ntl, translation_list: tl Lang Lang Int" ++ - "\n Random-generates a list of Int translation exercises from Lang1 to Lang2." ++ + "\ntl, translation_list: tl Lang Lang" ++ + "\n Random-generates a list of ten translation exercises from Lang1" ++ + "\n to Lang2. The number can be changed by a flag." ++ "\n HINT: use wf to save the exercises in a file." ++ "\n flags:" ++ "\n -cat" ++ + "\n -number" ++ "\n examples:" ++ "\n tl -cat=NP TestResourceEng TestResourceSwe -- quiz list for NPs" ++ "\n" ++ @@ -359,13 +361,14 @@ txtHelpFile = "\n examples:" ++ "\n mq -cat=N -lang=TestResourceSwe -- quiz for Swedish nouns" ++ "\n" ++ - "\nml, morphology_list: ml Int" ++ - "\n Random-generates a list of Int morphological exercises," ++ - "\n keeping score of success." ++ + "\nml, morphology_list: ml" ++ + "\n Random-generates a list of ten morphological exercises," ++ + "\n keeping score of success. The number can be changed with a flag." ++ "\n HINT: use wf to save the exercises in a file." ++ "\n flags:" ++ "\n -cat" ++ "\n -lang" ++ + "\n -number" ++ "\n examples:" ++ "\n ml -cat=N -lang=TestResourceSwe -- quiz list for Swedish nouns" ++ "\n" ++ diff --git a/src/GF/Shell/PShell.hs b/src/GF/Shell/PShell.hs index 480284ccf..78b1f38a6 100644 --- a/src/GF/Shell/PShell.hs +++ b/src/GF/Shell/PShell.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/05/12 10:03:33 $ +-- > CVS $Date: 2005/05/17 12:37:17 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.21 $ +-- > CVS $Revision: 1.22 $ -- -- parsing GF shell commands. AR 11\/11\/2001 ----------------------------------------------------------------------------- @@ -104,9 +104,9 @@ pCommand ws = case ws of "so" : s -> aUnit $ CShowOpers $ unwords s "tq" : i:o:[] -> aUnit (CTranslationQuiz (language i) (language o)) - "tl":i:o:n:[] -> aUnit (CTranslationList (language i) (language o) (readIntArg n)) + "tl":i:o:[] -> aUnit (CTranslationList (language i) (language o)) "mq" : [] -> aUnit CMorphoQuiz - "ml" : n : [] -> aUnit (CMorphoList (readIntArg n)) + "ml" : [] -> aUnit CMorphoList "wf" : f : s -> aString (CWriteFile f) s "af" : f : s -> aString (CAppendFile f) s diff --git a/src/GF/Shell/ShellCommands.hs b/src/GF/Shell/ShellCommands.hs index 0bed0e1e5..6144de0f8 100644 --- a/src/GF/Shell/ShellCommands.hs +++ b/src/GF/Shell/ShellCommands.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/05/13 12:40:20 $ --- > CVS $Author: peb $ --- > CVS $Revision: 1.34 $ +-- > CVS $Date: 2005/05/17 12:37:17 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.35 $ -- -- The datatype of shell commands and the list of their options. ----------------------------------------------------------------------------- @@ -53,9 +53,9 @@ data Command = | CShowOpers String | CTranslationQuiz Language Language - | CTranslationList Language Language Int + | CTranslationList Language Language | CMorphoQuiz - | CMorphoList Int + | CMorphoList | CReadFile FilePath | CWriteFile FilePath @@ -180,9 +180,9 @@ optionsOfCommand co = case co of CShowOpers _ -> flags "res" CTranslationQuiz _ _ -> flags "cat" - CTranslationList _ _ _ -> flags "cat" + CTranslationList _ _ -> flags "cat number" CMorphoQuiz -> flags "cat lang" - CMorphoList _ -> flags "cat lang" + CMorphoList -> flags "cat lang number" CReadFile _ -> none CWriteFile _ -> none diff --git a/src/HelpFile b/src/HelpFile index 4ebb00d1d..7d339e478 100644 --- a/src/HelpFile +++ b/src/HelpFile @@ -310,11 +310,13 @@ tq, translation_quiz: tq Lang Lang examples: tq -cat=NP TestResourceEng TestResourceSwe -- quiz for NPs -tl, translation_list: tl Lang Lang Int - Random-generates a list of Int translation exercises from Lang1 to Lang2. +tl, translation_list: tl Lang Lang + Random-generates a list of ten translation exercises from Lang1 + to Lang2. The number can be changed by a flag. HINT: use wf to save the exercises in a file. flags: -cat + -number examples: tl -cat=NP TestResourceEng TestResourceSwe -- quiz list for NPs @@ -330,13 +332,14 @@ mq, morphology_quiz: mq examples: mq -cat=N -lang=TestResourceSwe -- quiz for Swedish nouns -ml, morphology_list: ml Int - Random-generates a list of Int morphological exercises, - keeping score of success. +ml, morphology_list: ml + Random-generates a list of ten morphological exercises, + keeping score of success. The number can be changed with a flag. HINT: use wf to save the exercises in a file. flags: -cat -lang + -number examples: ml -cat=N -lang=TestResourceSwe -- quiz list for Swedish nouns