ml and tl

This commit is contained in:
aarne
2005-05-17 11:37:17 +00:00
parent 197c3029e3
commit 9cc8eb6905
6 changed files with 81 additions and 32 deletions

View File

@@ -21,7 +21,7 @@
<p>
12 May 2005
17 May 2005
</center>
@@ -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 <tt>translation_list = tl</tt>
<pre>
> translation_list PaleolithicEng PaleolithicIta 25
> translation_list -number=25 PaleolithicEng PaleolithicIta
</pre>
(The number 25 is the number of sentences generated.)
The number flag gives the number of sentences generated.
<!-- NEW -->
@@ -1125,6 +1125,47 @@ lin
<!-- NEW -->
<h4>Hierarchic parameter types</h4>
The reader familiar with a functional programming language such as
<a href="www.haskell.org">Haskell</a> must have noticed the similarity
between parameter types in GF and algebraic datatypes (<tt>data</tt> 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.)
<p>
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.
<p>
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
<tt>Gender => Number => Str</tt>. The following hierarchic definition
yields an accurate system of three adjectival forms.
<pre>
param AdjForm = ASg Gender | APl ;
param Gender = Uter | Neuter ;
</pre>
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
<pre>
oper plattAdj : Str -> AdjForm => Str = \x -> table {
ASg _ => x ;
APl => x + "a" ;
}
</pre>
<!-- NEW -->
<h2>Topics still to be written</h2>

View File

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

View File

@@ -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" ++

View File

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

View File

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

View File

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