forked from GitHub/gf-core
generalized tour to a variable language by the script MkTour
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
--# -path=.:present
|
FL--# -path=.:present
|
||||||
|
|
||||||
-- (c) 2009 Aarne Ranta under LGPL
|
-- (c) 2009 Aarne Ranta under LGPL
|
||||||
|
|
||||||
|
|||||||
12
lib/doc/tour/Makefile
Normal file
12
lib/doc/tour/Makefile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Cat:
|
||||||
|
runghc MkTour Cat Catalan
|
||||||
|
|
||||||
|
Ger:
|
||||||
|
runghc MkTour Ger German
|
||||||
|
|
||||||
|
Rus:
|
||||||
|
runghc MkTour Rus Russian
|
||||||
|
|
||||||
|
Swe:
|
||||||
|
txt2tags -thtml -o tourSwe.html tour.txt
|
||||||
|
|
||||||
47
lib/doc/tour/MkTour.hs
Normal file
47
lib/doc/tour/MkTour.hs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
import System
|
||||||
|
|
||||||
|
original = "tour.txt"
|
||||||
|
|
||||||
|
main = do
|
||||||
|
xx <- getArgs
|
||||||
|
let (lan:language:_) = xx
|
||||||
|
src <- readFile original >>= return . lines
|
||||||
|
let txt = "tour" ++ lan ++ ".txt"
|
||||||
|
let gfs = "tour" ++ lan ++ ".gfs"
|
||||||
|
writeFile gfs []
|
||||||
|
writeFile txt []
|
||||||
|
script <- mkTour lan language src txt gfs
|
||||||
|
system $ "gf -s Lang.pgf <" ++ gfs
|
||||||
|
system $ "txt2tags -thtml " ++ txt
|
||||||
|
|
||||||
|
|
||||||
|
mkTour :: String -> String -> [String] -> FilePath -> FilePath -> IO ()
|
||||||
|
mkTour lan language src txt gfs = mapM_ mk src where
|
||||||
|
|
||||||
|
mk line = case line of
|
||||||
|
'>':command -> do -- gf command
|
||||||
|
let comm = loc command
|
||||||
|
apptxt ('>':comm)
|
||||||
|
appgfs (comm ++ " | " ++ appcomm)
|
||||||
|
appgfs "\n"
|
||||||
|
'*':_ -> return () -- gf-generated text
|
||||||
|
'#':_ -> return () -- Swedish-specific line
|
||||||
|
_ -> apptxt (loc line)
|
||||||
|
|
||||||
|
appgfs line = appendFile gfs line >> appendFile gfs "\n"
|
||||||
|
|
||||||
|
loc line = case line of
|
||||||
|
'S':'w':'e':'d':'i':'s':'h':cs -> language ++ loc cs
|
||||||
|
'S':'w':'e' :cs -> lan ++ loc cs
|
||||||
|
c :cs -> c : loc cs
|
||||||
|
_ -> line
|
||||||
|
|
||||||
|
apptxt line = appgfs $ appcomm ++ " " ++ show (line ++ "\n") ++ "\n"
|
||||||
|
|
||||||
|
appcomm = "wf -append -file=" ++ txt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
A Guided Tour of Swedish Grammar
|
A Guided Tour of Swedish Grammar
|
||||||
Aarne Ranta
|
Aarne Ranta
|
||||||
|
|
||||||
|
%!style(html) : utf8
|
||||||
|
%!postproc(html) : "#SWE" ""
|
||||||
|
|
||||||
This is an introduction to the basic grammar of Swedish.
|
This is an introduction to the basic grammar of Swedish.
|
||||||
It is guided by a computer program that knows the rules of the grammar.
|
It is guided by a computer program that knows the rules of the grammar.
|
||||||
@@ -72,8 +73,7 @@ from words and their forms.
|
|||||||
|
|
||||||
==Nouns==
|
==Nouns==
|
||||||
|
|
||||||
Nouns in Swedish have 8 #Swe
|
The inflection forms of nouns are shown in the following example:
|
||||||
inflection forms, as shown by the following example:
|
|
||||||
```
|
```
|
||||||
> %table flower_N
|
> %table flower_N
|
||||||
* s Sg Indef Nom : blomma
|
* s Sg Indef Nom : blomma
|
||||||
@@ -85,8 +85,8 @@ inflection forms, as shown by the following example:
|
|||||||
* s Pl Def Nom : blommorna
|
* s Pl Def Nom : blommorna
|
||||||
* s Pl Def Gen : blommornas
|
* s Pl Def Gen : blommornas
|
||||||
```
|
```
|
||||||
Here are the main noun inflection patterns - the
|
Here are some inflection patterns.
|
||||||
declensions 1 to 5: #SWE
|
#SWE They show the declensions 1 to 5.
|
||||||
```
|
```
|
||||||
> %forms flower_N
|
> %forms flower_N
|
||||||
* blomma, blommas, blomman, blommans, blommor, blommors, blommorna, blommornas
|
* blomma, blommas, blomman, blommans, blommor, blommors, blommorna, blommornas
|
||||||
@@ -98,7 +98,7 @@ declensions 1 to 5: #SWE
|
|||||||
* katt, katts, katten, kattens, katter, katters, katterna, katternas
|
* katt, katts, katten, kattens, katter, katters, katterna, katternas
|
||||||
|
|
||||||
> %forms apple_N
|
> %forms apple_N
|
||||||
* äpple, äpples, äpplet, äpplets, äpplen, äpplens, äpplena, äpplenas
|
* äpple, äpples, äpplet, äpplets, äpplen, äpplens, äpplena, äpplenas
|
||||||
|
|
||||||
> %forms house_N
|
> %forms house_N
|
||||||
* hus, hus, huset, husets, hus, hus, husen, husens
|
* hus, hus, huset, husets, hus, hus, husen, husens
|
||||||
@@ -109,7 +109,7 @@ can be approximative, or just cover one of the possible senses.
|
|||||||
|
|
||||||
In addition to inflection forms,
|
In addition to inflection forms,
|
||||||
Swedish nouns also have a gender. The gender is reflected, among
|
Swedish nouns also have a gender. The gender is reflected, among
|
||||||
other things, in the indefinite article used with the nouns: #SWE
|
other things, in the indefinite article used with the nouns.
|
||||||
```
|
```
|
||||||
> %translate "a man"
|
> %translate "a man"
|
||||||
* en man
|
* en man
|
||||||
@@ -124,7 +124,7 @@ The grammar training program has a small lexicon, with just 182 nouns. To see
|
|||||||
all there nouns, together with their inflection forms and senses explained in
|
all there nouns, together with their inflection forms and senses explained in
|
||||||
English, you can do as follows:
|
English, you can do as follows:
|
||||||
```
|
```
|
||||||
> generate_trees -cat=N | linearize -treebank -list -lang=LangSwe
|
> generate_trees -cat=N -number=5 | linearize -treebank -list -lang=LangSwe
|
||||||
|
|
||||||
* airplane_N
|
* airplane_N
|
||||||
* flygplan, flygplans, flygplanet, flygplanets, flygplan, flygplans, flygplanen, flygplanens
|
* flygplan, flygplans, flygplanet, flygplanets, flygplan, flygplans, flygplanen, flygplanens
|
||||||
@@ -140,22 +140,12 @@ you can try out a **morphology quiz**, which lets you train your knowledge
|
|||||||
of Swedish noun inflection. You can later train your inflection skills with
|
of Swedish noun inflection. You can later train your inflection skills with
|
||||||
other parts of speech, just changing the symbol ``N`` to some other symbol.
|
other parts of speech, just changing the symbol ``N`` to some other symbol.
|
||||||
```
|
```
|
||||||
> morpho_quiz -cat=N -lang=LangSwe
|
morpho_quiz -cat=N -lang=LangSwe
|
||||||
|
|
||||||
* Welcome to GF Morphology Quiz.
|
Welcome to GF Morphology Quiz.
|
||||||
* The quiz is over when you have done at least 10 examples
|
The quiz is over when you have done at least 10 examples
|
||||||
* with at least 75 % success.
|
with at least 75 % success.
|
||||||
* You can interrupt the quiz by entering a line consisting of a dot ('.').
|
You can interrupt the quiz by entering a line consisting of a dot ('.').
|
||||||
*
|
|
||||||
* vin s Pl Def Gen
|
|
||||||
* vinernas
|
|
||||||
* > Yes.
|
|
||||||
* Score 1/1
|
|
||||||
* tunga s Sg Indef Nom
|
|
||||||
* tungan
|
|
||||||
* > No, not tungan, but
|
|
||||||
* tunga
|
|
||||||
* Score 1/2
|
|
||||||
```
|
```
|
||||||
The quiz questions are randomly generated, so you can use the same
|
The quiz questions are randomly generated, so you can use the same
|
||||||
quiz for increasing your Swedish skills over and over again.
|
quiz for increasing your Swedish skills over and over again.
|
||||||
@@ -164,20 +154,20 @@ Another quiz is the **translation quiz**, which lets you to train translations
|
|||||||
of nouns from English to Swedish (or, in fact, of any part of speech from any
|
of nouns from English to Swedish (or, in fact, of any part of speech from any
|
||||||
language to any other one). Here is how it goes:
|
language to any other one). Here is how it goes:
|
||||||
```
|
```
|
||||||
> translation_quiz -from=LangEng -to=LangSwe -cat=N
|
translation_quiz -from=LangEng -to=LangSwe -cat=N
|
||||||
* Welcome to GF Translation Quiz.
|
Welcome to GF Translation Quiz.
|
||||||
* The quiz is over when you have done at least 10 examples
|
The quiz is over when you have done at least 10 examples
|
||||||
* with at least 75 % success.
|
with at least 75 % success.
|
||||||
* You can interrupt the quiz by entering a line consisting of a dot ('.').
|
You can interrupt the quiz by entering a line consisting of a dot ('.').
|
||||||
*
|
|
||||||
* ceiling
|
ceiling
|
||||||
* tak
|
tak
|
||||||
* > Yes.
|
> Yes.
|
||||||
* Score 1/1
|
Score 1/1
|
||||||
* night
|
night
|
||||||
* nat
|
nat
|
||||||
* > No, not nat, but
|
> No, not nat, but
|
||||||
* natt
|
natt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -188,16 +178,15 @@ since their forms are independent of the noun; the noun is just inflected in
|
|||||||
the plural indefinite. This is with the exception of "one", whose form depends
|
the plural indefinite. This is with the exception of "one", whose form depends
|
||||||
on the gender of the noun. Here is a quick way to generate the numerals from 1 to 9:
|
on the gender of the noun. Here is a quick way to generate the numerals from 1 to 9:
|
||||||
```
|
```
|
||||||
> gt -cat=Sub10 -number=9 | l
|
> gt -cat=Sub10 -number=9 | l -lang=LangEng,LangSwe
|
||||||
> gt -cat=Sub10 -number=9 | l -lang=LangSwe
|
|
||||||
* en
|
* en
|
||||||
* två
|
* två
|
||||||
* tre
|
* tre
|
||||||
* fyra
|
* fyra
|
||||||
* fem
|
* fem
|
||||||
* sex
|
* sex
|
||||||
* sju
|
* sju
|
||||||
* åtta
|
* åtta
|
||||||
* nio
|
* nio
|
||||||
```
|
```
|
||||||
Translate digits to Swedish numerals; the largest one that can be translated is 999,999:
|
Translate digits to Swedish numerals; the largest one that can be translated is 999,999:
|
||||||
@@ -211,10 +200,10 @@ Translate noun phrases with numerals and nouns:
|
|||||||
* en pojke
|
* en pojke
|
||||||
|
|
||||||
> %translate "one apple"
|
> %translate "one apple"
|
||||||
* ett äpple
|
* ett äpple
|
||||||
|
|
||||||
> %translate "two boys"
|
> %translate "two boys"
|
||||||
* två pojkar
|
* två pojkar
|
||||||
|
|
||||||
> %translate "eleven cars"
|
> %translate "eleven cars"
|
||||||
* elva bilar
|
* elva bilar
|
||||||
@@ -229,9 +218,9 @@ articles:
|
|||||||
> %translate "a man, a woman, a car and a house"
|
> %translate "a man, a woman, a car and a house"
|
||||||
* en man , en kvinna , en bil och ett hus
|
* en man , en kvinna , en bil och ett hus
|
||||||
```
|
```
|
||||||
Definite articles are more special in Swedish:
|
Here are examples with definite articles.
|
||||||
they are expressed by inflecting the noun rather than adding a word like
|
#SWE In Swedish, they are expressed by inflecting the noun
|
||||||
English //the//. #SWE
|
#SWE rather than adding a word like English //the//.
|
||||||
```
|
```
|
||||||
> %translate "the man, the woman, the car and the house"
|
> %translate "the man, the woman, the car and the house"
|
||||||
* mannen , kvinnan , bilen och huset
|
* mannen , kvinnan , bilen och huset
|
||||||
@@ -239,39 +228,41 @@ English //the//. #SWE
|
|||||||
This is similar in the plural:
|
This is similar in the plural:
|
||||||
```
|
```
|
||||||
> %translate "the men, the women, the cars and the houses"
|
> %translate "the men, the women, the cars and the houses"
|
||||||
* männen , kvinnorna , bilarna och husen
|
* männen , kvinnorna , bilarna och husen
|
||||||
```
|
```
|
||||||
Just like in English, there is no explicit indefinite article in the plural:
|
The indefinite forms in plural look as follows.
|
||||||
just use the plural indefinite form. #SWE
|
#SWE Just like in English, there is no explicit indefinite article
|
||||||
|
#SWE in the plural: just use the plural indefinite form.
|
||||||
```
|
```
|
||||||
> %translate "men, women, cars and houses"
|
> %translate "men, women, cars and houses"
|
||||||
* män , kvinnor , bilar och hus
|
* män , kvinnor , bilar och hus
|
||||||
```
|
```
|
||||||
Other common determiners are shown in the following:
|
Other common determiners are shown in the following:
|
||||||
```
|
```
|
||||||
> %translate "this car, that car, these cars, those cars, some cars and all cars"
|
> %translate "this car, that car, these cars, those cars, some cars and all cars"
|
||||||
* den här bilen , den där bilen , de här bilarna , de där bilarna , några bilar och alla bilar
|
* den här bilen , den där bilen , de här bilarna , de där bilarna , några bilar och alla bilar
|
||||||
|
|
||||||
```
|
```
|
||||||
Generate more examples of nouns with determiners:
|
Generate more examples of nouns with determiners:
|
||||||
```
|
```
|
||||||
> gr -number=11 (DetCN ? (UseN ?)) | l
|
> gr -number=11 (UttNP (DetCN ? (UseN ?))) | l -lang=LangEng,LangSwe
|
||||||
* much reason
|
* much reason
|
||||||
* mycket anledning
|
* mycket anledning
|
||||||
*
|
*
|
||||||
* few grammars
|
* few grammars
|
||||||
* få grammatiker
|
* få grammatiker
|
||||||
*
|
*
|
||||||
* some teacher
|
* some teacher
|
||||||
* någon lärare
|
* någon lärare
|
||||||
```
|
```
|
||||||
You will find out that other determiners can combine with numerals, such as in
|
You will find out that other determiners can combine with numerals, such as in
|
||||||
```
|
```
|
||||||
> %translate "these seven sisters"
|
> %translate "these seven sisters"
|
||||||
* de här sju systrarna
|
* de här sju systrarna
|
||||||
```
|
|
||||||
In these cases, the definite article suddenly appears as a word: #SWE
|
|
||||||
```
|
|
||||||
> %translate "the seven sisters"
|
> %translate "the seven sisters"
|
||||||
* de sju systrarna
|
* de sju systrarna
|
||||||
```
|
```
|
||||||
|
#SWE thus with a numeral, the definite article suddenly appears as a word.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ loop opts gfenv0 = do
|
|||||||
-- special commands, requiring source grammar in env
|
-- special commands, requiring source grammar in env
|
||||||
|
|
||||||
case pwords of
|
case pwords of
|
||||||
|
{-
|
||||||
|
"eh":w:_ -> do
|
||||||
|
cs <- readFile w >>= return . map words . lines
|
||||||
|
gfenv' <- foldM (flip (process False benv)) gfenv cs
|
||||||
|
loopNewCPU gfenv'
|
||||||
|
-}
|
||||||
|
|
||||||
"q":_ -> ifv (putStrLn "See you.") >> return gfenv
|
"q":_ -> ifv (putStrLn "See you.") >> return gfenv
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user