1
0
forked from GitHub/gf-rgl

Merge pull request #463 from inariksit/release-morphodict

Build morphodict and put in GF_LIB_PATH
This commit is contained in:
Inari Listenmaa
2025-08-12 15:18:27 +02:00
committed by GitHub
5 changed files with 94 additions and 65 deletions

View File

@@ -25,6 +25,7 @@ data LangInfo = LangInfo
, langSymbolic :: Bool , langSymbolic :: Bool
, langCompatibility :: Bool , langCompatibility :: Bool
, langSynopsis :: Bool -- ^ include in RGL synopsis , langSynopsis :: Bool -- ^ include in RGL synopsis
, langMorphodict :: Bool
} deriving (Show,Eq) } deriving (Show,Eq)
-- | Load language information from default config file -- | Load language information from default config file
@@ -55,6 +56,7 @@ loadLangsFrom configFile = do
, langSymbolic = boolBit bits 8 True , langSymbolic = boolBit bits 8 True
, langCompatibility = boolBit bits 9 False , langCompatibility = boolBit bits 9 False
, langSynopsis = boolBit bits 10 False , langSynopsis = boolBit bits 10 False
, langMorphodict = boolBit bits 11 False
} }
-- | Separate a string on a character -- | Separate a string on a character

View File

@@ -19,6 +19,7 @@ default: build copy
build: src/*/*.gf build: src/*/*.gf
ifneq (, $(RUNGHC)) ifneq (, $(RUNGHC))
$(RUNGHC) build $(RUNGHC) build
$(RUNGHC) build morphodict
else else
./Setup.sh ./Setup.sh
endif endif
@@ -26,6 +27,7 @@ endif
copy: copy:
ifneq (, $(RUNGHC)) ifneq (, $(RUNGHC))
$(RUNGHC) copy $(RUNGHC) copy
$(RUNGHC) copy morphodict
endif endif
install: build copy install: build copy

View File

@@ -1,4 +1,4 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP, LambdaCase #-}
-- | Main build script for RGL -- | Main build script for RGL
@@ -150,11 +150,12 @@ getRGLBuildSubDir mode =
case mode of case mode of
Present -> "present" Present -> "present"
AllTenses -> "alltenses" AllTenses -> "alltenses"
MorphoDict -> "morphodict"
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Build modes -- Build modes
data Mode = Present | AllTenses data Mode = Present | AllTenses | MorphoDict
deriving (Show,Eq) deriving (Show,Eq)
all_modes :: [String] all_modes :: [String]
@@ -187,6 +188,7 @@ rglCommands =
, RGLCommand "lang" False $ gfcp [l,s] , RGLCommand "lang" False $ gfcp [l,s]
, RGLCommand "api" False $ gfcp [t,sc] , RGLCommand "api" False $ gfcp [t,sc]
, RGLCommand "compat" False $ gfcp [c] , RGLCommand "compat" False $ gfcp [c]
, RGLCommand "morphodict" False $ gfcp [m]
-- Special command, invoked when command ends in .gf -- Special command, invoked when command ends in .gf
, RGLCommand "modules" False $ \modes args bi -> do , RGLCommand "modules" False $ \modes args bi -> do
@@ -223,14 +225,20 @@ rglCommands =
s mode args = (symbol,optml mode langTry args) s mode args = (symbol,optml mode langTry args)
c mode args = (compat,optml AllTenses langCompatibility args) c mode args = (compat,optml AllTenses langCompatibility args)
t mode args = (try,optml mode langTry args) t mode args = (try,optml mode langTry args)
m mode args = (morphodict,optml mode langMorphodict args)
sc mode args = (symbolic,optml mode langSymbolic args) sc mode args = (symbolic,optml mode langSymbolic args)
optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo]) optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo])
optml mode pred args = optml mode pred args =
\langsAll -> \langsAll ->
let langsDefault = filter (if mode == Present then langPresent else const True) (filter pred langsAll) let langsDefault = filter (mode2langinfo mode) (filter pred langsAll)
in getOptLangs langsAll langsDefault args in getOptLangs langsAll langsDefault args
mode2langinfo = \case
Present -> langPresent
MorphoDict -> langMorphodict
_ -> const True
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Getting module paths/names -- Getting module paths/names
@@ -260,6 +268,9 @@ syntax l = sourceDir </> "api" </> ("Syntax" ++ langCode l ++ ".gf")
symbolic :: LangInfo -> FilePath symbolic :: LangInfo -> FilePath
symbolic l = sourceDir </> "api" </> ("Symbolic" ++ langCode l ++ ".gf") symbolic l = sourceDir </> "api" </> ("Symbolic" ++ langCode l ++ ".gf")
morphodict :: LangInfo -> FilePath
morphodict l = sourceDir </> "morphodict" </> ("MorphoDict" ++ langCode l ++ ".gf")
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Argument helpers -- Argument helpers
@@ -302,8 +313,9 @@ getOptMode args =
else explicit_modes else explicit_modes
where where
explicit_modes = explicit_modes =
[Present|have "present"]++ [Present | have "present"] ++
[AllTenses|have "alltenses"] [AllTenses | have "alltenses"] ++
[MorphoDict | have "morphodict"]
have mode = mode `elem` args have mode = mode `elem` args
-- | List of languages overriding the default definitions -- | List of languages overriding the default definitions
@@ -366,8 +378,8 @@ gfcn :: Info -> Mode -> String -> [FilePath] -> IO ()
gfcn bi mode summary files = do gfcn bi mode summary files = do
let dir = getRGLBuildDir bi mode let dir = getRGLBuildDir bi mode
preproc = case mode of preproc = case mode of
Present -> "--preproc=mkPresent" Present -> "--preproc=mkPresent"
AllTenses -> "" _ -> ""
createDirectoryIfMissing True dir createDirectoryIfMissing True dir
if length files > 0 if length files > 0
then do then do

View File

@@ -59,6 +59,7 @@ gfc="${gf} --batch --quiet --gf-lib-path=${dist}"
mkdir -p "${dist}/prelude" mkdir -p "${dist}/prelude"
mkdir -p "${dist}/present" mkdir -p "${dist}/present"
mkdir -p "${dist}/alltenses" mkdir -p "${dist}/alltenses"
mkdir -p "${dist}/morphodict"
# Build: prelude # Build: prelude
echo "Building [prelude]" echo "Building [prelude]"
@@ -68,6 +69,7 @@ ${gfc} --gfo-dir="${dist}"/prelude "${src}"/prelude/*.gf
# Gather all language modules for building # Gather all language modules for building
modules_present= modules_present=
modules_alltenses= modules_alltenses=
modules_morphodict=
for lang in $langs; do for lang in $langs; do
for mod in $modules_langs $modules_api; do for mod in $modules_langs $modules_api; do
if [ $mod == "Compatibility" ] && [[ "$langs_compat" != *"$lang"* ]]; then continue; fi if [ $mod == "Compatibility" ] && [[ "$langs_compat" != *"$lang"* ]]; then continue; fi
@@ -80,8 +82,12 @@ for lang in $langs; do
modules_alltenses="${modules_alltenses} ${file}" modules_alltenses="${modules_alltenses} ${file}"
done done
done done
file="${src}/morphodict/MorphoDict${lang}.gf"
if [ ! -f "$file" ]; then continue; fi
modules_morphodict="${modules_morphodict} ${file}"
done done
# Build: present # Build: present
echo "Building [present]" echo "Building [present]"
if [ $verbose = true ]; then echo $modules_present; fi if [ $verbose = true ]; then echo $modules_present; fi
@@ -96,6 +102,13 @@ for module in $modules_alltenses; do
${gfc} --no-pmcfg --gfo-dir="${dist}"/alltenses "${module}" ${gfc} --no-pmcfg --gfo-dir="${dist}"/alltenses "${module}"
done done
# Build: morphodict
echo "Building [morphodict]"
if [ $verbose = true ]; then echo $modules_morphodict; fi
for module in $modules_morphodict; do
${gfc} --no-pmcfg --gfo-dir="${dist}"/morphodict "${module}"
done
# Copy # Copy
if [ $dest == $dist ]; then exit 0; fi if [ $dest == $dist ]; then exit 0; fi
echo "Copying to ${dest}" echo "Copying to ${dest}"

View File

@@ -1,58 +1,58 @@
Code,Name,Directory,Functor,Unlexer,Present,All,Try,Symbolic,Compatibility,Synopsis Code,Name,Directory,Functor,Unlexer,Present,All,Try,Symbolic,Compatibility,Synopsis,MorphoDict
Afr,Afrikaans,afrikaans,,,,,,n,,y Afr,Afrikaans,afrikaans,,,,,,n,,y,n
Amh,Amharic,amharic,,,,,n,n,,n Amh,Amharic,amharic,,,,,n,n,,n,n
Ara,Arabic,arabic,,,,,,y,,y Ara,Arabic,arabic,,,,,,y,,y,y
Bul,Bulgarian,bulgarian,,,y,,,,,y Bul,Bulgarian,bulgarian,,,y,,,,,y,n
Cat,Catalan,catalan,Romance,,y,,,,y,y Cat,Catalan,catalan,Romance,,y,,,,y,y,n
Cgg,Rukiga,rukiga,,,y,y,n,n,y,y Cgg,Rukiga,rukiga,,,y,y,n,n,y,y,n
Chi,Chinese (simplified),chinese,,,,,,,,y Chi,Chinese (simplified),chinese,,,,,,,,y,y
Cze,Czech,czech,,,,,,n,,y Cze,Czech,czech,,,,,,n,,y,n
Dan,Danish,danish,Scand,,y,,,,,y Dan,Danish,danish,Scand,,y,,,,,y,n
Dut,Dutch,dutch,,,y,,,,,y Dut,Dutch,dutch,,,y,,,,,y,n
Eng,English,english,,,y,,,,y,y Eng,English,english,,,y,,,,y,y,y
Est,Estonian,estonian,,,,,,,,y Est,Estonian,estonian,,,,,,,,y,n
Eus,Basque,basque,,,,,,,,y Eus,Basque,basque,,,,,,,,y,n
Fin,Finnish,finnish,,,y,,,,y,y Fin,Finnish,finnish,,,y,,,,y,y,y
Fre,French,french,Romance,,y,,,,y,y Fre,French,french,Romance,,y,,,,y,y,y
Ger,German,german,,,y,,,,,y Ger,German,german,,,y,,,,,y,y
Grc,Ancient Greek,ancient_greek,,,y,,n,n,,n Grc,Ancient Greek,ancient_greek,,,y,,n,n,,n,n
Gre,Greek,greek,,,,,,,,y Gre,Greek,greek,,,,,,,,y,n
Heb,Hebrew,hebrew,,,,,n,n,,n Heb,Hebrew,hebrew,,,,,n,n,,n,n
Hin,Hindi,hindi,Hindustani,to_devanagari,y,,,,,y Hin,Hindi,hindi,Hindustani,to_devanagari,y,,,,,y,n
Hrv,Croatian,croatian,,,,,,y,,n Hrv,Croatian,croatian,,,,,,y,,n,n
Hun,Hungarian,hungarian,,,n,y,y,y,n,n Hun,Hungarian,hungarian,,,n,y,y,y,n,n,n
Ice,Icelandic,icelandic,,,,,,n,,y Ice,Icelandic,icelandic,,,,,,n,,y,n
Ina,Interlingua,interlingua,,,y,,n,n,,n Ina,Interlingua,interlingua,,,y,,n,n,,n,n
Ita,Italian,italian,Romance,,y,,,,y,y Ita,Italian,italian,Romance,,y,,,,y,y,y
Jpn,Japanese,japanese,,,,,,,,y Jpn,Japanese,japanese,,,,,,,,y,n
Kaz,Kazakh,kazakh,,,,y,n,n,n,y Kaz,Kazakh,kazakh,,,,y,n,n,n,y,n
Kor,Korean,korean,,,n,y,y,y,n,n Kor,Korean,korean,,,n,y,y,y,n,n,n
Lat,Latin,latin,,,,,y,y,n,y Lat,Latin,latin,,,,,y,y,n,y,n
Lav,Latvian,latvian,,,,,,,y,y Lav,Latvian,latvian,,,,,,,y,y,n
Mkd,Macedonian,macedonian,,,,y,n,n,n,y Mkd,Macedonian,macedonian,,,,y,n,n,n,y,n
May,Malay,malay,,,y,,,,n,y May,Malay,malay,,,y,,,,n,y,n
Mlt,Maltese,maltese,,,,,,,,y Mlt,Maltese,maltese,,,,,,,,y,n
Mon,Mongolian,mongolian,,,,,,n,,y Mon,Mongolian,mongolian,,,,,,n,,y,n
Nep,Nepali,nepali,,,,,,n,,y Nep,Nepali,nepali,,,,,,n,,y,n
Nno,Norwegian (nynorsk),nynorsk,,,y,,,,,y Nno,Norwegian (nynorsk),nynorsk,,,y,,,,,y,n
Nor,Norwegian (bokmål),norwegian,Scand,,y,,,,,y Nor,Norwegian (bokmål),norwegian,Scand,,y,,,,,y,n
Pes,Persian,persian,,,,,,,,y Pes,Persian,persian,,,,,,,,y,n
Pnb,Punjabi,punjabi,,,y,,,,,y Pnb,Punjabi,punjabi,,,y,,,,,y,n
Pol,Polish,polish,,,,,,,,y Pol,Polish,polish,,,,,,,,y,n
Por,Portuguese,portuguese,Romance,,y,,,,y,y Por,Portuguese,portuguese,Romance,,y,,,,y,y,y
Ron,Romanian,romanian,,,y,,,,,y Ron,Romanian,romanian,,,y,,,,,y,n
Rus,Russian,russian,,,y,,,,,y Rus,Russian,russian,,,y,,,,,y,n
Slo,Slovak,slovak,,,,,,n,,y Slo,Slovak,slovak,,,,,,n,,y,n
Slv,Slovenian,slovenian,,,,,n,n,,n Slv,Slovenian,slovenian,,,,,n,n,,n,n
Snd,Sindhi,sindhi,,,,,,,,y Snd,Sindhi,sindhi,,,,,,,,y,n
Spa,Spanish,spanish,Romance,,y,,,,y,y Spa,Spanish,spanish,Romance,,y,,,,y,y,y
Sqi,Albanian,albanian,,,,y,n,n,n,y Sqi,Albanian,albanian,,,,y,n,n,n,y,n
Swa,Swahili,swahili,Bantu,,,y,n,n,n,n Swa,Swahili,swahili,Bantu,,,y,n,n,n,n,n
Swe,Swedish,swedish,Scand,,y,,,,y,y Swe,Swedish,swedish,Scand,,y,,,,y,y,y
Tam,Tamil,tamil,n,n,n,n,n,n,n,n Tam,Tamil,tamil,n,n,n,n,n,n,n,n,n
Tel,Telugu,telugu,,,y,n,n,n,,n Tel,Telugu,telugu,,,y,n,n,n,,n,n
Tha,Thai,thai,,to_thai,,,,,,y Tha,Thai,thai,,to_thai,,,,,,y,n
Tur,Turkish,turkish,,,y,,,n,,n Tur,Turkish,turkish,,,y,,,n,,n,n
Urd,Urdu,urdu,Hindustani,,,,,,,y Urd,Urdu,urdu,Hindustani,,,,,,,y,n
Som,Somali,somali,,,,,n,n,,n Som,Somali,somali,,,,,n,n,,n,n
Zul,Zulu,zulu,,,,,n,n,,n Zul,Zulu,zulu,,,,,n,n,,n,n
1 Code Name Directory Functor Unlexer Present All Try Symbolic Compatibility Synopsis MorphoDict
2 Afr Afrikaans afrikaans n y n
3 Amh Amharic amharic n n n n
4 Ara Arabic arabic y y y
5 Bul Bulgarian bulgarian y y n
6 Cat Catalan catalan Romance y y y n
7 Cgg Rukiga rukiga y y n n y y n
8 Chi Chinese (simplified) chinese y y
9 Cze Czech czech n y n
10 Dan Danish danish Scand y y n
11 Dut Dutch dutch y y n
12 Eng English english y y y y
13 Est Estonian estonian y n
14 Eus Basque basque y n
15 Fin Finnish finnish y y y y
16 Fre French french Romance y y y y
17 Ger German german y y y
18 Grc Ancient Greek ancient_greek y n n n n
19 Gre Greek greek y n
20 Heb Hebrew hebrew n n n n
21 Hin Hindi hindi Hindustani to_devanagari y y n
22 Hrv Croatian croatian y n n
23 Hun Hungarian hungarian n y y y n n n
24 Ice Icelandic icelandic n y n
25 Ina Interlingua interlingua y n n n n
26 Ita Italian italian Romance y y y y
27 Jpn Japanese japanese y n
28 Kaz Kazakh kazakh y n n n y n
29 Kor Korean korean n y y y n n n
30 Lat Latin latin y y n y n
31 Lav Latvian latvian y y n
32 Mkd Macedonian macedonian y n n n y n
33 May Malay malay y n y n
34 Mlt Maltese maltese y n
35 Mon Mongolian mongolian n y n
36 Nep Nepali nepali n y n
37 Nno Norwegian (nynorsk) nynorsk y y n
38 Nor Norwegian (bokmål) norwegian Scand y y n
39 Pes Persian persian y n
40 Pnb Punjabi punjabi y y n
41 Pol Polish polish y n
42 Por Portuguese portuguese Romance y y y y
43 Ron Romanian romanian y y n
44 Rus Russian russian y y n
45 Slo Slovak slovak n y n
46 Slv Slovenian slovenian n n n n
47 Snd Sindhi sindhi y n
48 Spa Spanish spanish Romance y y y y
49 Sqi Albanian albanian y n n n y n
50 Swa Swahili swahili Bantu y n n n n n
51 Swe Swedish swedish Scand y y y y
52 Tam Tamil tamil n n n n n n n n n
53 Tel Telugu telugu y n n n n n
54 Tha Thai thai to_thai y n
55 Tur Turkish turkish y n n n
56 Urd Urdu urdu Hindustani y n
57 Som Somali somali n n n n
58 Zul Zulu zulu n n n n