diff --git a/contrib/summerschool/foods/LexFoodsGer.gf b/contrib/summerschool/foods/LexFoodsGer.gf index 8ea3afc42..a420e22d3 100644 --- a/contrib/summerschool/foods/LexFoodsGer.gf +++ b/contrib/summerschool/foods/LexFoodsGer.gf @@ -5,7 +5,7 @@ instance LexFoodsGer of LexFoods = oper wine_N = mkN "Wein" ; pizza_N = mkN "Pizza" "Pizzen" feminine ; - cheese_N = mkN "Käse" "Käsen" masculine ; + cheese_N = mkN "Käse" "Käse" masculine ; fish_N = mkN "Fisch" ; fresh_A = mkA "frisch" ; warm_A = mkA "warm" "wärmer" "wärmste" ; diff --git a/lib/doc/tour/tour.txt b/lib/doc/tour/tour.txt new file mode 100644 index 000000000..44921b0ae --- /dev/null +++ b/lib/doc/tour/tour.txt @@ -0,0 +1,269 @@ +A Guided Tour of Swedish Grammar +Aarne Ranta + + + +This is an introduction to the basic grammar of Swedish. +It is guided by a computer program that knows the rules of the grammar. +The program has produced the examples shown during the tour. +You can read this document without access to the program, and get an +overview of Swedish grammar rules. +However, really to make use of the knowledge included in the program, +you should try out every rule by itself and also vary the rules in +interaction with the computer. + +You can make the same tour, with appropriate modifications, with +Bulgarian +Catalan +Dutch +Finnish +French +German + + +=Computer prerequisites= + +To use the Swedish grammar program and test the grammar yourself, you need +- a computer with Linux, Mac OS, or Windows +- the program GF (Grammatical Framework), downloadable from + the [GF website http://grammaticalframework.org] +- the grammar package ``Lang.pgf``, downloadable from [here ./Lang.pgf] + + +In future, we plan to provide a web-based version of this grammar tour, +so that you can ran the program without downloading or installing anything. + +After installing GF (see instructions at GF website), just start it by +the shell command +``` + gf Lang.pgf +``` +Then initialize the shell with a couple of handy commands: + +| ``%translate`` | translate an utterance from English to Swedish | +| ``%table`` | show the inflection table a word or a phrase in Swedish +| ``%forms`` | show the forms of a word or a phrase in Swedish + +Initialization is made with the following commands, which define command macros in GF: +``` +> dc translate ps -lextext ?0 | parse -cat=Utt -lang=LangEng | linearize -lang=LangSwe +> dc table linearize -table -lang=LangSwe ?0 +> dc forms linearize -list -lang=LangSwe ?0 +> dc numeral ps -chars "123" | p -cat=Digits -lang=LangSwe | pt -transfer=digits2num | l -lang=LangSwe +``` +This is just to save you some work afterwards and to make this document +clearer; you could quite as well use the basic commands that are predifined +in GF, and for some less frequent cases we'll actually use them directly. + +The **prompt** sign ``>`` is produced by GF, and you should only +write what is after it. In this document, we will use two kinds of markings +of type-written lines: +- ``>`` followed by a command you type +- ``*`` followed by output from GF + + +=Words and inflection= + +We are ready to start the tour. We begin in the same way as grammar books usually do: +from words and their forms. + + +==Nouns== + +Nouns in Swedish have 8 #Swe +inflection forms, as shown by the following example: +``` +> %table flower_N +* s Sg Indef Nom : blomma +* s Sg Indef Gen : blommas +* s Sg Def Nom : blomman +* s Sg Def Gen : blommans +* s Pl Indef Nom : blommor +* s Pl Indef Gen : blommors +* s Pl Def Nom : blommorna +* s Pl Def Gen : blommornas +``` +Here are the main noun inflection patterns - the +declensions 1 to 5: #SWE +``` +> %forms flower_N +* blomma, blommas, blomman, blommans, blommor, blommors, blommorna, blommornas + +> %forms car_N +* bil, bils, bilen, bilens, bilar, bilars, bilarna, bilarnas + +> %forms cat_N +* katt, katts, katten, kattens, katter, katters, katterna, katternas + +> %forms apple_N +* äpple, äpples, äpplet, äpplets, äpplen, äpplens, äpplena, äpplenas + +> %forms house_N +* hus, hus, huset, husets, hus, hus, husen, husens +``` +The symbol ``N`` is used by GF to denote nouns. Here it is suffixed to +English words meaning the same as the Swedish forms. + +Swedish nouns also have a gender, which is reflected, among +other things, in the indefinite article they have: +``` +> %translate "a man" +* en man + +> %translate "a woman" +* en kvinna + +> %translate "a house" +* ett hus +``` +The little lexicon of the grammar training program has 182 nouns. To see +them all, together with their inflection forms and English translations, +you can do +``` +> generate_trees -cat=N | linearize -treebank -list -lang=LangSwe + +* airplane_N +* flygplan, flygplans, flygplanet, flygplanets, flygplan, flygplans, flygplanen, flygplanens + +* animal_N +* djur, djurs, djuret, djurets, djur, djurs, djuren, djurens +``` + +===Quizzes with nouns=== + +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 +other parts of speech, just changing the symbol ``N`` to some other symbol. +``` +> morpho_quiz -cat=N -lang=LangSwe + +* Welcome to GF Morphology Quiz. +* The quiz is over when you have done at least 10 examples +* with at least 75 % success. +* 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 +quiz for increasing your Swedish skills over and over again. + +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 +language to any other one). Here is how it goes: +``` +> tq -from=LangEng -to=LangSwe -cat=N +* Welcome to GF Translation Quiz. +* The quiz is over when you have done at least 10 examples +* with at least 75 % success. +* You can interrupt the quiz by entering a line consisting of a dot ('.'). +* +* ceiling +* tak +* > Yes. +* Score 1/1 +* night +* nat +* > No, not nat, but +* natt +``` + + +==Numerals and determiners== + +Numerals are in Swedish the easiest way to build complex noun phrases from nouns, +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 +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=LangSwe +* en +* två +* tre +* fyra +* fem +* sex +* sju +* åtta +* nio +``` +Translate digits to Swedish numerals: +``` +> %numeral "123" +* ett hundra tjugo tre +``` +Translate noun phrases with numerals and nouns: +``` +> %translate "one boy" +* en pojke + +> %translate "one apple" +* ett äpple + +> %translate "two boys" +* två pojkar + +> %translate "eleven cars" +* elva bilar +``` +Numerals are a special case of **determiners**: words that are combined with nouns to +form **noun phrases**. Articles are anouther special case; we already saw the indefinite +articles: +``` +> %translate "a man, a woman, a car and a house" +* en man , en kvinna , en bil och ett hus +``` +Definite articles are more special in Swedish: +they are expressed by inflecting the noun rather than adding a word like +English //the//. #SWE +``` +> %translate "the man, the woman, the car and the house" +* mannen , kvinnan , bilen och huset +``` +This is similar in the plural: +``` +> %translate "the men, the women, the cars and the houses" +* männen , kvinnorna , bilarna och husen +``` +Just like in English, there is no explicit indefinite article in the plural: +just use the plural indefinite form. #SWE +``` +> %translate "men, women, cars and houses" +* män , kvinnor , bilar och hus +``` +Other common determiners are shown in the following: +``` +> %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 + +``` +Generate more examples of nouns with determiners: +``` +> gr -number=11 (DetCN ? (UseN ?)) | l +* much reason +* mycket anledning +* +* few grammars +* få grammatiker +* +* some teacher +* någon lärare +``` +You will find out that other determiners can combine with numerals, such as in +``` +> %translate "these seven sisters" +* de här sju systrarna +``` +In these cases, the definite article suddenly appears as a word: #SWE +``` +> %translate "the seven sisters" +* de sju systrarna +``` diff --git a/src/compiler/GFI.hs b/src/compiler/GFI.hs index 4266afa45..2b1d125d9 100644 --- a/src/compiler/GFI.hs +++ b/src/compiler/GFI.hs @@ -130,6 +130,10 @@ loop opts gfenv0 = do writeFile "_gfdepgraph.dot" (depGraph sgr) putStrLn "wrote graph in file _gfdepgraph.dot" loopNewCPU gfenv + "eh":w:_ -> do + cs <- readFile w >>= return . map (interpretCommandLine enc env) . lines + loopNewCPU gfenv + "i":args -> do gfenv' <- case parseOptions args of Ok (opts',files) -> do