copied examples/app to examples/slowApp; the new app is a bit scaled down but much faster

This commit is contained in:
aarne
2015-06-02 12:59:29 +00:00
parent d723babc2c
commit 2529f87942
44 changed files with 66045 additions and 31 deletions

View File

@@ -1,11 +1,15 @@
abstract App =
Translate - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -28,10 +32,14 @@ fun
PhrasePhr : Phrase -> Phr ;
Phrase_Chunk : Phrase -> Chunk ;
ComplV2 : V2 -> NP -> VP ;
{-
ComplV2V : V2V -> NP -> VP -> VP ;
ComplV2A : V2A -> NP -> AP -> VP ;
ComplV2Q : V2Q -> NP -> QS -> VP ;
ComplV2S : V2S -> NP -> S -> VP ;
ComplV3 : V3 -> NP -> NP -> VP ;
-}
}

View File

@@ -4,11 +4,13 @@ concrete AppBul of App =
TranslateBul - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -44,4 +46,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -5,11 +5,13 @@ concrete AppCat of App =
TranslateCat - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -44,4 +46,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppChi of App =
TranslateChi - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -45,4 +47,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppDut of App =
TranslateDut - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -43,4 +45,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppEng of App =
TranslateEng - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -42,4 +44,7 @@ lin
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppFin of App =
TranslateFin - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -43,4 +45,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -1,14 +1,15 @@
--# -path=.:../../lib/src/chunk:../../lib/src/translator:../phrasebook/gfos
concrete AppFre of App =
TranslateFre - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -20,8 +21,6 @@ concrete AppFre of App =
-- Construction
-- Extensions
]
,PhrasebookFre - [PSentence, PQuestion, PGreetingMale, PGreetingFemale, GObjectPlease, open_A, closed_A]
** open ParadigmsFre, SyntaxFre, Prelude in {
@@ -37,11 +36,16 @@ lin
PhrasePhr p = {s = "+" ++ p.s} | p ;
Phrase_Chunk p = p ;
ComplV2 v np = mkVP v np ;
{-
ComplV2V v np vp = mkVP v np vp ;
ComplV2A v np vp = mkVP v np vp ;
ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
-}
ComplV2 v np = mkVP v np ;
}

BIN
examples/app/AppFre.pgf Normal file

Binary file not shown.

View File

@@ -1,68 +0,0 @@
--# -path=.:../../lib/src/chunk:../../lib/src/translator:../phrasebook/gfos
concrete AppFreInput of App =
{-
TranslateFre - [
---- SlashVP, SlashVS, ---- expensive functions in Fre
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
-- Question
ComplSlashIP,AdvQVP,AddAdvQVP,QuestQVP,
-- Idiom
CleftNP, CleftAdv,
ImpP3
-- Construction
-- Extensions
]
-}
NounFre - [PPartNP],
AdjectiveFre,
VerbFre [UseV,CompAP,CompAdv,UseComp,AdvVP,SlashV2a,ComplSlash],
SentenceFre [PredVP,UseCl],
QuestionFre - [QuestCl,QuestIAdv,ComplSlashIP,AdvQVP,AddAdvQVP,QuestQVP],
ConjunctionFre,
ConstructionFre,
TranslateFre [QuestCl,QuestIAdv],
IdiomFre - [CleftNP, CleftAdv,ImpP3],
TenseFre,
PhraseFre,
AdverbFre,
NumeralFre,
DocumentationFre,
SymbolFre [
PN, Symb, String, CN, Card, NP, MkSymb, SymbPN, CNNumNP
],
DictionaryFre,
ChunkFre
,PhrasebookFre - [PSentence, PQuestion, PGreetingMale, PGreetingFemale, GObjectPlease, open_A, closed_A]
** open ParadigmsFre, SyntaxFre, Prelude in {
flags
literal=Symb ;
lin
PSentence, PQuestion = \s -> lin Text (mkUtt s) ;
PGreetingMale, PGreetingFemale = \s -> lin Text s ;
GObjectPlease o = lin Text (mkUtt o) ;
PhrasePhr p = {s = "+" ++ p.s} | p ;
Phrase_Chunk p = p ;
{-
ComplV2V v np vp = mkVP v np vp ;
ComplV2A v np vp = mkVP v np vp ;
ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
-}
}

View File

@@ -4,11 +4,13 @@ concrete AppGer of App =
TranslateGer - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -43,4 +45,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppHin of App =
TranslateHin - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -43,4 +45,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppIta of App =
TranslateIta - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -42,4 +44,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppJpn of App =
TranslateJpn - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -45,4 +47,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -5,11 +5,13 @@ concrete AppSpa of App =
TranslateSpa - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -44,4 +46,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -3,11 +3,13 @@
concrete AppSwe of App =
TranslateSwe - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -42,4 +44,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -4,11 +4,13 @@ concrete AppTha of App =
TranslateTha - [
-- Verb
SlashV2V, -- replaced by more efficient inlined versions
SlashV2a,ComplSlash, -- replaced by a more efficient inlined version
SlashV2V,
Slash2V3, Slash3V3, SlashV2S, SlashV2Q, SlashV2A,
SlashVV, SlashV2VNP,
AdvVPSlash, AdVVPSlash, VPSlashPrep,
-- Sentence
SlashVP, SlashVS,
PredSCVP,
AdvSlash, SlashPrep, SlashVS,
EmbedS, EmbedQS, EmbedVP, RelS,
@@ -45,4 +47,7 @@ ComplV2Q v np vp = mkVP v np vp ;
ComplV2S v np vp = mkVP v np vp ;
ComplV3 v np vp = mkVP v np vp ;
ComplV2 v np = mkVP v np ;
}

View File

@@ -14,7 +14,7 @@ GFMKT=mkdir -p $(GFODIR) && gf $S -make -literal=PN,Symb -probs=$(PROBSFILE) -gf
APP11=AppEng.pgf AppBul.pgf AppChi.pgf AppGer.pgf AppSwe.pgf AppHin.pgf AppFin.pgf AppFre.pgf AppIta.pgf AppSpa.pgf AppDut.pgf
APP12=$(APP11) AppCat.pgf
APP13=$(APP12) AppJpn.pgf
APP14=$(APP13) AppTha.pgf AppFreInput.pgf
APP14=$(APP13) AppTha.pgf
# With dependencies:
App11.pgf: $(APP11)
@@ -46,7 +46,6 @@ AppFin.pgf:: ; $(GFMKT) -name=AppFin AppFin.gf +RTS -K64M
AppGer.pgf:: ; $(GFMKT) -name=AppGer AppGer.gf +RTS -K64M
AppHin.pgf:: ; $(GFMKT) -name=AppHin AppHin.gf
AppFre.pgf:: ; $(GFMKT) -name=AppFre AppFre.gf +RTS -K64M
AppFreInput.pgf:: ; $(GFMKT) -name=AppFreInput AppFreInput.gf +RTS -K64M
AppIta.pgf:: ; $(GFMKT) -name=AppIta AppIta.gf +RTS -K64M
AppJpn.pgf:: ; $(GFMKT) -name=AppJpn AppJpn.gf +RTS -K64M
AppSpa.pgf:: ; $(GFMKT) -name=AppSpa AppSpa.gf +RTS -K64M

View File

@@ -1,7 +0,0 @@
P=../phrasebook
L=../../lib/src
GFPATH=$L/chunk:$L/translator:$L/finnish/stemmed:$L/finnish:$P
J=-j +RTS -N4 -A20M -RTS
App.pgf::
gf -s -make $J -probs=./app.probs -path=$(GFPATH) -gfo-dir gfo App???.gf

View File

@@ -1,54 +0,0 @@
module MissApp where
import qualified Data.Set as S
import qualified Data.Map as M
import Data.Char
-- prerequisite: pg -missing | wf -file=missing-app.txt
missFile = "missing-app.txt"
allLangs = words "AppBul AppCat AppChi AppDut AppEng AppFin AppFre AppGer AppHin AppIta AppSpa AppSwe"
type Lang = String
type Fun = String
type MissMap = M.Map Lang (S.Set Fun)
getMissMap :: FilePath -> IO MissMap
getMissMap file = do
ms <- readFile file >>= return . map words . lines
return $ M.fromList [(lang,S.fromList ws) | lang:":":ws <- ms]
ifMiss :: MissMap -> Lang -> Fun -> Bool
ifMiss mm lang fun = case M.lookup lang mm of
Just ws -> S.member fun ws
_ -> error $ "language not found: " ++ lang
allMissLangs :: MissMap -> Fun -> [Lang]
allMissLangs mm fun = [l | l <- allLangs, ifMiss mm l fun]
allMissFuns :: MissMap -> Lang -> [Fun]
allMissFuns mm lang = maybe [] S.toList $ M.lookup lang mm
isSyntaxFun :: Fun -> Bool
isSyntaxFun (f:un) = isUpper f && any isUpper un -- the latter to exclude Phrasebook
allMissingSyntaxFuns :: MissMap -> [(Lang,[Fun])]
allMissingSyntaxFuns mm = [(l,takeWhile isSyntaxFun $ allMissFuns mm l) | l <- allLangs] -- takeWhile works on the sorted list
allMissingSuchFuns :: MissMap -> (Fun -> Bool) -> [(Lang,[Fun])]
allMissingSuchFuns mm f = [(l,filter f $ allMissFuns mm l) | l <- allLangs]
allMissingThoseFuns :: MissMap -> [Fun] -> [(Lang,[Fun])]
allMissingThoseFuns mm fs = let s = S.fromList fs in allMissingSuchFuns mm (flip S.member s)
parts :: Fun -> [String]
parts f = words (map (\c -> if c =='_' then ' ' else c) f)
catOf :: Fun -> String
catOf = last . parts
prepareMissing :: MissMap -> Lang -> String -> IO ()
prepareMissing mm lang cat = putStrLn $ unlines
[ "lin " ++ p ++ " = mk" ++ cat ++ " \"\" ;"| (l,ps) <- allMissingSuchFuns mm (\f -> catOf f == cat), l == lang, p <- ps]

View File

@@ -1,9 +1,9 @@
-- update the import list of every language
-- although possibly some extra definitions at the end
-- the new files are produced in ./tmp/
-- the new files are produced in ./tmp/ which has to be created first
-- usage: runghc MkApp.hs
langs = words "Bul Cat Chi Dut Eng Fin Fre Ger Hin Ita Spa Swe"
langs = words "Bul Cat Chi Dut Eng Fin Fre Ger Hin Ita Jpn Spa Swe Tha"
appCnc lang = "App" ++ lang ++ ".gf"
appAbs = "App.gf"
@@ -26,10 +26,6 @@ extraLines = -- [] -- default: no extra
[
"",
"ComplV2V v np vp = mkVP v np vp ;",
"ComplV2A v np vp = mkVP v np vp ;",
"ComplV2Q v np vp = mkVP v np vp ;",
"ComplV2S v np vp = mkVP v np vp ;",
"ComplV3 v np vp = mkVP v np vp ;",
"ComplV2 v np = mkVP v np ;",
""
]

View File

@@ -1,36 +0,0 @@
Grammar for coloured translation app.
(c) Aarne Ranta 2014 under GPL. Last modified 6/5/2014.
1. Make sure you have the latest RGL compiled and available. Test this for instance in GF shell by typing
import alltenses/LangEng.gfo
2. Check that you have the following file structure, which holds in the standard GF
repository (darcs or github):
GF/lib/src/translator -- the translator extensions of RGL
GF/lib/src/german -- German RGL sources, needed for DictGer (morphological Dict)
GF/lib/src/finnish -- Finnish RGL sources, needed for StemFin
GF/lib/src/finnish/stemmed -- StemFin, a special file for compact Finnish runtime
GF/lib/src/api -- Syntax sources
GF/lib/src/chunk -- Chunk sources
GF/examples/phrasebook -- Phrasebook sources
GF/examples/app -- App sources (this directory)
3. Do 'make' and take a cup of coffee. If you have multiple cores, do first 'make Phrasebook' and then 'make -j App11.pgf' and take an espresso.
4. Go to GF/src/ui/android and follow the README
5. Before the final 'ant debug install', do the following:
cd assets/
rm *pgf*
cp -p <Your-GF>/examples/app/App11.pgf .
gf -make -split-pgf App11.pgf +RTS -K200M
rm App11.pgf
cd ..
ant debug install
Removing superfluous pgf files is recommended, because otherwise they will be copied to the app and
increase its size unnecessarily.

View File

@@ -58,7 +58,7 @@ ComplVPIVV 1.629348323337908e-4
ComplVQ 3.3840311330864245e-4
ComplVS 0.10664084776246609
ComplVV 6.258577578913727e-2
CompoundN 0.10736547702286556
CompoundN 0.010736547702286556
ConjAP 2.1189670416781e-3
ConjAdV 9.744689144416293e-5
ConjAdv 1.0922898208991453e-3

4
examples/app/fre.tmp Normal file
View File

@@ -0,0 +1,4 @@
je suis ici
ma femme est allée a Nice
où est la voiture
personne ne vous aime