summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-04-12 20:10:48 +0000
committeraarne <aarne@chalmers.se>2010-04-12 20:10:48 +0000
commit0b224424a6ea4bbcd68830599e863d3e0b922424 (patch)
treeb57ad36db94cc15cc66bdbfc0e2ec65932934cb5 /examples
parent24d2acf097b029abf1cba87d3debc6488534c88f (diff)
a module to compile Phrasebook in different lang combinations
Diffstat (limited to 'examples')
-rw-r--r--examples/phrasebook/Compile.hs38
-rw-r--r--examples/phrasebook/Makefile18
-rw-r--r--examples/phrasebook/Words.gf3
-rw-r--r--examples/phrasebook/WordsFin.gf24
4 files changed, 63 insertions, 20 deletions
diff --git a/examples/phrasebook/Compile.hs b/examples/phrasebook/Compile.hs
new file mode 100644
index 000000000..9f8dd391f
--- /dev/null
+++ b/examples/phrasebook/Compile.hs
@@ -0,0 +1,38 @@
+import List
+import System
+
+-- (c) Aarne Ranta 2010 under GNU LGPL
+
+-- Compile files into pgf, in chosen combinations.
+
+-- Usage: runghc Compile (-make | -link)? Eng Fre Fin ...
+-- The -make option links all pgf files to one in the end
+-- The -link option only links, without first compiling
+-- Arguments whose length are 3 characters are prefixed with mainmodu.
+-- Other arguments are passed literally.
+
+-- Thus, for instance, to produce an English-Swedish-Romanian phrasebook with English
+-- disambiguation, the command is
+--
+-- runghc Compile -link Eng Swe Ron DisambPhrasebookEng
+
+
+-- change this to apply to another project; alternatively, just use full file names
+mainmodu = "Phrasebook"
+
+main = do
+ (opts,langs) <- getArgs >>= return . partition ((=='-') . head)
+ let modus = [mkFile la | la <- langs]
+ putStrLn $ unwords modus
+ if notElem "-link" opts
+ then mapM_ compileOne modus >> return ()
+ else return ()
+ case opts of
+ _ | elem "-make" opts || elem "makeonly" opts -> do
+ system $ "gf -make " ++ unwords (map (++ ".pgf") modus)
+ return ()
+ _ -> return ()
+
+compileOne modu = system $ "gf -make -name=" ++ modu ++ " " ++ modu ++ ".gf"
+
+mkFile la = if length la == 3 then mainmodu ++ la else la
diff --git a/examples/phrasebook/Makefile b/examples/phrasebook/Makefile
index ee9d1e132..b07ab91ef 100644
--- a/examples/phrasebook/Makefile
+++ b/examples/phrasebook/Makefile
@@ -1,19 +1,23 @@
+compile = runghc Compile
+
all: demo missing
demo:
- gf -make PhrasebookEng.gf PhrasebookFin.gf PhrasebookFre.gf PhrasebookGer.gf PhrasebookIta.gf PhrasebookRon.gf PhrasebookSwe.gf DisambPhrasebookEng.gf
-#DisambPhrasebookRon.gf
+ $(compile) Eng Fre Ger Ita Ron Swe
+ $(compile) -link Eng Fin Fre Ger Ita Ron Swe DisambPhrasebookEng
+
+#separate, because slow...
+fin:
+ $(compile) Fin
-pgf:
- gf -make Phrasebook???.gf DisambPhrasebookEng.gf
+pgfs:
+ $(compile) Bul Cat Dan Dut Eng Fin Fre Ger Ita Nor Pol Ron Rus Spa Swe
koe:
- gf -make PhrasebookEng.gf PhrasebookFre.gf DisambPhrasebookEng.gf
+ $(compile) Eng Fre DisambPhrasebookEng
missing:
echo "pg -missing | wf -file=missing.txt" | gf Phrasebook.pgf
-#PhrasebookBul.gf PhrasebookCat.gf PhrasebookDan.gf PhrasebookDut.gf PhrasebookNor.gf PhrasebookPol.gf PhrasebookRus.gf PhrasebookSpa.gf
-
doc:
cat Sentences.gf Words.gf >Ontology.gf
diff --git a/examples/phrasebook/Words.gf b/examples/phrasebook/Words.gf
index aaafb1037..f595eac84 100644
--- a/examples/phrasebook/Words.gf
+++ b/examples/phrasebook/Words.gf
@@ -99,7 +99,8 @@ abstract Words = Sentences ** {
AWant : Person -> Object -> Action ; -- I want two beers
AWantGo : Person -> Place -> Action ; -- I want to go to the hospital
--- miscellaneous phrases
+-- Miscellaneous phrases. Notice that also negations and questions can be formed from
+-- propositions.
QWhatAge : Person -> Question ; -- how many years are you
QWhatName : Person -> Question ; -- what is your name
diff --git a/examples/phrasebook/WordsFin.gf b/examples/phrasebook/WordsFin.gf
index d779859ef..6be95ba29 100644
--- a/examples/phrasebook/WordsFin.gf
+++ b/examples/phrasebook/WordsFin.gf
@@ -84,17 +84,9 @@ concrete WordsFin of Words = SentencesFin **
AHasAge p num = mkCl p.name (mkNP num L.year_N) ;
AHasChildren p num = mkCl p.name have_V2 (mkNP num L.child_N) ;
AHasName p name = mkCl (nameOf p) name ;
- AHasRoom p num = mkCl p.name have_V2
----- (mkNP (E.PartCN (mkN "huone")) ---- partitive works in questions
- (mkNP (mkNP a_Det (mkN "huone"))
- (SyntaxFin.mkAdv for_Prep (mkNP num (mkN "henki" "henkiä")))) ;
- AHasTable p num = mkCl p.name have_V2
----- (mkNP (E.PartCN (mkN "pöytä"))
- (mkNP (mkNP a_Det (mkN "pöytä"))
- (SyntaxFin.mkAdv for_Prep (mkNP num (mkN "henki" "henkiä")))) ;
-
-
- AHungry p = mkCl p.name have_V2 (mkNP (mkN "nälkä")) ;
+ AHasRoom p = haveForPerson p.name (mkCN (mkN "huone")) ;
+ AHasTable p = haveForPerson p.name (mkCN (mkN "pöytä")) ;
+ AHungry p = E.AdvExistNP (SyntaxFin.mkAdv on_Prep p.name) (mkNP (mkN "nälkä")) ;
AIll p = mkCl p.name (mkA "sairas") ;
AKnow p = mkCl p.name (mkV "tietää") ;
ALike p item = mkCl p.name L.like_V2 item ;
@@ -104,7 +96,7 @@ concrete WordsFin of Words = SentencesFin **
AReady p = mkCl p.name (ParadigmsFin.mkA "valmis") ;
AScared p = mkCl p.name (caseV partitive (mkV "pelottaa")) ;
ASpeak p lang = mkCl p.name (mkV2 (mkV "puhua") partitive) lang ;
- AThirsty p = mkCl p.name have_V2 (mkNP (mkN "jano")) ;
+ AThirsty p = E.AdvExistNP (SyntaxFin.mkAdv on_Prep p.name) (mkNP (mkN "jano")) ;
ATired p = mkCl p.name (caseV partitive (mkV "väsyttää")) ;
AUnderstand p = mkCl p.name (mkV "ymmärtää") ;
AWant p obj = mkCl p.name (mkV2 "haluta") obj ;
@@ -184,6 +176,14 @@ concrete WordsFin of Words = SentencesFin **
nameOf : NPPerson -> NP = \p -> (xOf sing L.name_N p).name ;
+ oper
+ -- do you have a table for five persons
+ haveForPerson : NP -> CN -> Card -> Cl = \p,a,n ->
+ mkCl p have_V2
+---- (mkNP (E.PartCN a) ---- partitive works in questions
+ (mkNP (mkNP a_Det a)
+ (SyntaxFin.mkAdv for_Prep (mkNP n (mkN "henki" "henkiä")))) ;
+
open_Adv = ParadigmsFin.mkAdv "avoinna" ;
closed_Adv = ParadigmsFin.mkAdv "kiinni" ;