mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
a module to compile Phrasebook in different lang combinations
This commit is contained in:
38
examples/phrasebook/Compile.hs
Normal file
38
examples/phrasebook/Compile.hs
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
pgf:
|
||||
gf -make Phrasebook???.gf DisambPhrasebookEng.gf
|
||||
#separate, because slow...
|
||||
fin:
|
||||
$(compile) Fin
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" ;
|
||||
|
||||
|
||||
@@ -16,4 +16,5 @@ abstract ExtraFinAbs = Extra [
|
||||
vai_Conj : Conj ; -- minä vai sinä? ("or" in question)
|
||||
|
||||
CompPartAP : AP -> Comp ; -- kahvi on valmista
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user