diff --git a/examples/phrasebook/Sentences.gf b/examples/phrasebook/Sentences.gf index c5105b079..77baf3785 100644 --- a/examples/phrasebook/Sentences.gf +++ b/examples/phrasebook/Sentences.gf @@ -2,8 +2,10 @@ abstract Sentences = Numeral ** { cat Phrase ; - Sentence ; Question ; Object ; Item ; Kind ; Quality ; - Place ; PlaceKind ; Currency ; Price ; + Sentence ; Question ; + Object ; Item ; Kind ; Quality ; + Place ; PlaceKind ; Currency ; Price ; Language ; + Person ; Action ; fun -- these phrases are formed here, not in Phrasebook, as they are functorial @@ -15,15 +17,17 @@ abstract Sentences = Numeral ** { PPlaceKind: PlaceKind-> Phrase ; PCurrency : Currency -> Phrase ; PPrice : Price -> Phrase ; + PLanguage : Language -> Phrase ; Is : Item -> Quality -> Sentence ; IsNot : Item -> Quality -> Sentence ; - IWant : Object -> Sentence ; - ILike : Item -> Sentence ; - DoYouHave : Kind -> Question ; WhetherIs : Item -> Quality -> Question ; - WhereIs : Place -> Question ; + WhereIs : Place -> Question ; + + SAction : Action -> Sentence ; + SNotAction : Action -> Sentence ; + QAction : Action -> Question ; HowMuchCost : Item -> Question ; ItCost : Item -> Price -> Sentence ; @@ -37,6 +41,8 @@ abstract Sentences = Numeral ** { Very : Quality -> Quality ; Too : Quality -> Quality ; + I, You : Person ; + ThePlace : PlaceKind -> Place ; } diff --git a/examples/phrasebook/SentencesI.gf b/examples/phrasebook/SentencesI.gf index 69d714aa1..235509ec1 100644 --- a/examples/phrasebook/SentencesI.gf +++ b/examples/phrasebook/SentencesI.gf @@ -15,6 +15,9 @@ incomplete concrete SentencesI of Sentences = Numeral ** PlaceKind = CN ; Currency = CN ; Price = NP ; + Action = Cl ; + Person = NP ; + Language = NP ; lin PObject x = mkPhrase (mkUtt x) ; PKind x = mkPhrase (mkUtt x) ; @@ -24,22 +27,23 @@ incomplete concrete SentencesI of Sentences = Numeral ** PPlaceKind x = mkPhrase (mkUtt x) ; PCurrency x = mkPhrase (mkUtt x) ; PPrice x = mkPhrase (mkUtt x) ; + PLanguage x = mkPhrase (mkUtt x) ; Is item quality = mkS (mkCl item quality) ; IsNot item quality = mkS negativePol (mkCl item quality) ; WhetherIs item quality = mkQS (mkQCl (mkCl item quality)) ; WhereIs place = mkQS (mkQCl where_IAdv place) ; - IWant obj = mkS (mkCl (mkNP i_Pron) want_V2 obj) ; - ILike item = mkS (mkCl (mkNP i_Pron) like_V2 item) ; - DoYouHave kind = - mkQS (mkQCl (mkCl (mkNP youPol_Pron) have_V2 (mkNP kind))) ; + + SAction = mkS ; + SNotAction = mkS negativePol ; + QAction a = mkQS (mkQCl a) ; HowMuchCost item = mkQS (mkQCl how8much_IAdv (mkCl item cost_V)) ; ItCost item price = mkS (mkCl item cost_V2 price) ; - AmountCurrency num curr = mkNP curr ; + AmountCurrency num curr = mkNP curr ; ObjItem i = i ; - ObjNumber n k = mkNP k ; + ObjNumber n k = mkNP k ; This kind = mkNP this_Quant kind ; That kind = mkNP that_Quant kind ; @@ -53,6 +57,9 @@ incomplete concrete SentencesI of Sentences = Numeral ** Too quality = mkAP too_AdA quality ; ThePlace kind = mkNP the_Quant kind ; + I = mkNP i_Pron ; + You = mkNP youPol_Pron ; + oper mkPhrase : Utt -> Text = \u -> lin Text u ; -- no punctuation diff --git a/examples/phrasebook/Words.gf b/examples/phrasebook/Words.gf index 2ea910272..12fad7bc8 100644 --- a/examples/phrasebook/Words.gf +++ b/examples/phrasebook/Words.gf @@ -11,4 +11,14 @@ abstract Words = Sentences ** { Euro, Dollar, Lei : Currency ; + English, Finnish, French, Romanian, Swedish : Language ; + +-- actions can be expressed by different structures in different languages + + AWant : Person -> Object -> Action ; + ALike : Person -> Item -> Action ; + AHave : Person -> Kind -> Action ; + ASpeak : Person -> Language -> Action ; + ALove : Person -> Person -> Action ; + } diff --git a/examples/phrasebook/WordsEng.gf b/examples/phrasebook/WordsEng.gf index 6f9400f94..2e94eb4ff 100644 --- a/examples/phrasebook/WordsEng.gf +++ b/examples/phrasebook/WordsEng.gf @@ -1,7 +1,7 @@ -- (c) 2009 Aarne Ranta under LGPL concrete WordsEng of Words = SentencesEng ** - open SyntaxEng, ParadigmsEng in { + open SyntaxEng, ParadigmsEng, IrregEng in { lin Wine = mkCN (mkN "wine") ; Beer = mkCN (mkN "beer") ; @@ -27,4 +27,17 @@ concrete WordsEng of Words = SentencesEng ** Dollar = mkCN (mkN "dollar") ; Lei = mkCN (mkN "leu" "lei") ; + English = mkNP (mkPN "English") ; + Finnish = mkNP (mkPN "Finnish") ; + French = mkNP (mkPN "French") ; + Romanian = mkNP (mkPN "Romanian") ; + Swedish = mkNP (mkPN "Swedish") ; + + AWant p obj = mkCl p (mkV2 (mkV "want")) obj ; + ALike p item = mkCl p (mkV2 (mkV "like")) item ; + AHave p kind = mkCl p have_V2 (mkNP kind) ; + ASpeak p lang = mkCl p (mkV2 IrregEng.speak_V) lang ; + ALove p q = mkCl p (mkV2 (mkV "love")) q ; + + } diff --git a/examples/phrasebook/WordsFin.gf b/examples/phrasebook/WordsFin.gf index 159ad55ad..cb445eadf 100644 --- a/examples/phrasebook/WordsFin.gf +++ b/examples/phrasebook/WordsFin.gf @@ -1,7 +1,7 @@ -- (c) 2009 Aarne Ranta under LGPL concrete WordsFin of Words = SentencesFin ** - open SyntaxFin, ParadigmsFin in { + open SyntaxFin, ParadigmsFin, DiffPhrasebookFin in { lin Wine = mkCN (mkN "viini") ; Beer = mkCN (mkN "olut") ; @@ -31,7 +31,15 @@ concrete WordsFin of Words = SentencesFin ** Dollar = mkCN (mkN "dollari") ; Lei = mkCN (mkN "lei") ; --- oper ---- optimization lasts forever --- mkCNN : Str -> CN = \s -> mkCN (mkN s) ; --- mkAPA : Str -> AP = \s -> mkAP (mkA s) ; + AWant p obj = mkCl p want_V2 obj ; + ALike p item = mkCl item like_V2 p ; + AHave p kind = mkCl p have_V2 (mkNP kind) ; + ASpeak p lang = mkCl p (mkV2 (mkV "puhua") partitive) lang ; + ALove p q = mkCl p (mkV2 (mkV "rakastaa") partitive) q ; + + English = mkNP (mkPN "englanti") ; + Finnish = mkNP (mkPN (mkN "suomi" "suomia")) ; + French = mkNP (mkPN "ranska") ; + Romanian = mkNP (mkPN "romania") ; + Swedish = mkNP (mkPN "ruotsi") ; } diff --git a/examples/phrasebook/WordsFre.gf b/examples/phrasebook/WordsFre.gf index e8a65a3b8..266d0ed6c 100644 --- a/examples/phrasebook/WordsFre.gf +++ b/examples/phrasebook/WordsFre.gf @@ -2,6 +2,8 @@ concrete WordsFre of Words = SentencesFre ** open SyntaxFre, + DiffPhrasebookFre, + IrregFre, ParadigmsFre in { flags coding=utf8 ; @@ -33,6 +35,18 @@ Boring = mkAPA "ennuyeux" ; Dollar = mkCN (mkN "dollar") ; Lei = mkCN (mkN "lei") ; ---- ? + AWant p obj = mkCl p want_V2 obj ; + ALike p item = mkCl item plaire_V2 p ; + AHave p kind = mkCl p have_V2 (mkNP kind) ; + ASpeak p lang = mkCl p (mkV2 (mkV "parler")) lang ; + ALove p q = mkCl p (mkV2 (mkV "aimer")) q ; + + English = mkNP (mkPN "anglais") ; + Finnish = mkNP (mkPN "finnois") ; + French = mkNP (mkPN "français") ; + Romanian = mkNP (mkPN "roumain") ; + Swedish = mkNP (mkPN "suédois") ; + oper mkAPA : (_ : Str) -> AP = \x -> mkAP (mkA x) ; diff --git a/examples/phrasebook/WordsRon.gf b/examples/phrasebook/WordsRon.gf index 616306989..8fb0aad5d 100644 --- a/examples/phrasebook/WordsRon.gf +++ b/examples/phrasebook/WordsRon.gf @@ -2,7 +2,8 @@ concrete WordsRon of Words = SentencesRon ** open SyntaxRon, - ParadigmsRon in + ParadigmsRon, + DiffPhrasebookRon in { flags coding=utf8 ; @@ -33,6 +34,18 @@ Boring = mkAPA "plictisitor" "plictisitoare" "plictisitori" "plictisitoare" ; Dollar = mkCN (mkN "dolar" masculine) ; Lei = mkCN (mkN "leu" "lei") ; + AWant p obj = mkCl p want_V2 obj ; + ALike p item = mkCl item like_V2 p ; + AHave p kind = mkCl p have_V2 (SyntaxRon.mkNP kind) ; + ASpeak p lang = mkCl p (dirV2 (mkV "vorbi")) lang ; + ALove p q = mkCl p (dirV2 (mkV "iubi")) q ; + + English = SyntaxRon.mkNP (mkPN "anglais") ; ---- ? +-- Finnish = mkNP (mkPN "finnois") ; +-- French = mkNP (mkPN "français") ; + Romanian = SyntaxRon.mkNP (mkPN "engleză") ; ---- ? +-- Swedish = mkNP (mkPN "suédois") ; + oper mkAPA : (_,_,_,_ : Str) -> AP = \x,y,z,u -> mkAP (mkA x y z u) ; diff --git a/examples/phrasebook/WordsSwe.gf b/examples/phrasebook/WordsSwe.gf index eee786792..19160d004 100644 --- a/examples/phrasebook/WordsSwe.gf +++ b/examples/phrasebook/WordsSwe.gf @@ -27,4 +27,17 @@ concrete WordsSwe of Words = SentencesSwe ** Dollar = mkCN (mkN "dollar" "dollar") ; Lei = mkCN (mkN "lei" "lei") ; + English = mkNP (mkPN "engelska") ; + Finnish = mkNP (mkPN "finska") ; + French = mkNP (mkPN "franska") ; + Romanian = mkNP (mkPN "rumänska") ; + Swedish = mkNP (mkPN "svenska") ; + + AWant p obj = mkCl p want_VV (mkVP have_V2 obj) ; + ALike p item = mkCl p (mkV2 (mkV "tycker") (mkPrep "om")) item ; + AHave p kind = mkCl p have_V2 (mkNP kind) ; + ASpeak p lang = mkCl p (mkV2 (mkV "tala")) lang ; + ALove p q = mkCl p (mkV2 (mkV "älska")) q ; + + } diff --git a/examples/phrasebook/phrasebook.html b/examples/phrasebook/phrasebook.html new file mode 100644 index 000000000..bad1acc4b --- /dev/null +++ b/examples/phrasebook/phrasebook.html @@ -0,0 +1,120 @@ + + + + +MOLTO Multilingual Phrasebook + +

MOLTO Multilingual Phrasebook

+ +Aarne Ranta
+
+ +

+History +

+
    +
  • Version 0.1, 26 March 2010. Eng, Fin, Fre, Ron; dedicated minibar UI. +
  • Version 0.2, 28 March. Swe; cat Action; small phrases. +
+ +

Purpose

+

+This phrasebook is a programme for translating touristic phrases +between 15 European languages: +

+
    +
  • Bulgarian, Catalan, Danish, Dutch, English, + Finnish, French, German, Italian, Norwegian, + Polish, Romanian, Russian, Spanish, Swedish +
+ +

+It is implemented by using the GF programming language +(Grammatical Framework). +It is the first demo for the MOLTO project +(Multilingual On-Line Translation). +

+

+The phrasebook has the following requirements: +

+
    +
  • high quality: reliable translations +
  • translation from any language to any other ones +
  • runnable in web browsers +
  • runnable on mobile phones (also off-line: forthcoming for Android phones) +
  • easily extensible by new words (forthcoming: semi-automatic extensions by users) +
+ +

+The phrasebook is available as open-source software, licensed under GNU LGPL. +The source code resides in +code.haskell.org/gf/examples/phrasebook/ +

+

+Current status (28 March 2010): +

+
    +
  • available in English, Finnish, French, Romanian, Swedish +
  • very small coverage +
  • works on web browsers calling a server +
  • web service not yet released, but preliminarily available + here +
+ +

Points illustrated

+

+The use of resource grammars and functors. +

+

+Compile-time transfer: especially, in Action in Words. +

+

+Quasi-incremental translation: many basic types are also used as phrases. +

+

+Disambiguation, esp. by the parameters in Roles. +

+

Files

+

+abstract Sentences: general syntactic structures implementable by functor +

+
    +
  • concrete by functor SencencesI +

    +abstract Words: words and predicates, typically language-dependent +
  • concrete separate +

    +abstract Greetings: idiomatic phrases, strings with role dependence +
  • concrete separate +

    +abstract Phrasebook: put everything everything together +
  • concrete separate +

    +resource Roles: param Politeness, Gender +

    +interface DiffPhrasebook: the (so far small) interface for Sentences +
+ +

To Do

+

+Text-based translation interface. +

+

+Access to disambiguation grammars in the interface. +

+

+The remaining 10 languages +

+

+Extract/construct lexica for +

+
    +
  • food stuff +
  • languages +
  • places +
+ + + + + diff --git a/examples/phrasebook/phrasebook.txt b/examples/phrasebook/phrasebook.txt index def5f3457..ba97b80fd 100644 --- a/examples/phrasebook/phrasebook.txt +++ b/examples/phrasebook/phrasebook.txt @@ -2,6 +2,12 @@ MOLTO Multilingual Phrasebook Aarne Ranta +History +- Version 0.1, 26 March 2010. Eng, Fin, Fre, Ron; dedicated minibar UI. +- Version 0.2, 28 March. Swe; cat Action; small phrases. + + + =Purpose= This phrasebook is a programme for translating touristic phrases @@ -37,3 +43,54 @@ Current status (28 March 2010): [here http://tournesol.cs.chalmers.se/~aarne/phrasebook/phrasebook.html] + +=Points illustrated= + +The use of resource grammars and functors. + +Compile-time transfer: especially, in Action in Words. + +Quasi-incremental translation: many basic types are also used as phrases. + +Disambiguation, esp. by the parameters in Roles. + + +=Files= + +abstract Sentences: general syntactic structures implementable by functor +- concrete by functor SencencesI + +abstract Words: words and predicates, typically language-dependent +- concrete separate + +abstract Greetings: idiomatic phrases, strings with role dependence +- concrete separate + +abstract Phrasebook: put everything everything together +- concrete separate + +resource Roles: param Politeness, Gender + +interface DiffPhrasebook: the (so far small) interface for Sentences + + + +=To Do= + +Text-based translation interface. + +Access to disambiguation grammars in the interface. + +The remaining 10 languages + +Extract/construct lexica for +- food stuff +- languages +- places + + + + + + + diff --git a/examples/phrasebook/www/phrasebook.html b/examples/phrasebook/www/phrasebook.html index 7d34a27fa..4e6113bd4 100644 --- a/examples/phrasebook/www/phrasebook.html +++ b/examples/phrasebook/www/phrasebook.html @@ -17,7 +17,9 @@ Based on minibar, powered by -GF +GF, +see +doc. diff --git a/src/runtime/haskell/PGF/Linearize.hs b/src/runtime/haskell/PGF/Linearize.hs index 3dadd1580..058d8281f 100644 --- a/src/runtime/haskell/PGF/Linearize.hs +++ b/src/runtime/haskell/PGF/Linearize.hs @@ -52,7 +52,7 @@ linTree pgf lang mark e = lin0 [] [] [] Nothing e return (listArray (bounds lins) [computeSeq seqid args | seqid <- elems lins]) PCoerce fid -> apply path xs (Just fid) f es Nothing -> mzero - Nothing -> apply path xs mb_fid _V [ELit (LStr "?")] -- function without linearization + Nothing -> apply path xs mb_fid _V [ELit (LStr ("[" ++ showCId f ++ "]"))] -- fun without lin where lookupProds (Just fid) prods = IntMap.lookup fid prods lookupProds Nothing prods