Latvian: 1) added some extra things that are used by the Attempto grammar; 2) added notpresent tags; 3) compiles with Setup.hs and lib/src/Make.hs

This commit is contained in:
normundsg
2012-02-20 02:42:07 +00:00
parent 30d3fc8b4d
commit 1966ce5eb6
13 changed files with 157 additions and 106 deletions

View File

@@ -73,7 +73,7 @@ rglCommands =
do let dir = getRGLBuildDir lbi mode
createDirectoryIfMissing True dir
sequence_ [run_gfc pkg lbi ["-s","-make","-name=Lang"++la,
dir ++ "/Lang" ++ la ++ ".gfo"]
dir ++ "/Lang" ++ la ++ ".gfo"]
| (_,la) <- optl langsPGF args]
run_gfc pkg lbi (["-s","-make","-name=Lang"]++
["Lang" ++ la ++ ".pgf"|(_,la)<-optl langsPGF args])
@@ -190,7 +190,7 @@ rgl_dst_dir lbi = buildDir lbi </> "rgl"
-- the languages have long directory names and short ISO codes (3 letters)
-- we also give the decodings for postprocessing linearizations, as long as grammars
-- don't support all flags needed; they are used in tests
langsCoding = [
(("amharic", "Amh"),""),
(("arabic", "Ara"),""),
@@ -206,13 +206,14 @@ langsCoding = [
(("interlingua","Ina"),""),
(("italian", "Ita"),""),
(("latin", "Lat"),""),
(("latvian", "Lav"),""),
(("norwegian","Nor"),""),
(("polish", "Pol"),""),
(("punjabi", "Pnb"),""),
(("romanian", "Ron"),""),
(("russian", "Rus"),""),
(("spanish", "Spa"),""),
(("swedish", "Swe"),""),
(("swedish", "Swe"),""),
(("thai", "Tha"),"to_thai"),
(("turkish", "Tur"),""),
(("urdu", "Urd"),"")
@@ -227,14 +228,14 @@ langs = map fst langsCoding
langsLang = langs `except` ["Amh","Ara","Lat","Hin","Tha","Tur"]
--langsLang = langs `only` ["Fin"] --test
-- languages for which to compile Try
-- languages for which to compile Try
langsAPI = langsLang `except` ["Hin","Ina","Tha"]
-- languages for which to compile Symbolic
-- languages for which to compile Symbolic
langsSymbolic = langsAPI -- `except` ["Rus"]
-- languages for which to run demo test
langsDemo = langsLang `except` ["Ara","Hin","Ina","Tha"]
langsDemo = langsLang `except` ["Ara","Hin","Ina","Lav","Tha"]
-- languages for which to compile parsing grammars
langsParse = langs `only` ["Eng"]
@@ -243,7 +244,7 @@ langsParse = langs `only` ["Eng"]
langsPGF = langsLang `except` ["Ara","Hin","Ron","Tha"]
-- languages for which Compatibility exists (to be extended)
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Spa","Swe"]
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Lav","Spa","Swe"]
gfc modes pkg lbi file = sequence_ [gfc1 mode pkg lbi file | mode<-modes]
gfc1 mode pkg lbi file = do
@@ -264,7 +265,7 @@ gf comm files pkg lbi = do
out <- readProcess gf ("-s":files) comm
putStrLn out
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
" | ps -to_html | wf -file=resdemo.html"
lang (lla,la) = rgl_src_dir </> lla </> ("All" ++ la ++ ".gf")
@@ -285,7 +286,7 @@ getOptMode args =
then default_modes
else explicit_modes
where
explicit_modes =
explicit_modes =
[Minimal|have "minimal"]++
[Present|have "present"]++
[AllTenses|have "alltenses"]
@@ -330,17 +331,17 @@ getRGLCommands args =
langs_prefix = "langs="
rgl_prefix = "rgl-"
unlexer abstr ls =
"-unlexer=\\\"" ++ unwords
[abstr ++ la ++ "=" ++ unl |
lla@(_,la) <- ls, let unl = unlex lla, not (null unl)] ++
unlexer abstr ls =
"-unlexer=\\\"" ++ unwords
[abstr ++ la ++ "=" ++ unl |
lla@(_,la) <- ls, let unl = unlex lla, not (null unl)] ++
"\\\""
where
unlex lla = maybe "" id $ lookup lla langsCoding
-- | Runs the gf executable in compile mode with the given arguments.
run_gfc :: PackageDescription -> LocalBuildInfo -> [String] -> IO ()
run_gfc pkg lbi args =
run_gfc pkg lbi args =
do let args' = ["-batch","-gf-lib-path="++rgl_src_dir,"+RTS","-K32M","-RTS"] ++ filter (not . null) args
gf = default_gf pkg lbi
gf_cmdline = gf ++ " " ++ unwords (map showArg args')

View File

@@ -8,12 +8,12 @@ import System.Environment
import System.Exit
-- Make commands for compiling and testing resource grammars.
-- usage: runghc Make (((present|alltenses)? OPT?) | (clone FILE))? LANGS?
-- where
-- usage: runghc Make (((present|alltenses)? OPT?) | (clone FILE))? LANGS?
-- where
-- - OPT = (lang | api | pgf | test | parse | clean | clone)
-- - LANGS has the form e.g. langs=Eng,Fin,Rus
-- - clone with a flag file=FILENAME clones the file to the specified languages,
-- by replacing the 3-letter language name of the original in both
-- by replacing the 3-letter language name of the original in both
-- the filename and the body
-- with each name in the list (default: all languages)
-- With no argument, lang and api are done, in this order.
@@ -21,12 +21,12 @@ import System.Exit
default_gf = "../../dist/build/gf/gf"
presApiPath = "-path=api:present"
presApiPath = "-path=api:present:../present"
presSymbolPath = "" -- "-path=.:abstract:present:common:romance:scandinavian" ----
-- the languages have long directory names and short ISO codes (3 letters)
-- we also give the functors implied
langsCoding = [
(("afrikaans","Afr"),""),
(("amharic", "Amh"),""),
@@ -52,7 +52,7 @@ langsCoding = [
(("romanian", "Ron"),""),
(("russian", "Rus"),""),
(("spanish", "Spa"),"Romance"),
(("swedish", "Swe"),"Scand"),
(("swedish", "Swe"),"Scand"),
(("thai", "Tha"),""),
(("thai", "Thb"),""), -- Thai pronunciation
(("turkish", "Tur"),""),
@@ -70,25 +70,25 @@ langsLangAll = langs
langsLang = langs `except` langsIncomplete
-- languagues that have notpresent marked
langsPresent = langsLang `except` ["Lav","Nep","Pes","Tha"]
langsPresent = langsLang `except` ["Nep","Pes","Tha"]
-- languages for which Lang can be compiled but which are incomplete
langsIncomplete = ["Amh","Ara","Hin","Lat","Tur"]
-- languages for which to compile Try
-- languages for which to compile Try
langsAPI = langsLang `except` langsIncomplete
-- languages for which to compile Symbolic
langsSymbolic = langsLang `except` (langsIncomplete ++ ["Afr","Ina","Lav","Nep","Pes","Pnb","Rus"])
langsSymbolic = langsLang `except` (langsIncomplete ++ ["Afr","Ina","Nep","Pes","Pnb","Rus"])
-- languages for which to compile minimal Syntax
langsMinimal = langs `only` ["Ara","Eng","Bul","Rus"]
-- languages for which to run treebank test
langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Rus","Spa","Tha"]
langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Lav","Rus","Spa","Tha"]
-- languages for which to run demo test
langsDemo = langsLang `except` ["Ara","Hin","Ina","Lat","Tha"]
langsDemo = langsLang `except` ["Ara","Hin","Ina","Lat","Lav","Tha"]
-- languages for which to compile parsing grammars
langsParse = langs `only` ["Eng"]
@@ -97,7 +97,7 @@ langsParse = langs `only` ["Eng"]
langsPGF = langsTest `only` ["Eng","Fre","Swe"]
-- languages for which Compatibility exists (to be extended)
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Spa","Swe"]
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Lav","Spa","Swe"]
treebankExx = "exx-resource.gft"
treebankResults = "exx-resource.gftb"
@@ -108,14 +108,14 @@ main = do
make :: [String] -> IO ()
make xx = do
let ifx opt act = if null xx || elem opt xx then act >> return () else return ()
let ifxx opt act = if elem opt xx then act >> return () else return ()
let pres
let ifx opt act = if null xx || elem opt xx then act >> return () else return ()
let ifxx opt act = if elem opt xx then act >> return () else return ()
let pres
| elem "present" xx = 1
| elem "alltenses" xx = 2
| otherwise = 0
let dir = case pres of
1 -> "../present"
let dir = case pres of
1 -> "../present"
2 -> "../alltenses"
_ -> "../full"
@@ -150,7 +150,7 @@ make xx = do
++ [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- optl langsPGF]
ifxx "test" $ do
let ls = optl langsTest
gf (treeb "Lang" ls) $ unwords [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- ls]
gf (treeb "Lang" ls) $ unwords [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- ls]
ifxx "parse" $ do
mapM_ (gfc pres [] . parse) (optl langsParse)
copy "parse/*.gfo parse/oald/*.gfo" dir
@@ -169,7 +169,7 @@ gfc pres ppath file = do
let preproc = if (pres==1) then "-preproc=mkPresent" else ""
let path = if (pres==1) then ppath else ""
putStrLn $ "Compiling " ++ file
if pres == 0
if pres == 0
then run_gfc ["-s","-src",preproc, path, file]
else run_gfc ["-s","-src","-no-pmcfg",preproc, path, file]
@@ -185,10 +185,10 @@ gf comm file = do
putStrLn cmd
system cmd
treeb abstr ls = "rf -lines -tree -file=" ++ treebankExx ++
treeb abstr ls = "rf -lines -tree -file=" ++ treebankExx ++
" | l -treebank " ++ unlexer abstr ls ++ " | wf -file=" ++ treebankResults
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
" | ps -to_html | wf -file=resdemo.html"
lang (lla,la) = lla ++ "/All" ++ la ++ ".gf"
@@ -214,7 +214,7 @@ getOptLangs args = case [ls | a <- args, let (f,ls) = splitAt 6 a, f=="langs="]
-- the file name has the form p....pLLL.gf, i.e. 3-letter lang name, suffix .gf
getLangName args = case [ls | a <- args, let (f,ls) = splitAt 5 a, f=="file="] of
fi:_ -> let (nal,ferp) = splitAt 3 (drop 3 (reverse fi)) in return (reverse ferp,reverse nal)
fi:_ -> let (nal,ferp) = splitAt 3 (drop 3 (reverse fi)) in return (reverse ferp,reverse nal)
_ -> Nothing
replaceLang s1 s2 = repl where
@@ -225,19 +225,19 @@ replaceLang s1 s2 = repl where
_ -> s
lgs = 3 -- length s1
unlexer abstr ls =
"-unlexer=\\\"" ++ unwords
[abstr ++ la ++ "=" ++ unl |
lla@(_,la) <- ls, let unl = unlex lla, not (null unl)] ++
unlexer abstr ls =
"-unlexer=\\\"" ++ unwords
[abstr ++ la ++ "=" ++ unl |
lla@(_,la) <- ls, let unl = unlex lla, not (null unl)] ++
"\\\""
where
unlex lla = maybe "" id $ lookup lla langsCoding
-- | Runs the gf executable in compile mode with the given arguments.
run_gfc :: [String] -> IO ()
run_gfc args =
run_gfc args =
do let args' = ["-batch"] ++ filter (not . null) args ++ ["+RTS"] ++ rts_flags ++ ["-RTS"]
--- do let args' = ["-batch","-gf-lib-path=."] ++ filter (not . null) args ++ ["+RTS"] ++ rts_flags ++ ["-RTS"] --- why path? AR
--- do let args' = ["-batch","-gf-lib-path=."] ++ filter (not . null) args ++ ["+RTS"] ++ rts_flags ++ ["-RTS"] --- why path? AR
putStrLn $ "Running: " ++ default_gf ++ " " ++ unwords (map showArg args')
e <- rawSystem default_gf args'
case e of
@@ -247,24 +247,24 @@ run_gfc args =
showArg arg = "'" ++ arg ++ "'"
copy :: String -> String -> IO ()
copy from to =
copy from to =
do system $ "cp " ++ from ++ " " ++ to
return ()
copyl :: [(String,String)] -> String -> String -> IO ()
copyl lans from to = do
copyl lans from to = do
echosystem $ "cp abstract/" ++ from ++ " " ++ to
echosystem $ "cp common/" ++ from ++ " " ++ to
mapM_ (\lan -> echosystem $ "cp */*" ++ lan ++ from ++ " " ++ to)
mapM_ (\lan -> echosystem $ "cp */*" ++ lan ++ from ++ " " ++ to)
(map snd lans ++ concatMap implied lans)
return ()
copyld :: [(String,String)] -> String -> String -> String -> IO ()
copyld lans dir from to = do
mapM_ (\lan -> echosystem $ "cp " ++ dir ++ lan ++ from ++ " " ++ to)
copyld lans dir from to = do
mapM_ (\lan -> echosystem $ "cp " ++ dir ++ lan ++ from ++ " " ++ to)
(map snd lans ++ if (take 3 dir == "api") then [] else concatMap implied lans)
return ()
echosystem c = do
putStrLn c
putStrLn c
system c

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude:../latvian
resource SymbolicLav = Symbolic with
(Symbol = SymbolLav),
(Grammar = GrammarLav) ;

View File

@@ -1,8 +1,11 @@
--# -path=.:../abstract:../common:../prelude
concrete ExtraLav of ExtraLavAbs = CatLav ** {
concrete ExtraLav of ExtraLavAbs = CatLav ** open ResLav in {
flags
coding = utf8 ;
lin
GenNP np = {s = \\_,_,_ => np.s ! Gen ; d = Def} ;
}

View File

@@ -1,3 +1,3 @@
--# -path=.:../abstract:../common:../prelude
abstract ExtraLavAbs = {}
abstract ExtraLavAbs = Extra ** {}

View File

@@ -58,11 +58,9 @@ lin
s =
vp.v.s ! Pos ! (Indicative P1 Pl Pres) ++ -- Verb
vp.s2 ! a -- Object(s), complements, adverbial modifiers
} | {
s =
vp.v.s ! Pos ! (Indicative P1 Pl Fut) ++
vp.s2 ! a
} ;
}
| { s = vp.v.s ! Pos ! (Indicative P1 Pl Fut) ++ vp.s2 ! a } --# notpresent
;
ImpP3 np vp = {
s = "lai" ++ np.s ! Nom ++ buildVerb vp.v (Ind Simul Pres) Pos np.a ++ vp.s2 ! np.a ;

View File

@@ -0,0 +1,15 @@
--# -path=.:../common:../abstract
resource MakeStructuralLav = open CatLav, ParadigmsLav, ResLav, Prelude in {
flags
coding = utf8 ;
oper
mkSubj : Str -> Subj = \x ->
lin Subj {s = x} ;
mkIDet : Str -> ParadigmsLav.Number -> IDet = \s,n ->
lin IDet {s = \\_ => s ; n = n} ;
}

View File

@@ -32,6 +32,14 @@ flags
coding = utf8 ;
oper
Number : Type ;
singular : Number ;
plural : Number ;
Number = ResLav.Number ;
singular = Sg ;
plural = Pl ;
second_conjugation : VerbConj = C2 ;
third_conjugation : VerbConj = C3 ;

View File

@@ -32,11 +32,24 @@ param
-- Deb = Debitive (Latvian specific: http://www.isocat.org/rest/dc/3835)
-- Condit = Conditional
-- DebitiveRelative = the relative subtype of debitive
VerbForm = Infinitive | Indicative Person Number Tense | Relative Tense | Debitive |
Imperative Number | DebitiveRelative | Participle Gender Number Case ;
VerbForm =
Infinitive
| Indicative Person Number Tense
| Relative Tense
| Debitive
| Imperative Number
| DebitiveRelative
| Participle Gender Number Case
;
-- TODO: divdabim noteiktā forma un arī pārākā / vispārākā pakāpe
VerbMood = Ind Anteriority Tense | Rel Anteriority Tense | Deb Anteriority Tense | Condit Anteriority ;
VerbMood =
Ind Anteriority Tense
| Rel Anteriority Tense --# notpresent
| Deb Anteriority Tense --# notpresent
| Condit Anteriority --# notpresent
;
VerbConj = C2 | C3 ;
--Agr = Ag Gender Number ;

View File

@@ -42,8 +42,9 @@ lin
UseQCl t p cl = { s = t.s ++ p.s ++ cl.s ! (Ind t.a t.t) ! p.p } ;
UseRCl t p cl =
{ s = \\ag => t.s ++ p.s ++ cl.s ! (Ind t.a t.t) ! p.p ! ag } |
{ s = \\ag => t.s ++ p.s ++ cl.s ! (Rel t.a t.t) ! p.p ! ag } ;
{ s = \\ag => t.s ++ p.s ++ cl.s ! (Ind t.a t.t) ! p.p ! ag }
| { s = \\ag => t.s ++ p.s ++ cl.s ! (Rel t.a t.t) ! p.p ! ag } --# notpresent
;
UseSlash t p slash = { s = t.s ++ p.s ++ slash.s ! (Ind t.a t.t) ! p.p ; p = slash.p } ;
@@ -55,7 +56,7 @@ oper
s = \\mood,pol =>
case mood of { -- Subject
-- FIXME: jāčeko valences, reizēm arī īstenības izteiksmē - 'man patīk kaut kas'
Deb _ _ => np.s ! Dat ;
Deb _ _ => np.s ! Dat ; --# notpresent
_ => np.s ! Nom
} ++
buildVerb vp.v mood pol np.a ++ -- Verb

View File

@@ -450,37 +450,4 @@ oper
no_Utt = ss "nē" ;
{-
can8know_VV, can_VV = {
s = table {
VVF VInf => ["be able to"] ;
VVF VPres => "can" ;
VVF VPPart => ["been able to"] ;
VVF VPresPart => ["being able to"] ;
VVF VPast => "could" ; --# notpresent
VVPastNeg => "couldn't" ; --# notpresent
VVPresNeg => "can't"
} ;
isAux = True
} ;
must_VV = {
s = table {
VVF VInf => ["have to"] ;
VVF VPres => "must" ;
VVF VPPart => ["had to"] ;
VVF VPresPart => ["having to"] ;
VVF VPast => ["had to"] ; --# notpresent
VVPastNeg => ["hadn't to"] ; --# notpresent
VVPresNeg => "mustn't"
} ;
isAux = True
} ;
not_Predet = {s = "not" ; lock_Predet = <>} ;
no_Quant = mkQuant "no" "no" "none" "none" ;
have_V2 = dirV2 (mk5V "have" "has" "had" "had" "having") ;
-}
}

View File

@@ -8,4 +8,38 @@ concrete SymbolLav of Symbol = CatLav ** open
flags
coding = utf8 ;
lin
SymbPN i = {s = \\_ => i.s ; g = Masc ; n = Sg} ;
IntPN i = {s = \\_ => i.s ; g = Masc ; n = Pl} ;
FloatPN i = {s = \\_ => i.s ; g = Masc ; n = Pl} ;
NumPN i = {s = \\_ => i.s ! Masc ! Nom ; g = Masc ; n = Pl} ;
CNIntNP cn i = {
s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ;
a = agrgP3 Sg cn.g
} ;
CNSymbNP det cn xs = {
s = \\_ => det.s ! cn.g ! Nom ++ cn.s ! det.d ! det.n ! Nom ++ xs.s ;
a = agrgP3 det.n cn.g
} ;
CNNumNP cn i = {
s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ! Masc ! Nom ;
a = agrgP3 Sg cn.g
} ;
SymbS sy = sy ;
SymbNum sy = { s = \\_,_ => sy.s ; n = Pl } ;
SymbOrd sy = { s = \\_,_ => sy.s ++ "."} ;
lincat
Symb, [Symb] = SS ;
lin
MkSymb s = s ;
BaseSymb = infixSS "un" ;
ConsSymb = infixSS "," ;
}

View File

@@ -6,6 +6,7 @@
-- Not so simple since morphology itself needs ResLav & friends.
concrete VerbLav of Verb = CatLav ** open
ParamX,
ResLav,
ParadigmsVerbsLav,
StructuralLav
@@ -74,22 +75,27 @@ oper
buildVerb : Verb -> VerbMood -> Polarity -> Agr -> Str = \v,mood,pol,ag ->
let
ag = fromAgr ag ;
part = v.s ! ResLav.Pos ! (Participle ag.g ag.n Nom)
ag = fromAgr ag
; --# notpresent
part = v.s ! ResLav.Pos ! (Participle ag.g ag.n Nom) --# notpresent
in case mood of {
Ind Simul tense => v.s ! pol ! (Indicative ag.p ag.n tense) ;
Ind Anter tense => mkVerb_toBe.s ! pol ! (Indicative ag.p ag.n tense) ++ part ;
Ind Simul tense => v.s ! pol ! (Indicative ag.p ag.n tense)
; --# notpresent
Ind Anter tense => mkVerb_toBe.s ! pol ! (Indicative ag.p ag.n tense) ++ part ; --# notpresent
Rel _ Past => ResLav.NON_EXISTENT ; -- FIXME (?)
Rel Simul tense => v.s ! pol ! (Relative tense) ;
Rel Anter tense => mkVerb_toBe.s ! pol ! (Relative tense) ++ part ;
-- FIXME(?): Rel _ Past => ...
Rel _ Past => ResLav.NON_EXISTENT ; --# notpresent
Rel Simul tense => v.s ! pol ! (Relative tense) ; --# notpresent
Rel Anter tense => mkVerb_toBe.s ! pol ! (Relative tense) ++ part ; --# notpresent
Deb Simul tense => mkVerb_toBe.s ! pol ! (Indicative P3 Sg tense) ++ v.s ! ResLav.Pos ! Debitive ;
Deb Anter tense => mkVerb_toBe.s ! pol ! (Indicative P3 Sg tense) ++
mkVerb_toBe.s ! ResLav.Pos ! (Participle Masc Sg Nom) ++ v.s ! ResLav.Pos ! Debitive ;
Deb Simul tense => mkVerb_toBe.s ! pol ! (Indicative P3 Sg tense) ++ --# notpresent
v.s ! ResLav.Pos ! Debitive ; --# notpresent
Deb Anter tense => mkVerb_toBe.s ! pol ! (Indicative P3 Sg tense) ++ --# notpresent
mkVerb_toBe.s ! ResLav.Pos ! (Participle Masc Sg Nom) ++ --# notpresent
v.s ! ResLav.Pos ! Debitive ; --# notpresent
Condit Simul => v.s ! pol ! (Indicative ag.p ag.n Cond) ;
Condit Anter => mkVerb_toBe.s ! pol ! (Indicative ag.p ag.n Cond) ++ part
Condit Simul => v.s ! pol ! (Indicative ag.p ag.n ParamX.Cond) ; --# notpresent
Condit Anter => mkVerb_toBe.s ! pol ! (Indicative ag.p ag.n ParamX.Cond) ++ part --# notpresent
} ;
-- TODO: nav testēts