Compare commits
19 Commits
sense-disa
...
remove-exa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69cea20dac | ||
|
|
32ce03dc94 | ||
|
|
8560b4fb65 | ||
|
|
b0c3aef6ec | ||
|
|
a45c735545 | ||
|
|
05c2cfb628 | ||
|
|
69ad1e617e | ||
|
|
eb2774af2b | ||
|
|
9b28d21b0a | ||
|
|
507236fdcd | ||
|
|
397f18a298 | ||
|
|
abf3911b70 | ||
|
|
735f5ff76f | ||
|
|
422248f11f | ||
|
|
d46682bc29 | ||
|
|
8596fc5d26 | ||
|
|
4958aab518 | ||
|
|
0b4d9cbea1 | ||
|
|
1010b9e49a |
2
.ghci
@@ -1,2 +1,2 @@
|
|||||||
:set -isrc/compiler -isrc/binary -isrc/runtime/haskell -isrc/server -isrc/example-based -isrc/server/transfer -idist/build/autogen -idist/build
|
:set -isrc/compiler -isrc/binary -isrc/runtime/haskell -isrc/server -isrc/server/transfer -idist/build/autogen -idist/build
|
||||||
:set -fwarn-unused-imports -optP-DSERVER_MODE -optP-DUSE_INTERRUPT -optP-DCC_LAZY -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build/gf/gf-tmp -hidir dist/build/gf/gf-tmp -stubdir dist/build/gf/gf-tmp
|
:set -fwarn-unused-imports -optP-DSERVER_MODE -optP-DUSE_INTERRUPT -optP-DCC_LAZY -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build/gf/gf-tmp -hidir dist/build/gf/gf-tmp -stubdir dist/build/gf/gf-tmp
|
||||||
|
|||||||
3
.gitignore
vendored
@@ -39,8 +39,7 @@ src/runtime/c/sg/.dirstamp
|
|||||||
src/runtime/c/stamp-h1
|
src/runtime/c/stamp-h1
|
||||||
src/runtime/java/.libs/
|
src/runtime/java/.libs/
|
||||||
src/runtime/python/build/
|
src/runtime/python/build/
|
||||||
src/ui/android/libs/
|
|
||||||
src/ui/android/obj/
|
|
||||||
.cabal-sandbox
|
.cabal-sandbox
|
||||||
cabal.sandbox.config
|
cabal.sandbox.config
|
||||||
|
.stack-work
|
||||||
DATA_DIR
|
DATA_DIR
|
||||||
|
|||||||
19
LICENSE
@@ -8,24 +8,9 @@ other. For this reason the different components have different licenses.
|
|||||||
In summary:
|
In summary:
|
||||||
|
|
||||||
- the GF compiler in the folder src/compiler and the PGF Web service in src/server
|
- the GF compiler in the folder src/compiler and the PGF Web service in src/server
|
||||||
are under the GNU GENERAL PUBLIC LICENSE.
|
are under the GNU GENERAL PUBLIC LICENSE.
|
||||||
|
|
||||||
- the GF runtime in src/runtime is under dual GNU LESSER GENERAL PUBLIC LICENSE
|
- the GF runtime in src/runtime is under dual GNU LESSER GENERAL PUBLIC LICENSE and BSD LICENSE
|
||||||
and BSD LICENSE
|
|
||||||
|
|
||||||
- the resource grammar library in lib/src is under GNU LESSER GENERAL PUBLIC LICENSE.
|
|
||||||
However the user have the right to choose any license for any application grammar
|
|
||||||
derived from the resource grammar by using the grammar API.
|
|
||||||
|
|
||||||
- the resource grammar library also includes large coverage lexicons for some languages.
|
|
||||||
Since these lexicons are derived from external sources they might be under different licenses.
|
|
||||||
Look at the source file for every lexicon for details. The lexicons that we currently have
|
|
||||||
are:
|
|
||||||
|
|
||||||
lib/src/bulgarian/ DictBul.gf DictBulAbs.gf for Bulgarian
|
|
||||||
lib/src/english/ DictEng.gf DictEngAbs.gf for English
|
|
||||||
lib/src/turkish/ DictTur.gf DictTurAbs.gf for Turkish
|
|
||||||
lib/src/swedish/ DictSwe.gf DictSweAbs.gf for Swedish
|
|
||||||
|
|
||||||
The rest of this document contains copies of the GPL, LGPL and BSD licenses
|
The rest of this document contains copies of the GPL, LGPL and BSD licenses
|
||||||
which are applicable to the different components of Grammatical Framework
|
which are applicable to the different components of Grammatical Framework
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ buildWeb gf flags (pkg,lbi) = do
|
|||||||
gf_lib_path = datadir (absoluteInstallDirs pkg lbi dest) </> "lib"
|
gf_lib_path = datadir (absoluteInstallDirs pkg lbi dest) </> "lib"
|
||||||
args = numJobs flags++["-make","-s"] -- ,"-optimize-pgf"
|
args = numJobs flags++["-make","-s"] -- ,"-optimize-pgf"
|
||||||
++["--gfo-dir="++tmp_dir,
|
++["--gfo-dir="++tmp_dir,
|
||||||
"--gf-lib-path="++gf_lib_path,
|
--"--gf-lib-path="++gf_lib_path,
|
||||||
"--name="++dropExtension pgf,
|
"--name="++dropExtension pgf,
|
||||||
"--output-dir="++gfo_dir]
|
"--output-dir="++gfo_dir]
|
||||||
++[dir</>file|file<-src]
|
++[dir</>file|file<-src]
|
||||||
|
|||||||
@@ -67,10 +67,27 @@ fi
|
|||||||
cabal install --only-dependencies -fserver -fc-runtime $extra
|
cabal install --only-dependencies -fserver -fc-runtime $extra
|
||||||
cabal configure --prefix="$prefix" -fserver -fc-runtime $extra
|
cabal configure --prefix="$prefix" -fserver -fc-runtime $extra
|
||||||
DYLD_LIBRARY_PATH="$extralib" LD_LIBRARY_PATH="$extralib" cabal build
|
DYLD_LIBRARY_PATH="$extralib" LD_LIBRARY_PATH="$extralib" cabal build
|
||||||
|
# Building the example grammars will fail, because the RGL is missing
|
||||||
|
cabal copy --destdir="$destdir" # create www directory
|
||||||
|
|
||||||
|
## Build the RGL and copy it to $destdir
|
||||||
|
PATH=$PWD/dist/build/gf:$PATH
|
||||||
|
export GF_LIB_PATH="$(dirname $(find "$destdir" -name www))/lib" # hmm
|
||||||
|
mkdir -p "$GF_LIB_PATH"
|
||||||
|
pushd ../gf-rgl
|
||||||
|
make build
|
||||||
|
make copy
|
||||||
|
popd
|
||||||
|
|
||||||
|
# Build GF again, including example grammars that need the RGL
|
||||||
|
DYLD_LIBRARY_PATH="$extralib" LD_LIBRARY_PATH="$extralib" cabal build
|
||||||
|
|
||||||
|
## Copy GF to $destdir
|
||||||
cabal copy --destdir="$destdir"
|
cabal copy --destdir="$destdir"
|
||||||
libdir=$(dirname $(find "$destdir" -name PGF.hi))
|
libdir=$(dirname $(find "$destdir" -name PGF.hi))
|
||||||
cabal register --gen-pkg-config=$libdir/gf-$ver.conf
|
cabal register --gen-pkg-config=$libdir/gf-$ver.conf
|
||||||
|
|
||||||
|
## Create the binary distribution package
|
||||||
case $fmt in
|
case $fmt in
|
||||||
tar.gz)
|
tar.gz)
|
||||||
targz="$name-bin-$hw-$os.tar.gz" # the final tar file
|
targz="$name-bin-$hw-$os.tar.gz" # the final tar file
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ h1 img.nofloat { float: none; }
|
|||||||
img.right { float: right; }
|
img.right { float: right; }
|
||||||
|
|
||||||
ol.languages {
|
ol.languages {
|
||||||
display: flex;
|
column-width: 12em;
|
||||||
flex-direction: column;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
height: 12em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.grow {
|
.grow {
|
||||||
|
|||||||
@@ -3120,23 +3120,44 @@ a part of the GF grammar compiler.
|
|||||||
<TR>
|
<TR>
|
||||||
<TD><CODE>nonExist</CODE></TD>
|
<TD><CODE>nonExist</CODE></TD>
|
||||||
<TD><CODE>Str</CODE></TD>
|
<TD><CODE>Str</CODE></TD>
|
||||||
<TD>this is a special token marking<BR/>
|
<TD>a special token marking<BR/>
|
||||||
non-existing morphological forms</TD>
|
non-existing morphological forms</TD>
|
||||||
</TR>
|
</TR>
|
||||||
<TR>
|
<TR>
|
||||||
<TD><CODE>BIND</CODE></TD>
|
<TD><CODE>BIND</CODE></TD>
|
||||||
<TD><CODE>Str</CODE></TD>
|
<TD><CODE>Str</CODE></TD>
|
||||||
<TD>this is a special token marking<BR/>
|
<TD>a special token marking<BR/>
|
||||||
that the surrounding tokens should not<BR/>
|
that the surrounding tokens should not<BR/>
|
||||||
be separated by space</TD>
|
be separated by space</TD>
|
||||||
</TR>
|
</TR>
|
||||||
<TR>
|
<TR>
|
||||||
<TD><CODE>SOFT_BIND</CODE></TD>
|
<TD><CODE>SOFT_BIND</CODE></TD>
|
||||||
<TD><CODE>Str</CODE></TD>
|
<TD><CODE>Str</CODE></TD>
|
||||||
<TD>this is a special token marking<BR/>
|
<TD>a special token marking<BR/>
|
||||||
that the surrounding tokens may not<BR/>
|
that the surrounding tokens may not<BR/>
|
||||||
be separated by space</TD>
|
be separated by space</TD>
|
||||||
</TR>
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD><CODE>SOFT_SPACE</CODE></TD>
|
||||||
|
<TD><CODE>Str</CODE></TD>
|
||||||
|
<TD>a special token marking<BR/>
|
||||||
|
that the space between the surrounding tokens<BR/>
|
||||||
|
is optional</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD><CODE>CAPIT</CODE></TD>
|
||||||
|
<TD><CODE>Str</CODE></TD>
|
||||||
|
<TD>a special token marking<BR/>
|
||||||
|
that the first character in the next token<BR/>
|
||||||
|
should be capitalized</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD><CODE>ALL_CAPIT</CODE></TD>
|
||||||
|
<TD><CODE>Str</CODE></TD>
|
||||||
|
<TD>a special token marking<BR/>
|
||||||
|
that the next word should be<BR/>
|
||||||
|
in all capital letters</TD>
|
||||||
|
</TR>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
|
|
||||||
<P></P>
|
<P></P>
|
||||||
|
|||||||
@@ -176,6 +176,11 @@ The above notes for installing from source apply also in these cases.
|
|||||||
For more info on working with the GF source code, see the
|
For more info on working with the GF source code, see the
|
||||||
[GF Developers Guide ../doc/gf-developers.html].
|
[GF Developers Guide ../doc/gf-developers.html].
|
||||||
|
|
||||||
|
==Using Stack==
|
||||||
|
|
||||||
|
You can also use [Stack https://www.haskellstack.org] to compile GF, just replace ``cabal install`` above
|
||||||
|
with ``stack install`` (assuming you already have Stack set up).
|
||||||
|
|
||||||
==Older releases==
|
==Older releases==
|
||||||
|
|
||||||
- [GF 3.8 index-3.8.html] (June 2016)
|
- [GF 3.8 index-3.8.html] (June 2016)
|
||||||
|
|||||||
32
gf.cabal
@@ -1,5 +1,5 @@
|
|||||||
name: gf
|
name: gf
|
||||||
version: 3.9-git
|
version: 3.10
|
||||||
|
|
||||||
cabal-version: >= 1.22
|
cabal-version: >= 1.22
|
||||||
build-type: Custom
|
build-type: Custom
|
||||||
@@ -42,7 +42,7 @@ data-files:
|
|||||||
custom-setup
|
custom-setup
|
||||||
setup-depends:
|
setup-depends:
|
||||||
base,
|
base,
|
||||||
Cabal >=1.4.0.0,
|
Cabal >=1.22.0.0,
|
||||||
directory,
|
directory,
|
||||||
filepath,
|
filepath,
|
||||||
process >=1.0.1.1
|
process >=1.0.1.1
|
||||||
@@ -67,11 +67,6 @@ flag network-uri
|
|||||||
-- Description: Make -new-comp the default
|
-- Description: Make -new-comp the default
|
||||||
-- Default: True
|
-- Default: True
|
||||||
|
|
||||||
flag custom-binary
|
|
||||||
Description: Use a customised version of the binary package
|
|
||||||
Default: True
|
|
||||||
Manual: True
|
|
||||||
|
|
||||||
flag c-runtime
|
flag c-runtime
|
||||||
Description: Include functionality from the C run-time library (which must be installed already)
|
Description: Include functionality from the C run-time library (which must be installed already)
|
||||||
Default: False
|
Default: False
|
||||||
@@ -89,17 +84,14 @@ Library
|
|||||||
exceptions
|
exceptions
|
||||||
hs-source-dirs: src/runtime/haskell
|
hs-source-dirs: src/runtime/haskell
|
||||||
|
|
||||||
if flag(custom-binary)
|
other-modules:
|
||||||
other-modules:
|
-- not really part of GF but I have changed the original binary library
|
||||||
-- not really part of GF but I have changed the original binary library
|
-- and we have to keep the copy for now.
|
||||||
-- and we have to keep the copy for now.
|
Data.Binary
|
||||||
Data.Binary
|
Data.Binary.Put
|
||||||
Data.Binary.Put
|
Data.Binary.Get
|
||||||
Data.Binary.Get
|
Data.Binary.Builder
|
||||||
Data.Binary.Builder
|
Data.Binary.IEEE754
|
||||||
Data.Binary.IEEE754
|
|
||||||
else
|
|
||||||
build-depends: binary, data-binary-ieee754
|
|
||||||
|
|
||||||
--ghc-options: -fwarn-unused-imports
|
--ghc-options: -fwarn-unused-imports
|
||||||
--if impl(ghc>=7.8)
|
--if impl(ghc>=7.8)
|
||||||
@@ -295,9 +287,7 @@ Library
|
|||||||
CGIUtils
|
CGIUtils
|
||||||
Cache
|
Cache
|
||||||
Fold
|
Fold
|
||||||
ExampleDemo
|
hs-source-dirs: src/server src/server/transfer
|
||||||
ExampleService
|
|
||||||
hs-source-dirs: src/server src/server/transfer src/example-based
|
|
||||||
|
|
||||||
if flag(interrupt)
|
if flag(interrupt)
|
||||||
cpp-options: -DUSE_INTERRUPT
|
cpp-options: -DUSE_INTERRUPT
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function sitesearch() {
|
|||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://hackage.haskell.org/package/gf-3.9/docs/PGF.html">PGF library API (Old Runtime)</a>
|
<li><a href="http://hackage.haskell.org/package/gf-3.9/docs/PGF.html">PGF library API (Old Runtime)</a>
|
||||||
<li><a href="doc/runtime-api.html">PGF library API (New Runtime)</a>
|
<li><a href="doc/runtime-api.html">PGF library API (New Runtime)</a>
|
||||||
<li><a href="src/ui/android/README">GF on Android (new)</a>
|
<li><a href="https://github.com/GrammaticalFramework/gf-offline-translator/tree/master/android">GF on Android (new)</a>
|
||||||
<li><A HREF="/android/">GF on Android (old) </A>
|
<li><A HREF="/android/">GF on Android (old) </A>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -373,8 +373,6 @@ optDescr =
|
|||||||
"Enable or disable global grammar optimization. This could significantly reduce the size of the final PGF file",
|
"Enable or disable global grammar optimization. This could significantly reduce the size of the final PGF file",
|
||||||
Option [] ["split-pgf"] (NoArg (splitPGF True))
|
Option [] ["split-pgf"] (NoArg (splitPGF True))
|
||||||
"Split the PGF into one file per language. This allows the runtime to load only individual languages",
|
"Split the PGF into one file per language. This allows the runtime to load only individual languages",
|
||||||
Option [] ["stem"] (onOff (toggleOptimize OptStem) True) "Perform stem-suffix analysis (default on).",
|
|
||||||
Option [] ["cse"] (onOff (toggleOptimize OptCSE) True) "Perform common sub-expression elimination (default on).",
|
|
||||||
Option [] ["cfg"] (ReqArg cfgTransform "TRANS") "Enable or disable specific CFG transformations. TRANS = merge, no-merge, bottomup, no-bottomup, ...",
|
Option [] ["cfg"] (ReqArg cfgTransform "TRANS") "Enable or disable specific CFG transformations. TRANS = merge, no-merge, bottomup, no-bottomup, ...",
|
||||||
Option [] ["heuristic_search_factor"] (ReqArg (readDouble (\d o -> o { optHeuristicFactor = Just d })) "FACTOR") "Set the heuristic search factor for statistical parsing",
|
Option [] ["heuristic_search_factor"] (ReqArg (readDouble (\d o -> o { optHeuristicFactor = Just d })) "FACTOR") "Set the heuristic search factor for statistical parsing",
|
||||||
Option [] ["case_sensitive"] (onOff (\v -> set $ \o -> o{optCaseSensitive=v}) True) "Set the parser in case-sensitive/insensitive mode [sensitive by default]",
|
Option [] ["case_sensitive"] (onOff (\v -> set $ \o -> o{optCaseSensitive=v}) True) "Set the parser in case-sensitive/insensitive mode [sensitive by default]",
|
||||||
@@ -448,8 +446,6 @@ optDescr =
|
|||||||
optimize_pgf x = set $ \o -> o { optOptimizePGF = x }
|
optimize_pgf x = set $ \o -> o { optOptimizePGF = x }
|
||||||
splitPGF x = set $ \o -> o { optSplitPGF = x }
|
splitPGF x = set $ \o -> o { optSplitPGF = x }
|
||||||
|
|
||||||
toggleOptimize x b = set $ setOptimization' x b
|
|
||||||
|
|
||||||
cfgTransform x = let (x', b) = case x of
|
cfgTransform x = let (x', b) = case x of
|
||||||
'n':'o':'-':rest -> (rest, False)
|
'n':'o':'-':rest -> (rest, False)
|
||||||
_ -> (x, True)
|
_ -> (x, True)
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import GF.Infra.UseIO(readBinaryFile,writeBinaryFile,ePutStrLn)
|
|||||||
import GF.Infra.SIO(captureSIO)
|
import GF.Infra.SIO(captureSIO)
|
||||||
import GF.Data.Utilities(apSnd,mapSnd)
|
import GF.Data.Utilities(apSnd,mapSnd)
|
||||||
import qualified PGFService as PS
|
import qualified PGFService as PS
|
||||||
import qualified ExampleService as ES
|
|
||||||
import Data.Version(showVersion)
|
import Data.Version(showVersion)
|
||||||
import Paths_gf(getDataDir,version)
|
import Paths_gf(getDataDir,version)
|
||||||
import GF.Infra.BuildInfo (buildInfo)
|
import GF.Infra.BuildInfo (buildInfo)
|
||||||
@@ -171,7 +170,6 @@ handle logLn documentroot state0 cache execute1 stateVar
|
|||||||
(_ ,_ ,".pgf") -> do --debug $ "PGF service: "++path
|
(_ ,_ ,".pgf") -> do --debug $ "PGF service: "++path
|
||||||
wrapCGI $ PS.cgiMain' cache path
|
wrapCGI $ PS.cgiMain' cache path
|
||||||
(dir,"grammars.cgi",_ ) -> grammarList dir (decoded qs)
|
(dir,"grammars.cgi",_ ) -> grammarList dir (decoded qs)
|
||||||
(dir ,"exb.fcgi" ,_ ) -> wrapCGI $ ES.cgiMain' root dir (PS.pgfCache cache)
|
|
||||||
_ -> serveStaticFile rpath path
|
_ -> serveStaticFile rpath path
|
||||||
where path = translatePath rpath
|
where path = translatePath rpath
|
||||||
_ -> return $ resp400 upath
|
_ -> return $ resp400 upath
|
||||||
@@ -209,7 +207,7 @@ handle logLn documentroot state0 cache execute1 stateVar
|
|||||||
((_,(value,_)):qs1,qs2) -> do put_qs (qs1++qs2)
|
((_,(value,_)):qs1,qs2) -> do put_qs (qs1++qs2)
|
||||||
return value
|
return value
|
||||||
_ -> err $ resp400 $ "no "++field++" in request"
|
_ -> err $ resp400 $ "no "++field++" in request"
|
||||||
|
|
||||||
inDir ok = cd =<< look "dir"
|
inDir ok = cd =<< look "dir"
|
||||||
where
|
where
|
||||||
cd ('/':dir@('t':'m':'p':_)) =
|
cd ('/':dir@('t':'m':'p':_)) =
|
||||||
|
|||||||
@@ -1,553 +0,0 @@
|
|||||||
module ExampleDemo (Environ,initial,getNext, provideExample, testThis,mkFuncWithArg,searchGoodTree,isMeta)
|
|
||||||
where
|
|
||||||
|
|
||||||
import PGF
|
|
||||||
--import System.IO
|
|
||||||
import Data.List
|
|
||||||
--import Control.Monad
|
|
||||||
import qualified Data.Map as Map
|
|
||||||
--import qualified Data.IntMap as IntMap
|
|
||||||
import qualified Data.Set as Set
|
|
||||||
import Data.Maybe
|
|
||||||
--import System.Environment (getArgs)
|
|
||||||
import System.Random (RandomGen) --newStdGen
|
|
||||||
|
|
||||||
|
|
||||||
type MyType = CId -- name of the categories from the program
|
|
||||||
type ConcType = CId -- categories from the resource grammar, that we parse on
|
|
||||||
type MyFunc = CId -- functions that we need to implement
|
|
||||||
--type FuncWithArg = ((MyFunc, MyType), Expr) -- function with arguments
|
|
||||||
type InterInstr = [String] -- lincats that were generated but not written to the file
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data FuncWithArg = FuncWithArg
|
|
||||||
{getName :: MyFunc, -- name of the function to generate
|
|
||||||
getType :: MyType, -- return type of the function
|
|
||||||
getTypeArgs :: [MyType] -- types of arguments
|
|
||||||
}
|
|
||||||
deriving (Show,Eq,Ord)
|
|
||||||
|
|
||||||
-- we assume that it's for English for the moment
|
|
||||||
|
|
||||||
|
|
||||||
type TypeMap = Map.Map MyType ConcType -- mapping found from a file
|
|
||||||
|
|
||||||
type ConcMap = Map.Map MyFunc Expr -- concrete expression after parsing
|
|
||||||
|
|
||||||
data Environ = Env {getTypeMap :: TypeMap, -- mapping between a category in the grammar and a concrete type from RGL
|
|
||||||
getConcMap :: ConcMap, -- concrete expression after parsing
|
|
||||||
getSigs :: Map.Map MyType [FuncWithArg], -- functions for which we have the concrete syntax already with args
|
|
||||||
getAll :: [FuncWithArg] -- all the functions with arguments
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
getNext :: Environ -> Environ -> ([MyFunc],[MyFunc])
|
|
||||||
getNext env example_env =
|
|
||||||
let sgs = getSigs env
|
|
||||||
allfuncs = getAll env
|
|
||||||
names = Set.fromList $ map getName $ concat $ Map.elems sgs
|
|
||||||
exampleable = filter (\x -> (isJust $ getNameExpr x env)
|
|
||||||
&&
|
|
||||||
(not $ Set.member x names) -- maybe drop this if you want to also rewrite from examples...
|
|
||||||
) $ map getName allfuncs
|
|
||||||
testeable = filter (\x -> (isJust $ getNameExpr x env )
|
|
||||||
&&
|
|
||||||
(Set.member x names)
|
|
||||||
) $ map getName allfuncs
|
|
||||||
|
|
||||||
in (exampleable,testeable)
|
|
||||||
|
|
||||||
|
|
||||||
provideExample :: RandomGen gen => gen -> Environ -> MyFunc -> PGF -> PGF -> Language -> Maybe (Expr,String)
|
|
||||||
provideExample gen env myfunc parsePGF pgfFile lang =
|
|
||||||
fmap giveExample $ getNameExpr myfunc env
|
|
||||||
where
|
|
||||||
giveExample e_ =
|
|
||||||
let newexpr = head $ generateRandomFromDepth gen pgfFile e_ (Just 5) -- change here with the new random generator
|
|
||||||
ty = getType $ head $ filter (\x -> getName x == myfunc) $ getAll env
|
|
||||||
embeddedExpr = maybe "" (\x -> ", as in: " ++ q (linearize pgfFile lang x)) (embedInStart (getAll env) (Map.fromList [(ty,e_)]))
|
|
||||||
lexpr = linearize pgfFile lang newexpr
|
|
||||||
q s = sq++s++sq
|
|
||||||
sq = "\""
|
|
||||||
in (newexpr,q lexpr ++ embeddedExpr)
|
|
||||||
-- question, you need the IO monad for the random generator, how to do otherwise ??
|
|
||||||
-- question can you make the expression bold/italic - somehow distinguishable from the rest ?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
testThis :: Environ -> MyFunc -> PGF -> Language -> Maybe String
|
|
||||||
testThis env myfunc parsePGF lang =
|
|
||||||
fmap (linearize parsePGF lang . mapToResource env . llin env) $
|
|
||||||
getNameExpr myfunc env
|
|
||||||
|
|
||||||
|
|
||||||
-- we assume that even the functions linearized by the user will still be in getSigs along with their linearization
|
|
||||||
|
|
||||||
|
|
||||||
-- fill in the blancs of an expression that we want to linearize for testing purposes
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
llin :: Environ -> Expr -> Expr
|
|
||||||
llin env expr =
|
|
||||||
let
|
|
||||||
(id,args) = fromJust $ unApp expr
|
|
||||||
--cexpr = fromJust $ Map.lookup id (getConcMap env)
|
|
||||||
in
|
|
||||||
if any isMeta args
|
|
||||||
then let
|
|
||||||
sigs = concat $ Map.elems $ getSigs env
|
|
||||||
tys = findExprWhich sigs id
|
|
||||||
in replaceConcArg 1 tys expr env
|
|
||||||
else mkApp id $ map (llin env) args
|
|
||||||
|
|
||||||
|
|
||||||
-- argument of the meta variable to replace, list of arguments left, expression to replace, environment, current replace expression
|
|
||||||
replaceConcArg :: Int -> [MyType] -> Expr -> Environ -> Expr
|
|
||||||
replaceConcArg i [] expr env = expr
|
|
||||||
replaceConcArg i (t:ts) expr env = -- TO DO : insert randomness here !!
|
|
||||||
let ss = fromJust $ Map.lookup t $ getSigs env
|
|
||||||
args = filter (null . getTypeArgs) ss
|
|
||||||
finArg = if null args then let l = last ss in llin env (mkApp (getName l) [mkMeta j | j <- [1..(length $ getTypeArgs l)]])
|
|
||||||
else mkApp (getName $ last args) []
|
|
||||||
in
|
|
||||||
let newe = replaceOne i finArg expr
|
|
||||||
in replaceConcArg (i+1) ts newe env
|
|
||||||
|
|
||||||
-- replace a certain metavariable with a certain expression in another expression - return updated expression
|
|
||||||
replaceOne :: Int -> Expr -> Expr -> Expr
|
|
||||||
replaceOne i erep expr =
|
|
||||||
if isMeta expr && ((fromJust $ unMeta expr) == i)
|
|
||||||
then erep
|
|
||||||
else if isMeta expr then expr
|
|
||||||
else let (id,args) = fromJust $ unApp expr
|
|
||||||
in
|
|
||||||
mkApp id $ map (replaceOne i erep) args
|
|
||||||
|
|
||||||
|
|
||||||
findExprWhich :: [FuncWithArg] -> MyFunc -> [MyType]
|
|
||||||
findExprWhich lst f = getTypeArgs $ head $ filter (\x -> getName x == f) lst
|
|
||||||
|
|
||||||
|
|
||||||
mapToResource :: Environ -> Expr -> Expr
|
|
||||||
mapToResource env expr =
|
|
||||||
let (id,args) = maybe (error $ "tried to unwrap " ++ showExpr [] expr) (\x -> x) (unApp expr)
|
|
||||||
cmap = getConcMap env
|
|
||||||
cexp = maybe (error $ "didn't find " ++ showCId id ++ " in "++ show cmap) (\x -> x) (Map.lookup id cmap)
|
|
||||||
in
|
|
||||||
if null args then cexp
|
|
||||||
else let newargs = map (mapToResource env) args
|
|
||||||
in replaceAllArgs cexp 1 newargs
|
|
||||||
where
|
|
||||||
replaceAllArgs expr i [] = expr
|
|
||||||
replaceAllArgs expr i (x:xs) = replaceAllArgs (replaceOne i x expr) (i+1) xs
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------
|
|
||||||
|
|
||||||
-- embed expression in another one from the start category
|
|
||||||
|
|
||||||
embedInStart :: [FuncWithArg] -> Map.Map MyType Expr -> Maybe Expr
|
|
||||||
embedInStart fss cs =
|
|
||||||
let currset = Map.toList cs
|
|
||||||
nextset = Map.fromList $ concat [ if elem myt (getTypeArgs farg)
|
|
||||||
then connectWithArg (myt,exp) farg else []
|
|
||||||
| (myt,exp) <- currset, farg <- fss]
|
|
||||||
nextmap = Map.union cs nextset
|
|
||||||
maybeExpr = Map.lookup startCateg nextset
|
|
||||||
in if isNothing maybeExpr then
|
|
||||||
if Map.size nextmap == Map.size cs then Nothing --error $ "could't build " ++ show startCateg ++ "with " ++ show fss
|
|
||||||
else embedInStart fss nextmap
|
|
||||||
else return $ fromJust maybeExpr
|
|
||||||
where
|
|
||||||
connectWithArg (myt,exp) farg =
|
|
||||||
let ind = head $ elemIndices myt (getTypeArgs farg)
|
|
||||||
in [(getType farg, mkApp (getName farg) $ [mkMeta i | i <- [1..ind]] ++ [exp] ++ [mkMeta i | i <- [(ind + 1)..((length $ getTypeArgs farg) - 1)]])]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------
|
|
||||||
{-
|
|
||||||
updateConcMap :: Environ -> MyFunc -> Expr -> Environ
|
|
||||||
updateConcMap env myf expr =
|
|
||||||
Env (getTypeMap env) (Map.insert myf expr (getConcMap env)) (getSigs env) (getAll env)
|
|
||||||
|
|
||||||
|
|
||||||
updateInterInstr :: Environ -> MyType -> FuncWithArg -> Environ
|
|
||||||
updateInterInstr env myt myf =
|
|
||||||
let ii = getSigs env
|
|
||||||
newInterInstr =
|
|
||||||
maybe (Map.insert myt [myf] ii) (\x -> Map.insert myt (myf:x) ii) $ Map.lookup myt ii
|
|
||||||
in Env (getTypeMap env) (getConcMap env) newInterInstr (getAll env)
|
|
||||||
|
|
||||||
|
|
||||||
putSignatures :: Environ -> [FuncWithArg] -> Environ
|
|
||||||
putSignatures env fss =
|
|
||||||
Env (getTypeMap env) (getConcMap env) (mkSigs fss) (getAll env)
|
|
||||||
|
|
||||||
|
|
||||||
updateEnv :: Environ -> FuncWithArg -> MyType -> Expr -> Environ
|
|
||||||
updateEnv env myf myt expr =
|
|
||||||
let ii = getSigs env
|
|
||||||
nn = getName myf
|
|
||||||
newInterInstr =
|
|
||||||
maybe (Map.insert myt [myf] ii) (\x -> Map.insert myt (myf:x) ii) $ Map.lookup myt ii
|
|
||||||
in Env (getTypeMap env) (Map.insert nn expr (getConcMap env)) newInterInstr (getAll env)
|
|
||||||
-}
|
|
||||||
|
|
||||||
mkSigs :: [FuncWithArg] -> Map.Map MyType [FuncWithArg]
|
|
||||||
mkSigs fss = Map.fromListWith (++) $ zip (map getType fss) (map (\x -> [x]) fss)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------
|
|
||||||
lang :: String
|
|
||||||
lang = "Eng"
|
|
||||||
|
|
||||||
|
|
||||||
parseLang :: Language
|
|
||||||
parseLang = fromJust $ readLanguage "ParseEng"
|
|
||||||
|
|
||||||
|
|
||||||
parsePGFfile :: String
|
|
||||||
parsePGFfile = "ParseEngAbs.pgf"
|
|
||||||
------------------------------------}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
searchGoodTree :: Environ -> Expr -> [Expr] -> IO (Maybe (Expr,Expr))
|
|
||||||
searchGoodTree env expr [] = return Nothing
|
|
||||||
searchGoodTree env expr (e:es) =
|
|
||||||
do val <- debugReplaceArgs expr e env
|
|
||||||
maybe (searchGoodTree env expr es) (\x -> return $ Just (x,e)) val
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getNameExpr :: MyFunc -> Environ -> Maybe Expr
|
|
||||||
getNameExpr myfunc env =
|
|
||||||
let allfunc = filter (\x -> getName x == myfunc) $ getAll env
|
|
||||||
in
|
|
||||||
if null allfunc then Nothing
|
|
||||||
else getExpr (head allfunc) env
|
|
||||||
|
|
||||||
-- find an expression to generate where we have all the other elements available
|
|
||||||
getExpr :: FuncWithArg -> Environ -> Maybe Expr
|
|
||||||
getExpr farg env =
|
|
||||||
let tys = getTypeArgs farg
|
|
||||||
ctx = getSigs env
|
|
||||||
lst = getConcTypes ctx tys 1
|
|
||||||
in if (all isJust lst) then Just $ mkApp (getName farg) (map fromJust lst)
|
|
||||||
else Nothing
|
|
||||||
where getConcTypes context [] i = []
|
|
||||||
getConcTypes context (ty:types) i =
|
|
||||||
let pos = Map.lookup ty context
|
|
||||||
in
|
|
||||||
if isNothing pos || (null $ fromJust pos) then [Nothing]
|
|
||||||
else
|
|
||||||
let mm = last $ fromJust pos
|
|
||||||
mmargs = getTypeArgs mm
|
|
||||||
newi = i + length mmargs - 1
|
|
||||||
lst = getConcTypes (Map.insert ty (init $ (fromJust pos)) context) types (newi+1)
|
|
||||||
in
|
|
||||||
if (all isJust lst) then -- i..newi
|
|
||||||
(Just $ mkApp (getName mm) [mkMeta j | j <- [1..(length mmargs)]]) : lst
|
|
||||||
else [Nothing]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- only covers simple expressions with meta variables, not the rest...
|
|
||||||
isGeneralizationOf :: Expr -> Expr -> Bool
|
|
||||||
isGeneralizationOf genExpr testExpr =
|
|
||||||
if isMeta genExpr then True
|
|
||||||
else if isMeta testExpr then False
|
|
||||||
else let genUnwrap = unApp genExpr
|
|
||||||
testUnwrap = unApp testExpr
|
|
||||||
in if isNothing genUnwrap || isNothing testUnwrap then False -- see if you can generalize here
|
|
||||||
else let (gencid, genargs) = fromJust genUnwrap
|
|
||||||
(testcid, testargs) = fromJust testUnwrap
|
|
||||||
in
|
|
||||||
(gencid == testcid) && (length genargs == length testargs)
|
|
||||||
&& (and [isGeneralizationOf g t | (g,t) <- (zip genargs testargs)])
|
|
||||||
|
|
||||||
{-do lst <- getConcTypes context types (i+1)
|
|
||||||
return $ mkMeta i : lst -}
|
|
||||||
|
|
||||||
debugReplaceArgs :: Expr -> Expr -> Environ -> IO (Maybe Expr)
|
|
||||||
debugReplaceArgs aexpr cexpr env =
|
|
||||||
if isNothing $ unApp aexpr then return Nothing
|
|
||||||
else if any isNothing $ map unApp $ snd $ fromJust $ unApp aexpr then return Nothing
|
|
||||||
else
|
|
||||||
let args = map (fst.fromJust.unApp) $ snd $ fromJust $ unApp aexpr
|
|
||||||
concExprs = map (\x -> fromJust $ Map.lookup x $ getConcMap env) args
|
|
||||||
in startReplace 1 cexpr concExprs
|
|
||||||
where
|
|
||||||
startReplace i cex [] = return $ Just cex
|
|
||||||
startReplace i cex (a:as) = do val <- debugReplaceConc cex i a
|
|
||||||
maybe ( --do putStrLn $ "didn't find "++ showExpr [] a ++ " in " ++showExpr [] cexpr
|
|
||||||
return Nothing)
|
|
||||||
(\x -> --do putStrLn $ "found it, the current expression is "++ showExpr [] x
|
|
||||||
startReplace (i+1) x as)
|
|
||||||
val
|
|
||||||
|
|
||||||
debugReplaceConc :: Expr -> Int -> Expr -> IO (Maybe Expr)
|
|
||||||
debugReplaceConc expr i e =
|
|
||||||
let (newe,isThere) = searchArg expr
|
|
||||||
in if isThere then return $ Just newe else return $ Nothing
|
|
||||||
where
|
|
||||||
searchArg e_ =
|
|
||||||
if isGeneralizationOf e e_ then (mkMeta i, True)
|
|
||||||
else maybe (e_,False) (\(cid,args) -> let repargs = map searchArg args
|
|
||||||
in (mkApp cid (map fst repargs), or $ map snd repargs)) $ unApp e_
|
|
||||||
|
|
||||||
|
|
||||||
{-
|
|
||||||
-- replaceArgs : Original expression to parse (from abstract syntax) -> Concrete expression (parsed)
|
|
||||||
replaceArgs :: Expr -> Expr -> Environ -> Maybe Expr
|
|
||||||
replaceArgs aexpr cexpr env =
|
|
||||||
if isNothing $ unApp aexpr then error $ "could't unwrap this "++ show aexpr
|
|
||||||
else if any isNothing $ map unApp $ snd $ fromJust $ unApp aexpr then error $ "couldn't unwrap more this : "++ show aexpr
|
|
||||||
else
|
|
||||||
let args = map (fst.fromJust.unApp) $ snd $ fromJust $ unApp aexpr
|
|
||||||
concExprs = map (\x -> fromJust $ Map.lookup x $ getConcMap env) args
|
|
||||||
in startReplace 1 cexpr concExprs
|
|
||||||
where
|
|
||||||
startReplace i cex [] = return cex
|
|
||||||
startReplace i cex (a:as) = maybe Nothing (\x -> startReplace (i+1) x as) $ replaceConc cex i a
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
replaceConc :: Expr -> Int -> Expr -> Maybe Expr
|
|
||||||
replaceConc expr i e =
|
|
||||||
let (newe,isThere) = searchArg expr
|
|
||||||
in if isThere then return newe else Nothing
|
|
||||||
where
|
|
||||||
searchArg e_ =
|
|
||||||
if isGeneralizationOf e e_ then (mkMeta i, True)
|
|
||||||
else maybe (e_,False) (\(cid,args) -> let repargs = map searchArg args
|
|
||||||
in (mkApp cid (map fst repargs), or $ map snd repargs)) $ unApp e_
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
writeResults :: Environ -> String -> IO ()
|
|
||||||
writeResults env fileName =
|
|
||||||
let cmap = getConcMap env
|
|
||||||
lincats = unlines $ map (\(x,y) -> "lincat " ++ showCId x ++ " = " ++ showCId y ++ " ; " ) $ Map.toList $ getTypeMap env
|
|
||||||
sigs = unlines $ map
|
|
||||||
(\x -> let n = getName x
|
|
||||||
no = length $ getTypeArgs x
|
|
||||||
oargs = unwords $ ("lin " ++ showCId n) : ["o"++show i | i <- [1..no]]
|
|
||||||
in (oargs ++ " = " ++ (simpleReplace $ showExpr [] $ fromJust $ Map.lookup n cmap) ++ " ; ")) $ concat $ Map.elems $ getSigs env
|
|
||||||
in
|
|
||||||
writeFile fileName ("\n" ++ lincats ++ "\n\n" ++ sigs)
|
|
||||||
|
|
||||||
|
|
||||||
simpleReplace :: String -> String
|
|
||||||
simpleReplace [] = []
|
|
||||||
simpleReplace ('?':xs) = 'o' : simpleReplace xs
|
|
||||||
simpleReplace (x:xs) = x : simpleReplace xs
|
|
||||||
-}
|
|
||||||
|
|
||||||
isMeta :: Expr -> Bool
|
|
||||||
isMeta = isJust.unMeta
|
|
||||||
|
|
||||||
-- works with utf-8 characters also, as it seems
|
|
||||||
|
|
||||||
|
|
||||||
mkFuncWithArg :: ((CId,CId),[CId]) -> FuncWithArg
|
|
||||||
mkFuncWithArg ((c1,c2),cids) = FuncWithArg c1 c2 cids
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
initial :: TypeMap -> ConcMap -> [FuncWithArg] -> [FuncWithArg] -> Environ
|
|
||||||
initial tm cm fss allfs = Env tm cm (mkSigs fss) allfs
|
|
||||||
{-
|
|
||||||
testInit :: [FuncWithArg] -> Environ
|
|
||||||
testInit allfs = initial lTypes Map.empty [] allfs
|
|
||||||
|
|
||||||
lTypes = Map.fromList [(mkCId "Comment", mkCId "S"),(mkCId "Item", mkCId "NP"), (mkCId "Kind", mkCId "CN"), (mkCId "Quality", mkCId "AP")]
|
|
||||||
-}
|
|
||||||
startCateg = mkCId "Comment"
|
|
||||||
-- question about either to give the startcat or not ...
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------
|
|
||||||
{-
|
|
||||||
main =
|
|
||||||
do args <- getArgs
|
|
||||||
case args of
|
|
||||||
[pgfFile] ->
|
|
||||||
do pgf <- readPGF pgfFile
|
|
||||||
parsePGF <- readPGF parsePGFfile
|
|
||||||
fsWithArg <- forExample pgf
|
|
||||||
let funcsWithArg = map (map mkFuncWithArg) fsWithArg
|
|
||||||
let morpho = buildMorpho parsePGF parseLang
|
|
||||||
let fss = concat funcsWithArg
|
|
||||||
let fileName = takeWhile (/='.') pgfFile ++ lang ++ ".gf"
|
|
||||||
env <- start parsePGF pgf morpho (testInit fss) fss
|
|
||||||
putStrLn $ "Should I write the results to a file ? yes/no"
|
|
||||||
ans <-getLine
|
|
||||||
if ans == "yes" then do writeResults env fileName
|
|
||||||
putStrLn $ "Wrote file " ++ fileName
|
|
||||||
else return ()
|
|
||||||
_ -> fail "usage : Testing <path-to-pgf> "
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
start :: PGF -> PGF -> Morpho -> Environ -> [FuncWithArg] -> IO Environ
|
|
||||||
start parsePGF pgfFile morpho env lst =
|
|
||||||
do putStrLn "Do you want examples from another language ? (no/concrete syntax name otherwise)"
|
|
||||||
ans1 <- getLine
|
|
||||||
putStrLn "Do you want testing mode ? (yes/no)"
|
|
||||||
ans2 <- getLine
|
|
||||||
case (ans1,ans2) of
|
|
||||||
("no","no") -> do putStrLn "no extra language, just the abstract syntax tree"
|
|
||||||
interact env lst False Nothing
|
|
||||||
(_,"no") -> interact env lst False (readLanguage ans1)
|
|
||||||
("no","yes") -> do putStrLn "no extra language, just the abstract syntax tree"
|
|
||||||
interact env lst True Nothing
|
|
||||||
(_,"yes") -> interact env lst True (readLanguage ans1)
|
|
||||||
("no",_) -> do putStrLn "no extra language, just the abstract syntax tree"
|
|
||||||
putStrLn $ "I assume you don't want the testing mode ... "
|
|
||||||
interact env lst False Nothing
|
|
||||||
(_,_) -> do putStrLn $ "I assume you don't want the testing mode ... "
|
|
||||||
interact env lst False (readLanguage ans1)
|
|
||||||
where
|
|
||||||
|
|
||||||
interact environ [] func _ = return environ
|
|
||||||
interact environ (farg:fargs) boo otherLang =
|
|
||||||
do
|
|
||||||
maybeEnv <- basicInter farg otherLang environ boo
|
|
||||||
if isNothing maybeEnv then return environ
|
|
||||||
else interact (fromJust maybeEnv) fargs boo otherLang
|
|
||||||
|
|
||||||
basicInter farg js environ False =
|
|
||||||
let e_ = getExpr farg environ in
|
|
||||||
if isNothing e_ then return $ Just environ
|
|
||||||
else parseAndBuild farg js environ (getType farg) e_ Nothing
|
|
||||||
basicInter farg js environ True =
|
|
||||||
let (e_,e_test) = get2Expr farg environ in
|
|
||||||
if isNothing e_ then return $ Just environ
|
|
||||||
else if isNothing e_test then do putStrLn $ "not enough arguments "++ (showCId $ getName farg)
|
|
||||||
parseAndBuild farg js environ (getType farg) e_ Nothing
|
|
||||||
else parseAndBuild farg js environ (getType farg) e_ e_test
|
|
||||||
|
|
||||||
-- . head . generateRandomFrom gen2 pgfFile
|
|
||||||
parseAndBuild farg js environ ty e_ e_test =
|
|
||||||
do let expr = fromJust e_
|
|
||||||
gen1 <- newStdGen
|
|
||||||
gen2 <- newStdGen
|
|
||||||
let newexpr = head $ generateRandomFrom gen1 pgfFile expr
|
|
||||||
let embeddedExpr = maybe "***" (showExpr [] ) (embedInStart (getAll environ) (Map.fromList [(ty,expr)]))
|
|
||||||
let lexpr = if isNothing js then "" else "\n-- " ++ linearize pgfFile (fromJust js) newexpr ++ " --"
|
|
||||||
putStrLn $ "Give an example for " ++ (showExpr [] expr)
|
|
||||||
++ lexpr ++ "and now"
|
|
||||||
++ "\n\nas in " ++ embeddedExpr ++ "\n\n"
|
|
||||||
--
|
|
||||||
ex <- getLine
|
|
||||||
if (ex == ":q") then return Nothing
|
|
||||||
else
|
|
||||||
let ctype = fromJust $ Map.lookup (getType farg) (getTypeMap environ) in
|
|
||||||
do env' <- decypher farg ex expr environ (fromJust $ readType $ showCId ctype) e_test
|
|
||||||
return (Just env')
|
|
||||||
|
|
||||||
decypher farg ex expr environ ty e_test =
|
|
||||||
--do putStrLn $ "We need to parse " ++ ex ++ " as " ++ show ctype
|
|
||||||
let pTrees = parse parsePGF (fromJust $ readLanguage "ParseEng") ty ex in
|
|
||||||
pickTree farg expr environ ex e_test pTrees
|
|
||||||
|
|
||||||
-- putStrLn $ "And now for testing, \n is this also correct yes/no \n ## " ++ (linearize parsePGF parseLang $ mapToResource newenv $ llin newenv e_test) ++ " ##"
|
|
||||||
|
|
||||||
-- select the right tree among the options given by the parser
|
|
||||||
pickTree farg expr environ ex e_test [] =
|
|
||||||
let miswords = morphoMissing morpho (words ex)
|
|
||||||
in
|
|
||||||
if null miswords then do putStrLn $ "all words known, but some syntactic construction is not covered by the grammar..."
|
|
||||||
return environ
|
|
||||||
else do putStrLn $ "the following words are unknown, please add them to the lexicon: " ++ show miswords
|
|
||||||
return environ
|
|
||||||
pickTree farg expr environ ex e_test [tree] =
|
|
||||||
do val <- searchGoodTree environ expr [tree] -- maybe order here after the probabilities for better precision
|
|
||||||
maybe (do putStrLn $ "none of the trees is consistent with the rest of the grammar, please check arguments "
|
|
||||||
return environ)
|
|
||||||
(\(x,newtree) -> let newenv = updateEnv environ farg (getType farg) x in
|
|
||||||
do putStrLn $ "the result is "++showExpr [] x
|
|
||||||
newtestenv <- testTest newenv e_test -- question ? should it belong there - there is just one possibility of a tree...
|
|
||||||
return newenv) val
|
|
||||||
pickTree farg expr environ ex e_test parseTrees =
|
|
||||||
do putStrLn $ "There is more than one possibility, do you want to choose the right tree yourself ? yes/no "
|
|
||||||
putStr " >"
|
|
||||||
ans <- getLine
|
|
||||||
if ans == "yes" then do pTree <- chooseRightTree parseTrees
|
|
||||||
processTree farg environ expr pTree e_test
|
|
||||||
else processTree farg environ expr parseTrees e_test
|
|
||||||
|
|
||||||
-- introduce testing function, if it doesn't work, then reparse, take that tree
|
|
||||||
testTree envv e_test = return envv -- TO DO - add testing here
|
|
||||||
|
|
||||||
testTest envv Nothing = return envv
|
|
||||||
testTest envv (Just exxpr) = testTree envv exxpr
|
|
||||||
|
|
||||||
|
|
||||||
-- allows the user to pick his own tree
|
|
||||||
chooseRightTree trees = return trees -- TO DO - add something clever here
|
|
||||||
|
|
||||||
-- selects the tree from where one can abstract over the original arguments
|
|
||||||
processTree farg environ expr lsTrees e_test =
|
|
||||||
let trmes = if length lsTrees == 1 then "the tree is not consistent " else "none of the trees is consistent " in
|
|
||||||
do val <- searchGoodTree environ expr lsTrees
|
|
||||||
maybe (do putStrLn $ trmes ++ "with the rest of the grammar, please check arguments! "
|
|
||||||
return environ)
|
|
||||||
(\(x,newtree) -> let newenv = updateEnv environ farg (getType farg) x in
|
|
||||||
do putStrLn $ "the result is "++showExpr [] x
|
|
||||||
newtestenv <- testTest newenv e_test
|
|
||||||
return newenv) val
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
get2Expr :: FuncWithArg -> Environ -> (Maybe Expr, Maybe Expr)
|
|
||||||
get2Expr farg env =
|
|
||||||
let tys = getTypeArgs farg
|
|
||||||
ctx = getSigs env
|
|
||||||
(lst1,lst2) = getConcTypes2 ctx tys 1
|
|
||||||
arg1 = if (all isJust lst1) then Just $ mkApp (getName farg) (map fromJust lst1) else Nothing
|
|
||||||
arg2 = if (all isJust lst2) then Just $ mkApp (getName farg) (map fromJust lst2) else Nothing
|
|
||||||
in if arg1 == arg2 then (arg1, Nothing)
|
|
||||||
else (arg1,arg2)
|
|
||||||
where
|
|
||||||
getConcTypes2 context [] i = ([],[])
|
|
||||||
getConcTypes2 context (ty:types) i =
|
|
||||||
let pos = Map.lookup ty context
|
|
||||||
in
|
|
||||||
if isNothing pos || (null $ fromJust pos) then ([Nothing],[Nothing])
|
|
||||||
else
|
|
||||||
let (mm,tt) = (last $ fromJust pos, head $ fromJust pos)
|
|
||||||
mmargs = getTypeArgs mm
|
|
||||||
newi = i + length mmargs - 1
|
|
||||||
(lst1,lst2) = getConcTypes2 (Map.insert ty (init (fromJust pos)) context) types (newi+1)
|
|
||||||
ttargs = getTypeArgs tt
|
|
||||||
newtti = i + length ttargs - 1
|
|
||||||
fstArg = if (all isJust lst1) then -- i..newi
|
|
||||||
(Just $ mkApp (getName mm) [mkMeta j | j <- [1..(length mmargs)]]) : lst1
|
|
||||||
else [Nothing]
|
|
||||||
sndArg = if (all isJust lst2) then
|
|
||||||
(Just $ mkApp (getName tt) [mkMeta j | j <- [1..(length ttargs)]]) : lst2
|
|
||||||
else [Nothing]
|
|
||||||
in
|
|
||||||
(fstArg,sndArg)
|
|
||||||
|
|
||||||
|
|
||||||
-}
|
|
||||||
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
module ExampleService(cgiMain,cgiMain',newPGFCache) where
|
|
||||||
import System.Random(newStdGen)
|
|
||||||
import System.FilePath((</>),makeRelative)
|
|
||||||
import Data.Map(fromList)
|
|
||||||
import Data.Char(isDigit)
|
|
||||||
import Data.Maybe(fromJust)
|
|
||||||
import qualified Codec.Binary.UTF8.String as UTF8 (decodeString)
|
|
||||||
import PGF
|
|
||||||
import GF.Compile.ToAPI
|
|
||||||
import Network.CGI
|
|
||||||
import Text.JSON
|
|
||||||
import CGIUtils
|
|
||||||
import Cache
|
|
||||||
import qualified ExampleDemo as E
|
|
||||||
|
|
||||||
newPGFCache = newCache readPGF
|
|
||||||
|
|
||||||
|
|
||||||
cgiMain :: Cache PGF -> CGI CGIResult
|
|
||||||
cgiMain = handleErrors . handleCGIErrors . cgiMain' "." "."
|
|
||||||
|
|
||||||
cgiMain' root cwd cache =
|
|
||||||
do command <- getInp "command"
|
|
||||||
environ <- parseEnviron =<< getInp "state"
|
|
||||||
case command of
|
|
||||||
"possibilities" -> doPossibilities environ
|
|
||||||
"provide_example" -> doProvideExample root cwd cache environ
|
|
||||||
"abstract_example" -> doAbstractExample cwd cache environ
|
|
||||||
"test_function" -> doTestFunction cwd cache environ
|
|
||||||
_ -> throwCGIError 400 ("Unknown command: "++command) []
|
|
||||||
|
|
||||||
doPossibilities environ =
|
|
||||||
do example_environ <- parseEnviron =<< getInp "example_state"
|
|
||||||
outputJSONP (E.getNext environ example_environ)
|
|
||||||
|
|
||||||
doProvideExample root cwd cache environ =
|
|
||||||
do Just lang <- readInput "lang"
|
|
||||||
fun <- getCId "fun"
|
|
||||||
parsePGF <- readParsePGF cwd cache
|
|
||||||
let adjpath path = root</>makeRelative "/" (makeRelative root cwd</>path)
|
|
||||||
pgf <- liftIO . readCache cache . adjpath =<< getInp "grammar"
|
|
||||||
gen <- liftIO newStdGen
|
|
||||||
let Just (e,s) = E.provideExample gen environ fun parsePGF pgf lang
|
|
||||||
res = (showExpr [] e,s)
|
|
||||||
liftIO $ logError $ "proveExample ... = "++show res
|
|
||||||
outputJSONP res
|
|
||||||
|
|
||||||
doAbstractExample cwd cache environ =
|
|
||||||
do example <- getInp "input"
|
|
||||||
Just params <- readInput "params"
|
|
||||||
absstr <- getInp "abstract"
|
|
||||||
Just abs <- return $ readExpr absstr
|
|
||||||
liftIO $ logError $ "abstract = "++showExpr [] abs
|
|
||||||
Just cat <- readInput "cat"
|
|
||||||
let t = mkType [] cat []
|
|
||||||
parsePGF <- readParsePGF cwd cache
|
|
||||||
let lang:_ = languages parsePGF
|
|
||||||
ae <- liftIO $ abstractExample parsePGF environ lang t abs example
|
|
||||||
outputJSONP (fmap (\(e,_)->(exprToAPI (instExpMeta params e),e)) ae)
|
|
||||||
|
|
||||||
abstractExample parsePGF env lang cat abs example =
|
|
||||||
E.searchGoodTree env abs (parse parsePGF lang cat example)
|
|
||||||
|
|
||||||
doTestFunction cwd cache environ =
|
|
||||||
do fun <- getCId "fun"
|
|
||||||
parsePGF <- readParsePGF cwd cache
|
|
||||||
let lang:_ = languages parsePGF
|
|
||||||
Just txt <- return (E.testThis environ fun parsePGF lang)
|
|
||||||
outputJSONP txt
|
|
||||||
|
|
||||||
getCId :: String -> CGI CId
|
|
||||||
getCId name = maybe err return =<< fmap readCId (getInp name)
|
|
||||||
where err = throwCGIError 400 ("Bad "++name) []
|
|
||||||
{-
|
|
||||||
getLimit :: CGI Int
|
|
||||||
getLimit = maybe err return =<< readInput "limit"
|
|
||||||
where err = throwCGIError 400 "Missing/bad limit" []
|
|
||||||
-}
|
|
||||||
|
|
||||||
readParsePGF cwd cache =
|
|
||||||
do parsepgf <- getInp "parser"
|
|
||||||
liftIO $ readCache cache (cwd</>parsepgf)
|
|
||||||
|
|
||||||
parseEnviron s = do state <- liftIO $ readIO s
|
|
||||||
return $ environ state
|
|
||||||
|
|
||||||
getInp name = maybe err (return . UTF8.decodeString) =<< getInput name
|
|
||||||
where err = throwCGIError 400 ("Missing parameter: "++name) []
|
|
||||||
|
|
||||||
|
|
||||||
instance JSON CId where
|
|
||||||
showJSON = showJSON . show
|
|
||||||
readJSON = (readResult =<<) . readJSON
|
|
||||||
|
|
||||||
instance JSON Expr where
|
|
||||||
showJSON = showJSON . showExpr []
|
|
||||||
readJSON = (m2r . readExpr =<<) . readJSON
|
|
||||||
|
|
||||||
m2r = maybe (Error "read failed") Ok
|
|
||||||
|
|
||||||
readResult s = case reads s of
|
|
||||||
(x,r):_ | lex r==[("","")] -> Ok x
|
|
||||||
_ -> Error "read failed"
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
-- cat lincat fun lin fun cat cat
|
|
||||||
environ :: ([(CId, CId)],[(CId, Expr)],[((CId, CId), [CId])]) -> E.Environ
|
|
||||||
environ (lincats,lins0,funs) =
|
|
||||||
E.initial (fromList lincats) concmap fs allfs
|
|
||||||
where
|
|
||||||
concmap = fromList lins
|
|
||||||
allfs = map E.mkFuncWithArg funs
|
|
||||||
fs = [E.mkFuncWithArg f | f@((fn,_),_)<-funs, fn `elem` cns]
|
|
||||||
cns = map fst lins
|
|
||||||
lins = filter (not . E.isMeta .snd) lins0
|
|
||||||
|
|
||||||
|
|
||||||
instExpMeta :: [CId] -> Expr -> Expr
|
|
||||||
instExpMeta ps = fromJust . readExpr . instMeta ps . showExpr []
|
|
||||||
|
|
||||||
instMeta :: [CId] -> String -> String
|
|
||||||
instMeta ps s =
|
|
||||||
case break (=='?') s of
|
|
||||||
(s1,'?':s2) ->
|
|
||||||
case span isDigit s2 of
|
|
||||||
(s21@(_:_),s22) -> s1++show (ps!!(read s21-1))++instMeta ps s22
|
|
||||||
("",s22) -> s1++'?':instMeta ps s22
|
|
||||||
(_,_) -> s
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
|
||||||
import Control.Concurrent(forkIO)
|
|
||||||
import Network.FastCGI(runFastCGI,runFastCGIConcurrent')
|
|
||||||
import ExampleService(cgiMain,newPGFCache)
|
|
||||||
|
|
||||||
main = do --stderrToFile logFile
|
|
||||||
fcgiMain =<< newPGFCache
|
|
||||||
|
|
||||||
|
|
||||||
fcgiMain cache =
|
|
||||||
#ifndef mingw32_HOST_OS
|
|
||||||
runFastCGIConcurrent' forkIO 100 (cgiMain cache)
|
|
||||||
#else
|
|
||||||
runFastCGI (cgiMain cache)
|
|
||||||
#endif
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
Name: gf-exb
|
|
||||||
Version: 1.0
|
|
||||||
Cabal-version: >= 1.8
|
|
||||||
Build-type: Simple
|
|
||||||
License: GPL
|
|
||||||
Synopsis: Example-based grammar writing for the Grammatical Framework
|
|
||||||
|
|
||||||
executable exb.fcgi
|
|
||||||
main-is: exb-fcgi.hs
|
|
||||||
Hs-source-dirs: . ../server ../compiler ../runtime/haskell
|
|
||||||
other-modules: ExampleService ExampleDemo
|
|
||||||
FastCGIUtils Cache GF.Compile.ToAPI
|
|
||||||
-- and a lot more...
|
|
||||||
ghc-options: -threaded
|
|
||||||
if impl(ghc>=7.0)
|
|
||||||
ghc-options: -rtsopts
|
|
||||||
|
|
||||||
build-depends: base >=4.2 && <5, json, cgi, fastcgi, random,
|
|
||||||
containers, old-time, directory, bytestring, utf8-string,
|
|
||||||
pretty, array, mtl, fst, filepath
|
|
||||||
|
|
||||||
if os(windows)
|
|
||||||
ghc-options: -optl-mwindows
|
|
||||||
else
|
|
||||||
build-depends: unix
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
Editor improvements for example-based grammar writing:
|
|
||||||
+ Remove the same language from the example language menu
|
|
||||||
+ Send the other language environment to getNext
|
|
||||||
- Compile a new .pgf automatically when needed
|
|
||||||
- Update buttons automatically when functions are added or removed
|
|
||||||
- Switch over to using AbsParadigmsEng.pgf instead of the old exprToAPI function
|
|
||||||
|
|
||||||
Editor support for guided construction of linearization functions
|
|
||||||
- enter api expressions by parsing them with AbsParadigmsEng.pgf in minibar
|
|
||||||
- replace simpleParseInput with one that accepts quoted string literals
|
|
||||||
- use lexcode/unlexcode in minibar
|
|
||||||
- better support for literals in minibar (completion info from the PGF
|
|
||||||
library should indicate if literals are acceptable)
|
|
||||||
|
|
||||||
Server support for example-based grammar writing:
|
|
||||||
- Change getNext to use info from the example language
|
|
||||||
- Random generator restricted to defined functions
|
|
||||||
|
|
||||||
- More testing
|
|
||||||
@@ -1,489 +0,0 @@
|
|||||||
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
|
|
||||||
-- | This is a layer on top of "Data.Binary" with its own 'Binary' class
|
|
||||||
-- and customised instances for 'Word', 'Int' and 'Double'.
|
|
||||||
-- The 'Int' and 'Word' instance use a variable-length encoding to save space
|
|
||||||
-- for small numbers. The 'Double' instance uses the standard IEEE754 encoding.
|
|
||||||
module PGF.Data.Binary (
|
|
||||||
|
|
||||||
-- * The Binary class
|
|
||||||
Binary(..)
|
|
||||||
|
|
||||||
-- * The Get and Put monads
|
|
||||||
, Get , Put, runPut
|
|
||||||
|
|
||||||
-- * Useful helpers for writing instances
|
|
||||||
, putWord8 , getWord8 , putWord16be , getWord16be
|
|
||||||
|
|
||||||
-- * Binary serialisation
|
|
||||||
, encode , decode
|
|
||||||
|
|
||||||
-- * IO functions for serialisation
|
|
||||||
, encodeFile , decodeFile
|
|
||||||
|
|
||||||
, encodeFile_ , decodeFile_
|
|
||||||
|
|
||||||
-- * Useful
|
|
||||||
, Word8, Word16
|
|
||||||
|
|
||||||
) where
|
|
||||||
|
|
||||||
|
|
||||||
import Data.Word
|
|
||||||
|
|
||||||
import qualified Data.Binary as Bin
|
|
||||||
import Data.Binary.Put
|
|
||||||
import Data.Binary.Get
|
|
||||||
import Data.Binary.IEEE754 ( putFloat64be, getFloat64be)
|
|
||||||
import Control.Monad
|
|
||||||
import Control.Exception
|
|
||||||
import Foreign
|
|
||||||
import System.IO
|
|
||||||
|
|
||||||
import Data.ByteString.Lazy (ByteString)
|
|
||||||
import qualified Data.ByteString.Lazy as L
|
|
||||||
|
|
||||||
--import Data.Char (chr,ord)
|
|
||||||
--import Data.List (unfoldr)
|
|
||||||
|
|
||||||
-- And needed for the instances:
|
|
||||||
import qualified Data.ByteString as B
|
|
||||||
import qualified Data.Map as Map
|
|
||||||
import qualified Data.Set as Set
|
|
||||||
import qualified Data.IntMap as IntMap
|
|
||||||
import qualified Data.IntSet as IntSet
|
|
||||||
--import qualified Data.Ratio as R
|
|
||||||
|
|
||||||
--import qualified Data.Tree as T
|
|
||||||
|
|
||||||
import Data.Array.Unboxed
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- | The @Binary@ class provides 'put' and 'get', methods to encode and
|
|
||||||
-- decode a Haskell value to a lazy ByteString. It mirrors the Read and
|
|
||||||
-- Show classes for textual representation of Haskell types, and is
|
|
||||||
-- suitable for serialising Haskell values to disk, over the network.
|
|
||||||
--
|
|
||||||
-- For parsing and generating simple external binary formats (e.g. C
|
|
||||||
-- structures), Binary may be used, but in general is not suitable
|
|
||||||
-- for complex protocols. Instead use the Put and Get primitives
|
|
||||||
-- directly.
|
|
||||||
--
|
|
||||||
-- Instances of Binary should satisfy the following property:
|
|
||||||
--
|
|
||||||
-- > decode . encode == id
|
|
||||||
--
|
|
||||||
-- That is, the 'get' and 'put' methods should be the inverse of each
|
|
||||||
-- other. A range of instances are provided for basic Haskell types.
|
|
||||||
--
|
|
||||||
class Binary t where
|
|
||||||
-- | Encode a value in the Put monad.
|
|
||||||
put :: t -> Put
|
|
||||||
-- | Decode a value in the Get monad
|
|
||||||
get :: Get t
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Wrappers to run the underlying monad
|
|
||||||
|
|
||||||
-- | Encode a value using binary serialisation to a lazy ByteString.
|
|
||||||
--
|
|
||||||
encode :: Binary a => a -> ByteString
|
|
||||||
encode = runPut . put
|
|
||||||
{-# INLINE encode #-}
|
|
||||||
|
|
||||||
-- | Decode a value from a lazy ByteString, reconstructing the original structure.
|
|
||||||
--
|
|
||||||
decode :: Binary a => ByteString -> a
|
|
||||||
decode = runGet get
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Convenience IO operations
|
|
||||||
|
|
||||||
-- | Lazily serialise a value to a file
|
|
||||||
--
|
|
||||||
-- This is just a convenience function, it's defined simply as:
|
|
||||||
--
|
|
||||||
-- > encodeFile f = B.writeFile f . encode
|
|
||||||
--
|
|
||||||
-- So for example if you wanted to compress as well, you could use:
|
|
||||||
--
|
|
||||||
-- > B.writeFile f . compress . encode
|
|
||||||
--
|
|
||||||
encodeFile :: Binary a => FilePath -> a -> IO ()
|
|
||||||
encodeFile f v = L.writeFile f (encode v)
|
|
||||||
|
|
||||||
encodeFile_ :: FilePath -> Put -> IO ()
|
|
||||||
encodeFile_ f m = L.writeFile f (runPut m)
|
|
||||||
|
|
||||||
-- | Lazily reconstruct a value previously written to a file.
|
|
||||||
--
|
|
||||||
-- This is just a convenience function, it's defined simply as:
|
|
||||||
--
|
|
||||||
-- > decodeFile f = return . decode =<< B.readFile f
|
|
||||||
--
|
|
||||||
-- So for example if you wanted to decompress as well, you could use:
|
|
||||||
--
|
|
||||||
-- > return . decode . decompress =<< B.readFile f
|
|
||||||
--
|
|
||||||
decodeFile :: Binary a => FilePath -> IO a
|
|
||||||
decodeFile f = bracket (openBinaryFile f ReadMode) hClose $ \h -> do
|
|
||||||
s <- L.hGetContents h
|
|
||||||
evaluate $ runGet get s
|
|
||||||
|
|
||||||
decodeFile_ :: FilePath -> Get a -> IO a
|
|
||||||
decodeFile_ f m = bracket (openBinaryFile f ReadMode) hClose $ \h -> do
|
|
||||||
s <- L.hGetContents h
|
|
||||||
evaluate $ runGet m s
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- For ground types, the standard instances can be reused,
|
|
||||||
-- but for container types it would imply using
|
|
||||||
-- the standard instances for all types of values in the container...
|
|
||||||
|
|
||||||
instance Binary () where put=Bin.put; get=Bin.get
|
|
||||||
instance Binary Bool where put=Bin.put; get=Bin.get
|
|
||||||
instance Binary Word8 where put=Bin.put; get=Bin.get
|
|
||||||
instance Binary Word16 where put=Bin.put; get=Bin.get
|
|
||||||
instance Binary Char where put=Bin.put; get=Bin.get
|
|
||||||
|
|
||||||
-- -- GF doesn't need these:
|
|
||||||
--instance Binary Ordering where put=Bin.put; get=Bin.get
|
|
||||||
--instance Binary Word32 where put=Bin.put; get=Bin.get
|
|
||||||
--instance Binary Word64 where put=Bin.put; get=Bin.get
|
|
||||||
--instance Binary Int8 where put=Bin.put; get=Bin.get
|
|
||||||
--instance Binary Int16 where put=Bin.put; get=Bin.get
|
|
||||||
--instance Binary Int32 where put=Bin.put; get=Bin.get
|
|
||||||
|
|
||||||
--instance Binary Int64 where put=Bin.put; get=Bin.get -- needed by instance Binary ByteString
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Words are written as sequence of bytes. The last bit of each
|
|
||||||
-- byte indicates whether there are more bytes to be read
|
|
||||||
instance Binary Word where
|
|
||||||
put i | i <= 0x7f = do put a
|
|
||||||
| i <= 0x3fff = do put (a .|. 0x80)
|
|
||||||
put b
|
|
||||||
| i <= 0x1fffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put c
|
|
||||||
| i <= 0xfffffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put d
|
|
||||||
-- -- #if WORD_SIZE_IN_BITS < 64
|
|
||||||
| otherwise = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put e
|
|
||||||
{-
|
|
||||||
-- Restricted to 32 bits even on 64-bit systems, so that negative
|
|
||||||
-- Ints are written as 5 bytes instead of 10 bytes (TH 2013-02-13)
|
|
||||||
--#else
|
|
||||||
| i <= 0x7ffffffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put e
|
|
||||||
| i <= 0x3ffffffffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put (e .|. 0x80)
|
|
||||||
put f
|
|
||||||
| i <= 0x1ffffffffffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put (e .|. 0x80)
|
|
||||||
put (f .|. 0x80)
|
|
||||||
put g
|
|
||||||
| i <= 0xffffffffffffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put (e .|. 0x80)
|
|
||||||
put (f .|. 0x80)
|
|
||||||
put (g .|. 0x80)
|
|
||||||
put h
|
|
||||||
| i <= 0xffffffffffffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put (e .|. 0x80)
|
|
||||||
put (f .|. 0x80)
|
|
||||||
put (g .|. 0x80)
|
|
||||||
put h
|
|
||||||
| i <= 0x7fffffffffffffff = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put (e .|. 0x80)
|
|
||||||
put (f .|. 0x80)
|
|
||||||
put (g .|. 0x80)
|
|
||||||
put (h .|. 0x80)
|
|
||||||
put j
|
|
||||||
| otherwise = do put (a .|. 0x80)
|
|
||||||
put (b .|. 0x80)
|
|
||||||
put (c .|. 0x80)
|
|
||||||
put (d .|. 0x80)
|
|
||||||
put (e .|. 0x80)
|
|
||||||
put (f .|. 0x80)
|
|
||||||
put (g .|. 0x80)
|
|
||||||
put (h .|. 0x80)
|
|
||||||
put (j .|. 0x80)
|
|
||||||
put k
|
|
||||||
-- #endif
|
|
||||||
-}
|
|
||||||
where
|
|
||||||
a = fromIntegral ( i .&. 0x7f) :: Word8
|
|
||||||
b = fromIntegral (shiftR i 7 .&. 0x7f) :: Word8
|
|
||||||
c = fromIntegral (shiftR i 14 .&. 0x7f) :: Word8
|
|
||||||
d = fromIntegral (shiftR i 21 .&. 0x7f) :: Word8
|
|
||||||
e = fromIntegral (shiftR i 28 .&. 0x7f) :: Word8
|
|
||||||
{-
|
|
||||||
f = fromIntegral (shiftR i 35 .&. 0x7f) :: Word8
|
|
||||||
g = fromIntegral (shiftR i 42 .&. 0x7f) :: Word8
|
|
||||||
h = fromIntegral (shiftR i 49 .&. 0x7f) :: Word8
|
|
||||||
j = fromIntegral (shiftR i 56 .&. 0x7f) :: Word8
|
|
||||||
k = fromIntegral (shiftR i 63 .&. 0x7f) :: Word8
|
|
||||||
-}
|
|
||||||
get = do i <- getWord8
|
|
||||||
(if i <= 0x7f
|
|
||||||
then return (fromIntegral i)
|
|
||||||
else do n <- get
|
|
||||||
return $ (n `shiftL` 7) .|. (fromIntegral (i .&. 0x7f)))
|
|
||||||
|
|
||||||
-- Int has the same representation as Word
|
|
||||||
instance Binary Int where
|
|
||||||
put i = put (fromIntegral i :: Word)
|
|
||||||
get = liftM toInt32 (get :: Get Word)
|
|
||||||
where
|
|
||||||
-- restrict to 32 bits (for PGF portability, TH 2013-02-13)
|
|
||||||
toInt32 w = fromIntegral (fromIntegral w::Int32)::Int
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- Portable, and pretty efficient, serialisation of Integer
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Fixed-size type for a subset of Integer
|
|
||||||
--type SmallInt = Int32
|
|
||||||
|
|
||||||
-- Integers are encoded in two ways: if they fit inside a SmallInt,
|
|
||||||
-- they're written as a byte tag, and that value. If the Integer value
|
|
||||||
-- is too large to fit in a SmallInt, it is written as a byte array,
|
|
||||||
-- along with a sign and length field.
|
|
||||||
{-
|
|
||||||
instance Binary Integer where
|
|
||||||
|
|
||||||
{-# INLINE put #-}
|
|
||||||
put n | n >= lo && n <= hi = do
|
|
||||||
putWord8 0
|
|
||||||
put (fromIntegral n :: SmallInt) -- fast path
|
|
||||||
where
|
|
||||||
lo = fromIntegral (minBound :: SmallInt) :: Integer
|
|
||||||
hi = fromIntegral (maxBound :: SmallInt) :: Integer
|
|
||||||
|
|
||||||
put n = do
|
|
||||||
putWord8 1
|
|
||||||
put sign
|
|
||||||
put (unroll (abs n)) -- unroll the bytes
|
|
||||||
where
|
|
||||||
sign = fromIntegral (signum n) :: Word8
|
|
||||||
|
|
||||||
{-# INLINE get #-}
|
|
||||||
get = do
|
|
||||||
tag <- get :: Get Word8
|
|
||||||
case tag of
|
|
||||||
0 -> liftM fromIntegral (get :: Get SmallInt)
|
|
||||||
_ -> do sign <- get
|
|
||||||
bytes <- get
|
|
||||||
let v = roll bytes
|
|
||||||
return $! if sign == (1 :: Word8) then v else - v
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Fold and unfold an Integer to and from a list of its bytes
|
|
||||||
--
|
|
||||||
unroll :: Integer -> [Word8]
|
|
||||||
unroll = unfoldr step
|
|
||||||
where
|
|
||||||
step 0 = Nothing
|
|
||||||
step i = Just (fromIntegral i, i `shiftR` 8)
|
|
||||||
|
|
||||||
roll :: [Word8] -> Integer
|
|
||||||
roll = foldr unstep 0
|
|
||||||
where
|
|
||||||
unstep b a = a `shiftL` 8 .|. fromIntegral b
|
|
||||||
|
|
||||||
instance (Binary a,Integral a) => Binary (R.Ratio a) where
|
|
||||||
put r = put (R.numerator r) >> put (R.denominator r)
|
|
||||||
get = liftM2 (R.%) get get
|
|
||||||
-}
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Instances for the first few tuples
|
|
||||||
|
|
||||||
instance (Binary a, Binary b) => Binary (a,b) where
|
|
||||||
put (a,b) = put a >> put b
|
|
||||||
get = liftM2 (,) get get
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c) => Binary (a,b,c) where
|
|
||||||
put (a,b,c) = put a >> put b >> put c
|
|
||||||
get = liftM3 (,,) get get get
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c, Binary d) => Binary (a,b,c,d) where
|
|
||||||
put (a,b,c,d) = put a >> put b >> put c >> put d
|
|
||||||
get = liftM4 (,,,) get get get get
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c, Binary d, Binary e) => Binary (a,b,c,d,e) where
|
|
||||||
put (a,b,c,d,e) = put a >> put b >> put c >> put d >> put e
|
|
||||||
get = liftM5 (,,,,) get get get get get
|
|
||||||
|
|
||||||
--
|
|
||||||
-- and now just recurse:
|
|
||||||
--
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c, Binary d, Binary e, Binary f)
|
|
||||||
=> Binary (a,b,c,d,e,f) where
|
|
||||||
put (a,b,c,d,e,f) = put (a,(b,c,d,e,f))
|
|
||||||
get = do (a,(b,c,d,e,f)) <- get ; return (a,b,c,d,e,f)
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c, Binary d, Binary e, Binary f, Binary g)
|
|
||||||
=> Binary (a,b,c,d,e,f,g) where
|
|
||||||
put (a,b,c,d,e,f,g) = put (a,(b,c,d,e,f,g))
|
|
||||||
get = do (a,(b,c,d,e,f,g)) <- get ; return (a,b,c,d,e,f,g)
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c, Binary d, Binary e,
|
|
||||||
Binary f, Binary g, Binary h)
|
|
||||||
=> Binary (a,b,c,d,e,f,g,h) where
|
|
||||||
put (a,b,c,d,e,f,g,h) = put (a,(b,c,d,e,f,g,h))
|
|
||||||
get = do (a,(b,c,d,e,f,g,h)) <- get ; return (a,b,c,d,e,f,g,h)
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c, Binary d, Binary e,
|
|
||||||
Binary f, Binary g, Binary h, Binary i)
|
|
||||||
=> Binary (a,b,c,d,e,f,g,h,i) where
|
|
||||||
put (a,b,c,d,e,f,g,h,i) = put (a,(b,c,d,e,f,g,h,i))
|
|
||||||
get = do (a,(b,c,d,e,f,g,h,i)) <- get ; return (a,b,c,d,e,f,g,h,i)
|
|
||||||
|
|
||||||
instance (Binary a, Binary b, Binary c, Binary d, Binary e,
|
|
||||||
Binary f, Binary g, Binary h, Binary i, Binary j)
|
|
||||||
=> Binary (a,b,c,d,e,f,g,h,i,j) where
|
|
||||||
put (a,b,c,d,e,f,g,h,i,j) = put (a,(b,c,d,e,f,g,h,i,j))
|
|
||||||
get = do (a,(b,c,d,e,f,g,h,i,j)) <- get ; return (a,b,c,d,e,f,g,h,i,j)
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Container types
|
|
||||||
|
|
||||||
instance Binary a => Binary [a] where
|
|
||||||
put l = put (length l) >> mapM_ put l
|
|
||||||
get = do n <- get :: Get Int
|
|
||||||
xs <- replicateM n get
|
|
||||||
return xs
|
|
||||||
|
|
||||||
instance (Binary a) => Binary (Maybe a) where
|
|
||||||
put Nothing = putWord8 0
|
|
||||||
put (Just x) = putWord8 1 >> put x
|
|
||||||
get = do
|
|
||||||
w <- getWord8
|
|
||||||
case w of
|
|
||||||
0 -> return Nothing
|
|
||||||
_ -> liftM Just get
|
|
||||||
|
|
||||||
instance (Binary a, Binary b) => Binary (Either a b) where
|
|
||||||
put (Left a) = putWord8 0 >> put a
|
|
||||||
put (Right b) = putWord8 1 >> put b
|
|
||||||
get = do
|
|
||||||
w <- getWord8
|
|
||||||
case w of
|
|
||||||
0 -> liftM Left get
|
|
||||||
_ -> liftM Right get
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- ByteStrings (have specially efficient instances)
|
|
||||||
|
|
||||||
instance Binary B.ByteString where
|
|
||||||
put bs = do put (B.length bs)
|
|
||||||
putByteString bs
|
|
||||||
get = get >>= getByteString
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Using old versions of fps, this is a type synonym, and non portable
|
|
||||||
--
|
|
||||||
-- Requires 'flexible instances'
|
|
||||||
--
|
|
||||||
{-
|
|
||||||
instance Binary ByteString where
|
|
||||||
put bs = do put (fromIntegral (L.length bs) :: Int)
|
|
||||||
putLazyByteString bs
|
|
||||||
get = get >>= getLazyByteString
|
|
||||||
-}
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Maps and Sets
|
|
||||||
|
|
||||||
instance (Ord a, Binary a) => Binary (Set.Set a) where
|
|
||||||
put s = put (Set.size s) >> mapM_ put (Set.toAscList s)
|
|
||||||
get = liftM Set.fromDistinctAscList get
|
|
||||||
|
|
||||||
instance (Ord k, Binary k, Binary e) => Binary (Map.Map k e) where
|
|
||||||
put m = put (Map.size m) >> mapM_ put (Map.toAscList m)
|
|
||||||
get = liftM Map.fromDistinctAscList get
|
|
||||||
|
|
||||||
instance Binary IntSet.IntSet where
|
|
||||||
put s = put (IntSet.size s) >> mapM_ put (IntSet.toAscList s)
|
|
||||||
get = liftM IntSet.fromDistinctAscList get
|
|
||||||
|
|
||||||
instance (Binary e) => Binary (IntMap.IntMap e) where
|
|
||||||
put m = put (IntMap.size m) >> mapM_ put (IntMap.toAscList m)
|
|
||||||
get = liftM IntMap.fromDistinctAscList get
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Floating point
|
|
||||||
|
|
||||||
-- instance Binary Double where
|
|
||||||
-- put d = put (decodeFloat d)
|
|
||||||
-- get = liftM2 encodeFloat get get
|
|
||||||
|
|
||||||
instance Binary Double where
|
|
||||||
put = putFloat64be
|
|
||||||
get = getFloat64be
|
|
||||||
{-
|
|
||||||
instance Binary Float where
|
|
||||||
put f = put (decodeFloat f)
|
|
||||||
get = liftM2 encodeFloat get get
|
|
||||||
-}
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Trees
|
|
||||||
{-
|
|
||||||
instance (Binary e) => Binary (T.Tree e) where
|
|
||||||
put (T.Node r s) = put r >> put s
|
|
||||||
get = liftM2 T.Node get get
|
|
||||||
-}
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
-- Arrays
|
|
||||||
|
|
||||||
instance (Binary i, Ix i, Binary e) => Binary (Array i e) where
|
|
||||||
put a = do
|
|
||||||
put (bounds a)
|
|
||||||
put (rangeSize $ bounds a) -- write the length
|
|
||||||
mapM_ put (elems a) -- now the elems.
|
|
||||||
get = do
|
|
||||||
bs <- get
|
|
||||||
n <- get -- read the length
|
|
||||||
xs <- replicateM n get -- now the elems.
|
|
||||||
return (listArray bs xs)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- The IArray UArray e constraint is non portable. Requires flexible instances
|
|
||||||
--
|
|
||||||
instance (Binary i, Ix i, Binary e, IArray UArray e) => Binary (UArray i e) where
|
|
||||||
put a = do
|
|
||||||
put (bounds a)
|
|
||||||
put (rangeSize $ bounds a) -- now write the length
|
|
||||||
mapM_ put (elems a)
|
|
||||||
get = do
|
|
||||||
bs <- get
|
|
||||||
n <- get
|
|
||||||
xs <- replicateM n get
|
|
||||||
return (listArray bs xs)
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
name: pgf-binary
|
|
||||||
version: 0.5
|
|
||||||
|
|
||||||
cabal-version: >= 1.10
|
|
||||||
build-type: Simple
|
|
||||||
license: BSD3
|
|
||||||
--license-file: LICENSE
|
|
||||||
synopsis: Custom version of the binary-0.5 package for the PGF library
|
|
||||||
homepage: http://www.grammaticalframework.org/
|
|
||||||
--bug-reports: http://code.google.com/p/grammatical-framework/issues/list
|
|
||||||
maintainer: Thomas Hallgren
|
|
||||||
stability: provisional
|
|
||||||
category: Data, Parsing
|
|
||||||
tested-with: GHC==7.4.2, GHC==7.8.3
|
|
||||||
|
|
||||||
source-repository head
|
|
||||||
type: darcs
|
|
||||||
location: http://www.grammaticalframework.org/
|
|
||||||
|
|
||||||
Library
|
|
||||||
default-language: Haskell2010
|
|
||||||
build-depends: base >= 4.3 && <5, binary, data-binary-ieee754,
|
|
||||||
containers, array, bytestring
|
|
||||||
exposed-modules: PGF.Data.Binary
|
|
||||||
|
|
||||||
ghc-options: -fwarn-unused-imports -O2
|
|
||||||
extensions: FlexibleInstances, FlexibleContexts
|
|
||||||
@@ -12,6 +12,9 @@ module PGF2.Internal(-- * Access the internal structures
|
|||||||
build, eAbs, eApp, eMeta, eFun, eVar, eTyped, eImplArg, dTyp, hypo,
|
build, eAbs, eApp, eMeta, eFun, eVar, eTyped, eImplArg, dTyp, hypo,
|
||||||
AbstrInfo, newAbstr, ConcrInfo, newConcr, newPGF,
|
AbstrInfo, newAbstr, ConcrInfo, newConcr, newPGF,
|
||||||
|
|
||||||
|
-- * Expose PGF and Concr for FFI with C
|
||||||
|
PGF(..), Concr(..),
|
||||||
|
|
||||||
-- * Write an in-memory PGF to a file
|
-- * Write an in-memory PGF to a file
|
||||||
writePGF
|
writePGF
|
||||||
) where
|
) where
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: pgf
|
name: pgf
|
||||||
version: 3.9.1-git
|
version: 3.10
|
||||||
|
|
||||||
cabal-version: >= 1.20
|
cabal-version: >= 1.20
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
@@ -12,11 +12,6 @@ bug-reports: https://github.com/GrammaticalFramework/gf-core/issues
|
|||||||
maintainer: Thomas Hallgren
|
maintainer: Thomas Hallgren
|
||||||
tested-with: GHC==7.6.3, GHC==7.8.3, GHC==7.10.3, GHC==8.0.2
|
tested-with: GHC==7.6.3, GHC==7.8.3, GHC==7.10.3, GHC==8.0.2
|
||||||
|
|
||||||
flag custom-binary
|
|
||||||
Description: Use a customised version of the binary package
|
|
||||||
Default: True
|
|
||||||
Manual: True
|
|
||||||
|
|
||||||
Library
|
Library
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
build-depends: base >= 4.6 && <5,
|
build-depends: base >= 4.6 && <5,
|
||||||
@@ -29,17 +24,14 @@ Library
|
|||||||
mtl,
|
mtl,
|
||||||
exceptions
|
exceptions
|
||||||
|
|
||||||
if flag(custom-binary)
|
other-modules:
|
||||||
other-modules:
|
-- not really part of GF but I have changed the original binary library
|
||||||
-- not really part of GF but I have changed the original binary library
|
-- and we have to keep the copy for now.
|
||||||
-- and we have to keep the copy for now.
|
Data.Binary
|
||||||
Data.Binary
|
Data.Binary.Put
|
||||||
Data.Binary.Put
|
Data.Binary.Get
|
||||||
Data.Binary.Get
|
Data.Binary.Builder
|
||||||
Data.Binary.Builder
|
Data.Binary.IEEE754
|
||||||
Data.Binary.IEEE754
|
|
||||||
else
|
|
||||||
build-depends: binary, data-binary-ieee754
|
|
||||||
|
|
||||||
--ghc-options: -fwarn-unused-imports
|
--ghc-options: -fwarn-unused-imports
|
||||||
--if impl(ghc>=7.8)
|
--if impl(ghc>=7.8)
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
name: gf-server
|
|
||||||
version: 1.0
|
|
||||||
cabal-version: >= 1.8
|
|
||||||
build-type: Custom
|
|
||||||
license: GPL
|
|
||||||
license-file: ../../LICENSE
|
|
||||||
synopsis: FastCGI Server for Grammatical Framework
|
|
||||||
|
|
||||||
flag content
|
|
||||||
Description:
|
|
||||||
Build content service (requires fastcgi and hsql-mysql packages)
|
|
||||||
(In Ubuntu: apt-get install libghc-fastcgi-dev libghc-hsql-mysql-dev)
|
|
||||||
Default: False
|
|
||||||
|
|
||||||
flag http
|
|
||||||
Description: Build pgf-http (deprecated, replaced by gf -server)
|
|
||||||
Default: False
|
|
||||||
|
|
||||||
flag fastcgi
|
|
||||||
Description: Build librar & pgf-service executable with fastcgi support
|
|
||||||
Default: True
|
|
||||||
|
|
||||||
flag c-runtime
|
|
||||||
Description: Include functionality from the C run-time library (which must be installed already)
|
|
||||||
Default: False
|
|
||||||
|
|
||||||
flag network-uri
|
|
||||||
description: Get Network.URI from the network-uri package
|
|
||||||
default: True
|
|
||||||
|
|
||||||
Library
|
|
||||||
exposed-modules: PGFService FastCGIUtils CGIUtils ServeStaticFile RunHTTP Cache
|
|
||||||
other-modules: URLEncoding CGI Fold
|
|
||||||
hs-source-dirs: . transfer
|
|
||||||
|
|
||||||
if flag(fastcgi)
|
|
||||||
build-depends: fastcgi >= 3001.0.2.2
|
|
||||||
-- Install it in Ubuntu with: apt-get install libghc-fastcgi-dev
|
|
||||||
else
|
|
||||||
Buildable: False
|
|
||||||
|
|
||||||
build-depends: base >=4.2 && <5,
|
|
||||||
time, time-compat, old-locale,
|
|
||||||
directory,
|
|
||||||
filepath,
|
|
||||||
containers,
|
|
||||||
process,
|
|
||||||
gf >= 3.6,
|
|
||||||
cgi >= 3001.1.7.3,
|
|
||||||
httpd-shed>=0.4.0.2,
|
|
||||||
mtl,
|
|
||||||
exceptions,
|
|
||||||
json >= 0.3.3,
|
|
||||||
utf8-string >= 0.3.1.1,
|
|
||||||
bytestring,
|
|
||||||
pretty,
|
|
||||||
random
|
|
||||||
|
|
||||||
if flag(network-uri)
|
|
||||||
build-depends: network-uri>=2.6, network>=2.6
|
|
||||||
else
|
|
||||||
build-depends: network>=2.3 && <2.6
|
|
||||||
|
|
||||||
ghc-options: -fwarn-unused-imports
|
|
||||||
if os(windows)
|
|
||||||
ghc-options: -optl-mwindows
|
|
||||||
else
|
|
||||||
build-depends: unix
|
|
||||||
|
|
||||||
if flag(c-runtime)
|
|
||||||
cpp-options: -DC_RUNTIME
|
|
||||||
|
|
||||||
executable pgf-http
|
|
||||||
main-is: pgf-http.hs
|
|
||||||
Hs-source-dirs: exec
|
|
||||||
ghc-options: -threaded
|
|
||||||
if impl(ghc>=7.0)
|
|
||||||
ghc-options: -rtsopts
|
|
||||||
|
|
||||||
if flag(http)
|
|
||||||
buildable: True
|
|
||||||
build-depends: base >=4.2 && <5, gf-server, filepath, directory, cgi
|
|
||||||
else
|
|
||||||
buildable: False
|
|
||||||
|
|
||||||
executable pgf-service
|
|
||||||
main-is: pgf-fcgi.hs
|
|
||||||
Hs-source-dirs: exec
|
|
||||||
ghc-options: -threaded -fwarn-unused-imports
|
|
||||||
if impl(ghc>=7.0)
|
|
||||||
ghc-options: -rtsopts
|
|
||||||
|
|
||||||
if flag(fastcgi)
|
|
||||||
build-depends: fastcgi >= 3001.0.2.2
|
|
||||||
-- Install it in Ubuntu with: apt-get install libghc-fastcgi-dev
|
|
||||||
else
|
|
||||||
Buildable: False
|
|
||||||
|
|
||||||
build-depends: base >=4.2 && <5, gf-server
|
|
||||||
|
|
||||||
if os(windows)
|
|
||||||
ghc-options: -optl-mwindows
|
|
||||||
else
|
|
||||||
build-depends: unix
|
|
||||||
|
|
||||||
executable content-service
|
|
||||||
if flag(content)
|
|
||||||
build-depends: base >=4.2 && <5, old-locale,
|
|
||||||
fastcgi >= 3001.0.2.2,
|
|
||||||
-- In Ubuntu: apt-get install libghc-fastcgi-dev
|
|
||||||
hsql-mysql, hsql
|
|
||||||
-- In Ubuntu: apt-get install libghc-hsql-mysql-dev
|
|
||||||
buildable: True
|
|
||||||
else
|
|
||||||
buildable: False
|
|
||||||
|
|
||||||
main-is: ContentService.hs
|
|
||||||
Hs-source-dirs: exec
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Run with (with -D for no-daemon)
|
# Run with (with -D for no-daemon)
|
||||||
# /usr/sbin/lighttpd -f lighttpd.conf -D
|
# /usr/sbin/lighttpd -f lighttpd.conf -D
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -10,8 +10,9 @@ server.modules = (
|
|||||||
"mod_cgi"
|
"mod_cgi"
|
||||||
)
|
)
|
||||||
|
|
||||||
var.basedir = var.CWD
|
var.basedir = var.CWD
|
||||||
|
|
||||||
|
# John: no longer valid after removing `src/ui` 2018-11-15
|
||||||
server.document-root = basedir + "/../ui/gwt/www"
|
server.document-root = basedir + "/../ui/gwt/www"
|
||||||
|
|
||||||
server.errorlog = basedir + "/error.log"
|
server.errorlog = basedir + "/error.log"
|
||||||
@@ -96,4 +97,3 @@ static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
|
|||||||
|
|
||||||
## bind to port (default: 80)
|
## bind to port (default: 80)
|
||||||
server.port = 41296
|
server.port = 41296
|
||||||
|
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
----------------------------------------------------------------------
|
|
||||||
-- |
|
|
||||||
-- Maintainer : AR
|
|
||||||
-- Stability : (stable)
|
|
||||||
-- Portability : (portable)
|
|
||||||
--
|
|
||||||
-- > CVS $Date: 2005/05/16 17:07:18 $
|
|
||||||
-- > CVS $Author: aarne $
|
|
||||||
-- > CVS $Revision: 1.11 $
|
|
||||||
--
|
|
||||||
-- chop an HTML file into separate files, each linked to the next and previous.
|
|
||||||
-- the names of the files are n-file, with n = 01,02,...
|
|
||||||
-- the chopping is performed at each separator, here defined as @\<!-- NEW --\>@
|
|
||||||
--
|
|
||||||
-- AR 7\/1\/2002 for the Vinnova meeting in Linköping.
|
|
||||||
-- Added table of contents generation in file 00, 16/4/2005
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
module Main (main) where
|
|
||||||
|
|
||||||
import System.Environment(getArgs)
|
|
||||||
import Data.Char
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = do
|
|
||||||
file:_ <- getArgs
|
|
||||||
htmls file
|
|
||||||
|
|
||||||
htmls :: FilePath -> IO ()
|
|
||||||
htmls file = do
|
|
||||||
s <- readFile file
|
|
||||||
let ss = allPages file s
|
|
||||||
lg = length ss
|
|
||||||
putStrLn $ show lg ++ " slides"
|
|
||||||
mapM_ (uncurry writeFile . mkFile file lg) ss
|
|
||||||
|
|
||||||
allPages :: FilePath -> String -> [(Int,String)]
|
|
||||||
allPages file s = addIndex $ zip [1..] $ map unlines $ chop lss where
|
|
||||||
chop ls = case span isNoSep ls of
|
|
||||||
(s,_:ss) -> s : chop ss
|
|
||||||
_ -> [ls]
|
|
||||||
isNoSep = (/= separator)
|
|
||||||
addIndex = ((0,mkIndex file lss) :)
|
|
||||||
lss = lines s
|
|
||||||
|
|
||||||
mkFile :: FilePath -> Int -> (Int,String) -> (FilePath,String)
|
|
||||||
mkFile base mx (number,content) =
|
|
||||||
(fileName base number,
|
|
||||||
unlines [
|
|
||||||
begHTML,
|
|
||||||
"<font size=1>",
|
|
||||||
pageNum mx number,
|
|
||||||
link base mx number,
|
|
||||||
"</font>",
|
|
||||||
"<p>",
|
|
||||||
content,
|
|
||||||
endHTML
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
begHTML, endHTML, separator :: String
|
|
||||||
begHTML = "<html><body bgcolor=\"#FFFFFF\" text=\"#000000\">"
|
|
||||||
endHTML = "</body></html>"
|
|
||||||
separator = "<!-- NEW -->"
|
|
||||||
|
|
||||||
link :: FilePath -> Int -> Int -> String
|
|
||||||
link file mx n =
|
|
||||||
(if n >= mx-1 then "" else (" <a href=\"" ++ file' ++ "\">Next</a>")) ++
|
|
||||||
(if n == 1 then "" else (" <a href=\"" ++ file_ ++ "\">Previous</a>")) ++
|
|
||||||
(" <a href=\"" ++ file0 ++ "\">Contents</a>") ++
|
|
||||||
(" <a href=\"" ++ file ++ "\">Fulltext</a>") ++
|
|
||||||
(" <a href=\"" ++ file1 ++ "\">First</a>") ++
|
|
||||||
(" <a href=\"" ++ file2 ++ "\">Last</a>")
|
|
||||||
where
|
|
||||||
file_ = fileName file (n - 1)
|
|
||||||
file' = fileName file (n + 1)
|
|
||||||
file0 = fileName file 0
|
|
||||||
file1 = fileName file 1
|
|
||||||
file2 = fileName file (mx - 1)
|
|
||||||
|
|
||||||
fileName :: FilePath -> Int -> FilePath
|
|
||||||
fileName file n = (if n < 10 then ('0':) else id) $ show n ++ "-" ++ file
|
|
||||||
|
|
||||||
pageNum mx num = "<p align=right>" ++ show num ++"/" ++ show (mx-1) ++ "</p>"
|
|
||||||
|
|
||||||
mkIndex file = unlines . mkInd 1 where
|
|
||||||
mkInd n ss = case ss of
|
|
||||||
s : rest | (s==separator) -> mkInd (n+1) rest
|
|
||||||
s : rest -> case getHeading s of
|
|
||||||
Just (i,t) -> mkLine n i t : mkInd n rest
|
|
||||||
_ -> mkInd n rest
|
|
||||||
_ -> []
|
|
||||||
getHeading s = case dropWhile isSpace s of
|
|
||||||
'<':h:i:_:t | isDigit i -> return (i,take (length t - 5) t) -- drop final </hi>
|
|
||||||
_ -> Nothing
|
|
||||||
mkLine _ '1' t = t ++ " : Table of Contents<p>" -- heading of whole document
|
|
||||||
mkLine n i t = stars i ++ link n t ++ "<br>"
|
|
||||||
stars i = case i of
|
|
||||||
'3' -> "<li> "
|
|
||||||
'4' -> "<li>* "
|
|
||||||
_ -> ""
|
|
||||||
link n t = "<a href=\"" ++ fileName file n ++ "\">" ++ t ++ "</a>"
|
|
||||||
@@ -6,7 +6,3 @@ cabal-version: >= 1.8
|
|||||||
Executable gfdoc
|
Executable gfdoc
|
||||||
main-is: GFDoc.hs
|
main-is: GFDoc.hs
|
||||||
build-depends: base, directory>=1.2, time>=1.5, process
|
build-depends: base, directory>=1.2, time>=1.5, process
|
||||||
|
|
||||||
Executable htmls
|
|
||||||
main-is: Htmls.hs
|
|
||||||
build-depends: base
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="src" path="gen"/>
|
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
|
||||||
</classpath>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>GFTranslator</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="org.grammaticalframework.ui.android"
|
|
||||||
android:versionCode="15"
|
|
||||||
android:versionName="1.2.2"
|
|
||||||
android:installLocation="auto" >
|
|
||||||
|
|
||||||
<uses-sdk
|
|
||||||
android:minSdkVersion="11"
|
|
||||||
android:targetSdkVersion="18" />
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
|
||||||
android:icon="@drawable/ic_app"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:theme="@style/AppTheme" android:name="GFTranslator">
|
|
||||||
<activity
|
|
||||||
android:name=".MainActivity"
|
|
||||||
android:label="@string/app_name" >
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity android:name="AlternativesActivity">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
|
||||||
<data android:scheme="gf-translator"/>
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity android:name="HelpActivity"></activity>
|
|
||||||
<activity android:name="SemanticGraphActivity"
|
|
||||||
android:launchMode="singleTop">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEARCH" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="android.app.searchable"
|
|
||||||
android:resource="@xml/searchable"/>
|
|
||||||
<meta-data android:name="android.app.default_searchable"
|
|
||||||
android:value=".SearchableActivity"/>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name="se.chalmers.phrasebook.gui.activities.NavigationActivity"></activity>
|
|
||||||
|
|
||||||
<service android:name="TranslatorInputMethodService"
|
|
||||||
android:permission="android.permission.BIND_INPUT_METHOD">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.view.InputMethod" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="android.view.im" android:resource="@xml/method" />
|
|
||||||
</service>
|
|
||||||
<provider android:name=".LexiconSuggestionProvider"
|
|
||||||
android:authorities="org.grammaticalframework.ui.android.LexiconSuggestionProvider">
|
|
||||||
<path-permission android:pathPrefix="/search_suggest_query"
|
|
||||||
android:readPermission="android.permission.GLOBAL_SEARCH"/>
|
|
||||||
</provider>
|
|
||||||
</application>
|
|
||||||
</manifest>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
BSD LICENSE
|
|
||||||
|
|
||||||
Copyright (c) 1998, Grammatical Framework
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
* Neither the name of the <organization> nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
= Overview =
|
|
||||||
|
|
||||||
This directory contains a sample Android app tht uses
|
|
||||||
the Android speech recognition and TTS APIs along with
|
|
||||||
JNI bindings to the C PGF runtime to implement a simple
|
|
||||||
speech translation app.
|
|
||||||
|
|
||||||
|
|
||||||
= Requirements =
|
|
||||||
|
|
||||||
1. Android SDK: http://developer.android.com/sdk/
|
|
||||||
installed in $ANDROID_SDK_LOCATION
|
|
||||||
|
|
||||||
2. Android NDK: http://developer.android.com/tools/sdk/ndk/
|
|
||||||
installed in $ANDROID_NDK_LOCATION
|
|
||||||
|
|
||||||
= Building =
|
|
||||||
|
|
||||||
Set up Android project:
|
|
||||||
|
|
||||||
# Creates local.properties, not to be checked in
|
|
||||||
$ $ANDROID_SDK_LOCATION/tools/android update project -p .
|
|
||||||
|
|
||||||
Build libs/libjpgf.jar:
|
|
||||||
|
|
||||||
$ (cd ../../runtime/java && javac org/grammaticalframework/*/*.java && jar -cf ../../ui/android/libs/jpgf.jar org/grammaticalframework/*/*.class)
|
|
||||||
|
|
||||||
Build JNI code:
|
|
||||||
|
|
||||||
$ cd jni
|
|
||||||
$ $ANDROID_NDK_LOCATION/ndk-build
|
|
||||||
|
|
||||||
Build the semantic database code:
|
|
||||||
|
|
||||||
$ runghc glosses.hs
|
|
||||||
|
|
||||||
Build APK:
|
|
||||||
|
|
||||||
$ ant debug
|
|
||||||
|
|
||||||
|
|
||||||
Install on your device:
|
|
||||||
|
|
||||||
$ ant debug install
|
|
||||||
|
|
||||||
or:
|
|
||||||
|
|
||||||
$ adb install -r bin/MainActivity-debug.apk
|
|
||||||
|
|
||||||
|
|
||||||
= Changing the grammar =
|
|
||||||
|
|
||||||
1. Replace assets/ResourceDemo.pgf
|
|
||||||
|
|
||||||
2. Edit Translator.java to point to the new file and include its metadata
|
|
||||||
|
|
||||||
|
|
||||||
= Developing in Eclipse =
|
|
||||||
|
|
||||||
1. Install Android ADT
|
|
||||||
|
|
||||||
2. Eclipse > File > Import > Existing Projects into Workspace > Next
|
|
||||||
|
|
||||||
3. Select root directory...
|
|
||||||
|
|
||||||
4. Select GF/src/ui/android
|
|
||||||
|
|
||||||
5. Finish
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
key.store=/home/krasimir/dg/src/keys/dg_keystore
|
|
||||||
key.alias=dg
|
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
<html>
|
|
||||||
<body>
|
|
||||||
</p>
|
|
||||||
<b>GF Offline Translator</b>:
|
|
||||||
text and speech translation for 16 languages with
|
|
||||||
quality control. Version 19 April 2017 (beta).
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Speech input</b>: Tap microphone icon and talk while it is red.
|
|
||||||
<br>
|
|
||||||
<b>Text input</b>: Select "keyboard" from menu, tap keyboard icon.
|
|
||||||
<br>
|
|
||||||
<b>Correction</b>: Tap input text and edit.
|
|
||||||
<br>
|
|
||||||
<b>Alternatives</b>: Tap output text.
|
|
||||||
<br>
|
|
||||||
<b>Grammar info</b>: Tap any of the alternatives.
|
|
||||||
<br>
|
|
||||||
<b>Confidence</b>: colour of output text
|
|
||||||
<ul>
|
|
||||||
<li><span style="background-color:palegreen">Green</span>: semantic, probably correct (but has alternatives)</li>
|
|
||||||
<li><span style="background-color:yellow">Yellow</span>: syntactic, often incorrect (has alternatives)</li>
|
|
||||||
<li><span style="background-color:pink">Light red</span>: chunk-based, probably incorrect (has alternatives)</li>
|
|
||||||
<li><span style="background-color:red">Dark red</span>: word-based, often very bad</li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
<b>Topics</b> (new, select from menu): Words grouped by semantic categories, with WordNet glosses.
|
|
||||||
<br>
|
|
||||||
<b>Phrasebook</b> (new, select from menu): Conceptual authoring with the green translations.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h2>More details</h2>
|
|
||||||
<p>
|
|
||||||
GF Offline Translator is based on grammar and semantics. It is compact in size
|
|
||||||
and gives control on quality. Its technology is inspired by compilers, which are
|
|
||||||
programs that translate computer languages.
|
|
||||||
Most other translators for human language are based on
|
|
||||||
statistics and have less control of quality and are much bigger, so that
|
|
||||||
they require either an internet connection or a huge storage on your phone.
|
|
||||||
</p>
|
|
||||||
The app indicates translation confidence with colours:
|
|
||||||
<ul>
|
|
||||||
<li><b>Green</b>:
|
|
||||||
semantic translation, should be correct.
|
|
||||||
But not necessarily the only correct one.
|
|
||||||
You can tap the output to see alternatives.
|
|
||||||
</li>
|
|
||||||
<li><b>Yellow</b>:
|
|
||||||
syntactic translation, should be grammatically correct.
|
|
||||||
But can be very strange in its interpretation and choice of words.
|
|
||||||
</li>
|
|
||||||
<li><b>Light red</b>:
|
|
||||||
chunk translation, probably incorrect.
|
|
||||||
Builds the translation from small pieces.
|
|
||||||
</li>
|
|
||||||
<li><b>Dark red</b>:
|
|
||||||
word-by-word translation, almost certainly incorrect.
|
|
||||||
Builds the translation word by word.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
The green translations come from a tourist phrasebook, which allows
|
|
||||||
you to translate things like "hello" and "how far is the airport from
|
|
||||||
the hotel".
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
You can translate both speech and text, as selected in the menu in the
|
|
||||||
upper right corner. Both kinds of input can be edited with the
|
|
||||||
keyboard by first tapping at the input field. This is often needed
|
|
||||||
because of <b>speech recognition errors</b>. Changing words
|
|
||||||
from <b>upper to lower case</b> may also be needed.
|
|
||||||
At the moment, <b>Japanese</b> and <b>Thai</b> input must be separated
|
|
||||||
to words, whereas Chinese works without spaces.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Translation works between any of the 16 supported languages, which means 240
|
|
||||||
language pairs in the current version. But different languages are on different levels of development.
|
|
||||||
The following table gives a rough idea of what to expect:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<center>
|
|
||||||
<table rules=all border=yes>
|
|
||||||
<tr> <th></th> <th>coverage</th> <th>quality</th> <th>speed</th> <th>speech</th> </tr>
|
|
||||||
<tr> <th>Bulgarian</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td><td bgcolor=palegreen></td> <td bgcolor=yellow>in only</td></tr>
|
|
||||||
<tr> <th>Catalan</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=yellow></td></tr>
|
|
||||||
<tr> <th>Chinese</th> <td bgcolor=pink></td> <td bgcolor=pink></td> <td bgcolor=palegreen></td> <td bgcolor=yellow></td> </tr>
|
|
||||||
<tr> <th>Dutch</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td> <td bgcolor=yellow></td> <td bgcolor=palegreen></td> </tr>
|
|
||||||
<tr> <th>English</th> <td bgcolor=palegreen></td> <td bgcolor=palegreen></td> <td bgcolor=palegreen></td> <td bgcolor=palegreen></td> </tr>
|
|
||||||
<tr> <th>Estonian</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=red></td></tr>
|
|
||||||
<tr> <th>Finnish</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=yellow></td></tr>
|
|
||||||
<tr> <th>French</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
|
|
||||||
<tr> <th>German</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
|
|
||||||
<tr> <th>Hindi</th> <td bgcolor=pink></td> <td bgcolor=red></td> <td bgcolor=yellow></td> <td bgcolor=yellow></td> </tr>
|
|
||||||
<tr> <th>Italian</th> <td bgcolor=pink></td> <td bgcolor=pink></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
|
|
||||||
<tr> <th>Japanese*</th><td bgcolor=pink></td> <td bgcolor=pink></td><td bgcolor=yellow></td> <td bgcolor=palegreen></td></tr>
|
|
||||||
<tr> <th>Russian</th> <td bgcolor=pink></td> <td bgcolor=red></td> <td bgcolor=yellow></td> <td bgcolor=yellow></td> </tr>
|
|
||||||
<tr> <th>Spanish</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
|
|
||||||
<tr> <th>Swedish</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td> <td bgcolor=palegreen></td> <td bgcolor=yellow></td></tr>
|
|
||||||
<tr> <th>Thai*</th> <td bgcolor=pink></td> <td bgcolor=pink></td><td bgcolor=yellow></td> <td bgcolor=palegreen></td></tr>
|
|
||||||
</table>
|
|
||||||
</center>
|
|
||||||
* For translation from Japanese and Thai you need to separate each word with a space
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The speech input and output use Google's voice services. Their status
|
|
||||||
can hence change without notice. You can make it more stable by
|
|
||||||
installing third-party speech tools, such as SVOX, which provides
|
|
||||||
output for most of the listed languages.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
When you tap on a translation you get a screen with <b>alternative translations</b>.
|
|
||||||
Tapping on each of the alternatives
|
|
||||||
gives you <b>grammatical information</b>:
|
|
||||||
an inflection table, if it is a single word,
|
|
||||||
and a syntax tree otherwise.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The app also provides an <b>input method</b> which you can use as
|
|
||||||
an alternative keyboard which allows you to do translation from
|
|
||||||
other applications, for instance while you are entering SMS or e-mail.
|
|
||||||
To activate it go to Settings > Language & input.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The translation works <b>completely off-line</b>, without
|
|
||||||
internet connection, when doing text-based translation.
|
|
||||||
Even speech works off-line in some languages,
|
|
||||||
but being on-line may give you better
|
|
||||||
speech input and output and more languages.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
You can also install third-party off-line speech engines, such as
|
|
||||||
<a href="https://play.google.com/store/apps/developer?id=SVOX+Mobile+Voices&hl=en">SVOX</a>.
|
|
||||||
Consult the voice/language settings on your phone to find the optimal
|
|
||||||
speech engines, and restart the app after changing the settings.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The GF Offline Translator is powered by
|
|
||||||
<a href="http://www.grammaticalframework.org/">GF</a>, Grammatical Framework.
|
|
||||||
It is open-source software,
|
|
||||||
built by support from the GF community and from <a href="http://www.digitalgrammars.com/">Digital Grammars</a>.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<i>Digital Grammars is a company that can tailor this app to you needs and provide good
|
|
||||||
translation for the kind of vocabulary you need. Just tell us what you want to see
|
|
||||||
in the green area!</i>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project name="MainActivity" default="help">
|
|
||||||
|
|
||||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
|
||||||
It contains the path to the SDK. It should *NOT* be checked into
|
|
||||||
Version Control Systems. -->
|
|
||||||
<property file="local.properties" />
|
|
||||||
|
|
||||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
|
||||||
'android' tool to add properties to it.
|
|
||||||
This is the place to change some Ant specific build properties.
|
|
||||||
Here are some properties you may want to change/update:
|
|
||||||
|
|
||||||
source.dir
|
|
||||||
The name of the source directory. Default is 'src'.
|
|
||||||
out.dir
|
|
||||||
The name of the output directory. Default is 'bin'.
|
|
||||||
|
|
||||||
For other overridable properties, look at the beginning of the rules
|
|
||||||
files in the SDK, at tools/ant/build.xml
|
|
||||||
|
|
||||||
Properties related to the SDK location or the project target should
|
|
||||||
be updated using the 'android' tool with the 'update' action.
|
|
||||||
|
|
||||||
This file is an integral part of the build system for your
|
|
||||||
application and should be checked into Version Control Systems.
|
|
||||||
|
|
||||||
-->
|
|
||||||
<property file="ant.properties" />
|
|
||||||
|
|
||||||
<!-- if sdk.dir was not set from one of the property file, then
|
|
||||||
get it from the ANDROID_HOME env var.
|
|
||||||
This must be done before we load project.properties since
|
|
||||||
the proguard config can use sdk.dir -->
|
|
||||||
<property environment="env" />
|
|
||||||
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
|
||||||
<isset property="env.ANDROID_HOME" />
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<!-- The project.properties file is created and updated by the 'android'
|
|
||||||
tool, as well as ADT.
|
|
||||||
|
|
||||||
This contains project specific properties such as project target, and library
|
|
||||||
dependencies. Lower level build properties are stored in ant.properties
|
|
||||||
(or in .classpath for Eclipse projects).
|
|
||||||
|
|
||||||
This file is an integral part of the build system for your
|
|
||||||
application and should be checked into Version Control Systems. -->
|
|
||||||
<loadproperties srcFile="project.properties" />
|
|
||||||
|
|
||||||
<!-- quick check on sdk.dir -->
|
|
||||||
<fail
|
|
||||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
|
|
||||||
unless="sdk.dir"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Import per project custom build rules if present at the root of the project.
|
|
||||||
This is the place to put custom intermediary targets such as:
|
|
||||||
-pre-build
|
|
||||||
-pre-compile
|
|
||||||
-post-compile (This is typically used for code obfuscation.
|
|
||||||
Compiled code location: ${out.classes.absolute.dir}
|
|
||||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
|
||||||
-post-package
|
|
||||||
-post-build
|
|
||||||
-pre-clean
|
|
||||||
-->
|
|
||||||
<import file="custom_rules.xml" optional="true" />
|
|
||||||
|
|
||||||
<!-- Import the actual build file.
|
|
||||||
|
|
||||||
To customize existing targets, there are two options:
|
|
||||||
- Customize only one target:
|
|
||||||
- copy/paste the target into this file, *before* the
|
|
||||||
<import> task.
|
|
||||||
- customize it to your needs.
|
|
||||||
- Customize the whole content of build.xml
|
|
||||||
- copy/paste the content of the rules files (minus the top node)
|
|
||||||
into this file, replacing the <import> task.
|
|
||||||
- customize to your needs.
|
|
||||||
|
|
||||||
***********************
|
|
||||||
****** IMPORTANT ******
|
|
||||||
***********************
|
|
||||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
|
||||||
in order to avoid having your file be overridden by tools such as "android update project"
|
|
||||||
-->
|
|
||||||
<!-- version-tag: 1 -->
|
|
||||||
<import file="/Users/aarne/Library/Android/apache-ant-1.9.4/fetch.xml" />
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
digraph {
|
|
||||||
rankdir=LR ;
|
|
||||||
node [shape = record] ;
|
|
||||||
bgcolor = "#FFFFFF00" ;
|
|
||||||
|
|
||||||
struct0[label = "<n0>твоят | <n1>телефон | <n2>може | <n3>да | <n4>превежда"] ;
|
|
||||||
struct0:n0:e -> struct1:n0:w ;
|
|
||||||
struct0:n1:e -> struct1:n1:w ;
|
|
||||||
struct0:n2:e -> struct1:n2:w ;
|
|
||||||
struct0:n4:e -> struct1:n3:w ;
|
|
||||||
struct1[label = "<n0>el teu | <n1>telèfon | <n2>sap | <n3>traduir"] ;
|
|
||||||
struct1:n0:e -> struct2:n0:w ;
|
|
||||||
struct1:n1:e -> struct2:n2:w ;
|
|
||||||
struct1:n2:e -> struct2:n3:w ;
|
|
||||||
struct1:n3:e -> struct2:n4:w ;
|
|
||||||
struct2[label = "<n0>你 | <n1>的 | <n2>电 话 | <n3>会 | <n4>翻 译"] ;
|
|
||||||
struct2:n0:e -> struct3:n0:w ;
|
|
||||||
struct2:n2:e -> struct3:n1:w ;
|
|
||||||
struct2:n3:e -> struct3:n2:w ;
|
|
||||||
struct2:n4:e -> struct3:n3:w ;
|
|
||||||
struct3[label = "<n0>je | <n1>telefoon | <n2>kan | <n3>vertalen"] ;
|
|
||||||
struct3:n0:e -> struct4:n0:w ;
|
|
||||||
struct3:n1:e -> struct4:n1:w ;
|
|
||||||
struct3:n2:e -> struct4:n2:w ;
|
|
||||||
struct3:n3:e -> struct4:n3:w ;
|
|
||||||
struct4[label = "<n0>your | <n1>phone | <n2>can | <n3>translate"] ;
|
|
||||||
struct4:n1:e -> struct5:n1:w ;
|
|
||||||
struct4:n2:e -> struct5:n2:w ;
|
|
||||||
struct4:n3:e -> struct5:n3:w ;
|
|
||||||
struct5[label = "<n1>puhelimesi | <n2>osaa | <n3>kääntää"] ;
|
|
||||||
struct5:n1:e -> struct6:n1:w ;
|
|
||||||
struct5:n2:e -> struct6:n2:w ;
|
|
||||||
struct5:n3:e -> struct6:n3:w ;
|
|
||||||
struct6[label = "<n0>ton | <n1>téléphone | <n2>sait | <n3>traduire"] ;
|
|
||||||
struct6:n0:e -> struct7:n0:w ;
|
|
||||||
struct6:n1:e -> struct7:n1:w ;
|
|
||||||
struct6:n2:e -> struct7:n2:w ;
|
|
||||||
struct6:n3:e -> struct7:n3:w ;
|
|
||||||
struct7[label = "<n0>dein | <n1>Telefon | <n2>kann | <n3>übersetzen"] ;
|
|
||||||
struct7:n0:e -> struct8:n0:w ;
|
|
||||||
struct7:n1:e -> struct8:n1:w ;
|
|
||||||
struct7:n2:e -> struct8:n3:w ;
|
|
||||||
struct7:n3:e -> struct8:n2:w ;
|
|
||||||
struct8[label = "<n0>तुम्हारा | <n1>फोन | <n2>अनुवाद कर | <n3>सकता | <n4>है"] ;
|
|
||||||
struct8:n0:e -> struct9:n1:w ;
|
|
||||||
struct8:n1:e -> struct9:n2:w ;
|
|
||||||
struct8:n2:e -> struct9:n4:w ;
|
|
||||||
struct8:n3:e -> struct9:n3:w ;
|
|
||||||
struct9[label = "<n0>il | <n1>tuo | <n2>telefono | <n3>sa | <n4>tradurre"] ;
|
|
||||||
struct9:n1:e -> struct10:n0:w ;
|
|
||||||
struct9:n2:e -> struct10:n1:w ;
|
|
||||||
struct9:n3:e -> struct10:n2:w ;
|
|
||||||
struct9:n4:e -> struct10:n3:w ;
|
|
||||||
struct10[label = "<n0>tu | <n1>teléfono | <n2>sabe | <n3>traducir"] ;
|
|
||||||
struct10:n0:e -> struct11:n0:w ;
|
|
||||||
struct10:n1:e -> struct11:n1:w ;
|
|
||||||
struct10:n2:e -> struct11:n2:w ;
|
|
||||||
struct10:n3:e -> struct11:n3:w ;
|
|
||||||
struct11[label = "<n0>din | <n1>telefon | <n2>kan | <n3>översätta"] ;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
|
||||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<?xml-stylesheet type="text/css" href="http://fonts.googleapis.com/css?family=Inconsolata"?>
|
|
||||||
|
|
||||||
<svg width="1024" height="500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
||||||
<filter id="A"><feGaussianBlur stdDeviation="2"/></filter>
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
|
|
||||||
<stop offset="0%" style="stop-color:#a8d8ff;stop-opacity:1" />
|
|
||||||
<stop offset="100%" style="stop-color:#f6f6f6;stop-opacity:1" />
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<rect width="1024" height="500" style="fill:url(#grad1)"/>
|
|
||||||
<path filter="url(#A)"
|
|
||||||
d="M120,270 v-51 h59 m-59,0 v-53 h114 a110.5,105 0 1,1 -24,-66"
|
|
||||||
fill="none" stroke="black" stroke-width="4" opacity="0.25"
|
|
||||||
stroke-linejoin="round" stroke-linecap="round"/>
|
|
||||||
<path d="M120,270 v-51 h59 m-59,0 v-53 h114 a110.5,105 0 1,1 -24,-66"
|
|
||||||
fill="none" stroke="red" stroke-width="4"
|
|
||||||
stroke-linejoin="round" stroke-linecap="round"/>
|
|
||||||
<text x="310" y="120" font-size="70" font-family="Inconsolata">Offline Translation</text>
|
|
||||||
<text x="600" y="170" font-size="35" font-family="Inconsolata">with</text>
|
|
||||||
<text x="270" y="240" font-size="70" font-family="Inconsolata" fill="black" opacity="0.25" filter="url(#A)">Grammatical Framework</text>
|
|
||||||
<text x="270" y="240" font-size="70" font-family="Inconsolata" fill="#06c">Grammatical Framework</text>
|
|
||||||
<image x="0" y="270" width="1024" height="200"
|
|
||||||
xlink:href="gf-translator-alignment.png" />
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,46 +0,0 @@
|
|||||||
import SG
|
|
||||||
import PGF2
|
|
||||||
import Data.Char
|
|
||||||
import Data.List
|
|
||||||
|
|
||||||
main = do
|
|
||||||
db <- openSG "assets/semantics.db"
|
|
||||||
inTransaction db $ do
|
|
||||||
ls <- fmap lines $ readFile "../../../lib/src/translator/Dictionary.gf"
|
|
||||||
let glosses = [x | Just (fn,gloss) <- map gloss ls, x <- glossTriples fn gloss]
|
|
||||||
topics <- fmap (map toTriple . lines) $ readFile "topics.txt"
|
|
||||||
sequence_ [insertTriple db s p o | (s,p,o) <- glosses++topics]
|
|
||||||
closeSG db
|
|
||||||
|
|
||||||
toTriple l =
|
|
||||||
case readTriple l of
|
|
||||||
Just t -> t
|
|
||||||
Nothing -> error ("topics.txt: "++l)
|
|
||||||
|
|
||||||
gloss l =
|
|
||||||
case words l of
|
|
||||||
("fun":fn:_) -> case dropWhile (/='\t') l of
|
|
||||||
'\t':l -> Just (fn,l)
|
|
||||||
_ -> Nothing
|
|
||||||
_ -> Nothing
|
|
||||||
|
|
||||||
glossTriples fn s =
|
|
||||||
(if null gs then [] else [(fn_e,gloss,mkStr (merge gs))])++
|
|
||||||
(if null es then [] else [(fn_e,example,mkStr (merge (map (init . tail) es)))])
|
|
||||||
where
|
|
||||||
fn_e = mkApp fn []
|
|
||||||
gloss = mkApp "gloss" []
|
|
||||||
example = mkApp "example" []
|
|
||||||
(es,gs) = partition isExample (splitGloss s)
|
|
||||||
|
|
||||||
splitGloss s =
|
|
||||||
let (xs,s') = break (==';') s
|
|
||||||
in trim xs : case s' of
|
|
||||||
';':s -> splitGloss s
|
|
||||||
_ -> []
|
|
||||||
where
|
|
||||||
trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace
|
|
||||||
|
|
||||||
merge = intercalate "; "
|
|
||||||
|
|
||||||
isExample s = not (null s) && head s == '"' && last s == '"'
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
|
||||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<?xml-stylesheet type="text/css" href="http://fonts.googleapis.com/css?family=Inconsolata"?>
|
|
||||||
|
|
||||||
<svg width="250" height="250" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<desc>Digital Grammar Logo</desc>
|
|
||||||
|
|
||||||
<path d="M205,200 a110,110 0 1,1 0,-150 M125,15 v110 h80 M165,95 v60 M205,95 v60" fill="none" stroke="red" stroke-width="14" stroke-linejoin="round" stroke-linecap="round"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 529 B |
@@ -1,28 +0,0 @@
|
|||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
jni_c_files := jpgf.c jsg.c jni_utils.c
|
|
||||||
sg_c_files := sg.c sqlite3Btree.c
|
|
||||||
pgf_c_files := data.c expr.c graphviz.c linearizer.c literals.c parser.c parseval.c pgf.c printer.c reader.c \
|
|
||||||
reasoner.c evaluator.c jit.c typechecker.c lookup.c aligner.c writer.c
|
|
||||||
gu_c_files := assert.c choice.c exn.c fun.c in.c map.c out.c utf8.c \
|
|
||||||
bits.c defs.c enum.c file.c hash.c mem.c prime.c seq.c string.c ucs.c variant.c
|
|
||||||
|
|
||||||
LOCAL_MODULE := jpgf
|
|
||||||
LOCAL_SRC_FILES := $(addprefix ../../../runtime/java/, $(jni_c_files)) \
|
|
||||||
$(addprefix ../../../runtime/c/sg/, $(sg_c_files)) \
|
|
||||||
$(addprefix ../../../runtime/c/pgf/, $(pgf_c_files)) \
|
|
||||||
$(addprefix ../../../runtime/c/gu/, $(gu_c_files))
|
|
||||||
LOCAL_C_INCLUDES := ../../../runtime/c
|
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
|
||||||
|
|
||||||
$(realpath ../obj/local/armeabi/objs/jpgf/__/__/__/runtime/c/pgf/jit.o): lightning
|
|
||||||
$(realpath ../obj/local/armeabi/objs-debug/jpgf/__/__/__/runtime/c/pgf/jit.o): lightning
|
|
||||||
|
|
||||||
lightning:
|
|
||||||
ln -s -f arm/asm.h ../../../runtime/c/pgf/lightning/asm.h
|
|
||||||
ln -s -f arm/core.h ../../../runtime/c/pgf/lightning/core.h
|
|
||||||
ln -s -f arm/fp.h ../../../runtime/c/pgf/lightning/fp.h
|
|
||||||
ln -s -f arm/funcs.h ../../../runtime/c/pgf/lightning/funcs.h
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
APP_PLATFORM := android-8
|
|
||||||
APP_CFLAGS := -std=gnu99
|
|
||||||
APP_OPTIM := release
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# To enable ProGuard in your project, edit project.properties
|
|
||||||
# to define the proguard.config property as described in that file.
|
|
||||||
#
|
|
||||||
# Add project specific ProGuard rules here.
|
|
||||||
# By default, the flags in this file are appended to flags specified
|
|
||||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the ProGuard
|
|
||||||
# include property in project.properties.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# This file is automatically generated by Android Tools.
|
|
||||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
|
||||||
#
|
|
||||||
# This file must be checked in Version Control Systems.
|
|
||||||
#
|
|
||||||
# To customize properties used by the Ant build system edit
|
|
||||||
# "ant.properties", and override values to adapt the script to your
|
|
||||||
# project structure.
|
|
||||||
#
|
|
||||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
|
||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
|
||||||
|
|
||||||
# Project target.
|
|
||||||
target=android-21
|
|
||||||
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 436 B |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 695 B |
|
Before Width: | Height: | Size: 665 B |
|
Before Width: | Height: | Size: 390 B |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 885 B |
|
Before Width: | Height: | Size: 536 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 859 B |
|
Before Width: | Height: | Size: 327 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 437 B |
|
Before Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 465 B |
|
Before Width: | Height: | Size: 771 B |
|
Before Width: | Height: | Size: 337 B |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 436 B |
|
Before Width: | Height: | Size: 547 B |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 783 B |
|
Before Width: | Height: | Size: 464 B |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 202 B |
|
Before Width: | Height: | Size: 684 B |
|
Before Width: | Height: | Size: 868 B |
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<corners android:radius="4dp" />
|
|
||||||
<solid android:color="#CDCDED" />
|
|
||||||
</shape>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
|
||||||
<stroke android:width="1dp"
|
|
||||||
android:color="@color/primary_color" />
|
|
||||||
<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />
|
|
||||||
<corners android:radius="8dp" />
|
|
||||||
</shape>
|
|
||||||
|
Before Width: | Height: | Size: 282 B |
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<corners android:radius="4dp" />
|
|
||||||
<solid android:color="@color/primary_color" />
|
|
||||||
</shape>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<corners android:radius="4dp" />
|
|
||||||
<solid android:color="#FFB2A5" />
|
|
||||||
</shape>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<corners android:radius="4dp" />
|
|
||||||
<solid android:color="#FFFF99" />
|
|
||||||
</shape>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<corners android:radius="4dp" />
|
|
||||||
<solid android:color="#FF303e" />
|
|
||||||
</shape>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent" >
|
|
||||||
|
|
||||||
<WebView
|
|
||||||
android:id="@+id/help_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
/>
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<android.support.v4.widget.DrawerLayout
|
|
||||||
android:id="@+id/drawer_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<!-- The main content view -->
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/lexical_header"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:background="#C0C0C0">
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.LanguageSelector
|
|
||||||
android:id="@+id/show_language"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:padding="0dp"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/lexical_desc"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/lexical_header"
|
|
||||||
android:paddingLeft="1dp"
|
|
||||||
android:paddingTop="4dp"
|
|
||||||
android:paddingBottom="2dp"
|
|
||||||
android:textSize="25sp"/>
|
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_below="@id/lexical_desc"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingLeft="1dp"
|
|
||||||
android:id="@android:id/list" >
|
|
||||||
</ListView>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<!-- The navigation drawer -->
|
|
||||||
<ListView android:id="@+id/topics_list"
|
|
||||||
android:layout_width="250dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="start"
|
|
||||||
android:choiceMode="singleChoice"
|
|
||||||
android:divider="@android:color/transparent"
|
|
||||||
android:dividerHeight="0dp"
|
|
||||||
android:background="#FFFFE0"/>
|
|
||||||
</android.support.v4.widget.DrawerLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/progressBarView"
|
|
||||||
android:gravity="center"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:background="#00000000"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/top_bg"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:background="#C0C0C0">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/start_stop"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_alignTop="@+id/source_language"
|
|
||||||
android:layout_alignBottom="@+id/target_language"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:src="@drawable/ic_mic"
|
|
||||||
android:contentDescription="@string/microphone"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/switch_languages"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_alignTop="@+id/source_language"
|
|
||||||
android:layout_alignBottom="@+id/target_language"
|
|
||||||
android:layout_toLeftOf="@id/start_stop"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:src="@drawable/ic_action_switch"
|
|
||||||
android:contentDescription="@string/switch_languages"/>
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.LanguageSelector
|
|
||||||
android:id="@+id/source_language"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_toLeftOf="@id/switch_languages"
|
|
||||||
android:padding="0dp"/>
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.LanguageSelector
|
|
||||||
android:id="@+id/target_language"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_below="@id/source_language"
|
|
||||||
android:layout_toLeftOf="@id/switch_languages"
|
|
||||||
android:padding="0dp"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.ConversationView
|
|
||||||
android:id="@+id/conversation"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_below="@id/top_bg">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/conversation_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp"/>
|
|
||||||
</org.grammaticalframework.ui.android.ConversationView>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/progressBarView"
|
|
||||||
android:gravity="center"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:background="#00000000"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
|
|
||||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/drawer_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".gui.activities.NavigationActivity">
|
|
||||||
|
|
||||||
<!-- As the main content view, the view below consumes the entire
|
|
||||||
space available using match_parent in both dimensions. -->
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
</android.support.v4.widget.DrawerLayout>
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/graph_header"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:background="#C0C0C0">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/add_word"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:src="@drawable/ic_search_black_24dp"/>
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.LanguageSelector
|
|
||||||
android:id="@+id/show_language"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_toLeftOf="@id/add_word"
|
|
||||||
android:padding="0dp"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.SemanticGraphView
|
|
||||||
android:id="@+id/semantic_graph"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_below="@id/graph_header"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/progressBarView"
|
|
||||||
android:gravity="center"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:background="#00000000"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="match_parent">
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent" >
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/arrow"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:contentDescription="@string/open_image"
|
|
||||||
android:src="@drawable/open_arrow"
|
|
||||||
android:paddingLeft="10dp"
|
|
||||||
android:paddingRight="5dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/alternative_desc"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toRightOf="@id/arrow"
|
|
||||||
android:paddingLeft="10dp"
|
|
||||||
android:textSize="25sp"/>
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.ParseTreeView
|
|
||||||
android:id="@+id/desc_details"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/alternative_desc"
|
|
||||||
android:textSize="25sp"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/abstract_tree"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/desc_details"
|
|
||||||
android:textSize="15sp"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:id="@+id/choice_checkbox" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_gravity="left"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:inputType="textNoSuggestions"
|
|
||||||
android:background="@drawable/first_person_utterance_bg"
|
|
||||||
/>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:descendantFocusability="blocksDescendants"
|
|
||||||
tools:context="se.chalmers.phrasebook.gui.fragments.PhraseListFragment">
|
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/phrase_listView"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@drawable/grid_phrasebook_button"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:id="@+id/fragment_translation">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="New Text"
|
|
||||||
android:textSize="24dp"
|
|
||||||
android:id="@+id/origin_phrase"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:maxLines="4"
|
|
||||||
android:scrollHorizontally="false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="New Text"
|
|
||||||
android:textSize="24dp"
|
|
||||||
android:id="@+id/target_phrase"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:maxLines="4"
|
|
||||||
android:scrollHorizontally="false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/button3"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:src="@drawable/ic_volume_up_black_18dp"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/input_holder"
|
|
||||||
android:divider="@android:color/transparent"
|
|
||||||
android:padding="8dp"/>
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.TranslatorKeyboardView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/keyboard"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
/>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TableLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="5dp"
|
|
||||||
android:layout_margin="1dp"
|
|
||||||
>
|
|
||||||
<ImageButton android:id="@+id/closeButton"
|
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:src="@drawable/btn_close"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:padding="5dp"
|
|
||||||
android:clickable="true"
|
|
||||||
/>
|
|
||||||
</TableLayout>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TextView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:textSize="20sp"
|
|
||||||
/>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent" >
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/arrow"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:contentDescription="@string/open_image"
|
|
||||||
android:src="@drawable/open_arrow"
|
|
||||||
android:paddingLeft="10dp"
|
|
||||||
android:paddingRight="5dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/lexical_desc"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toRightOf="@id/arrow"
|
|
||||||
android:paddingLeft="10dp"
|
|
||||||
android:textSize="25sp"/>
|
|
||||||
|
|
||||||
<WebView
|
|
||||||
android:id="@+id/desc_details"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/lexical_desc"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="New Text"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:id="@+id/textView_number" />
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:max="100"
|
|
||||||
android:id="@+id/seekBar" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="numberPassword"
|
|
||||||
android:ems="10"
|
|
||||||
android:id="@+id/editNumber" />
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:textColor="@color/text_colour_light"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:text="New Text"
|
|
||||||
android:id="@+id/textView3"
|
|
||||||
android:padding="8dp"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
||||||
|
|
||||||