Skip to content

Commit e962cc3

Browse files
authored
Merge branch 'GrammaticalFramework:master' into nheengatu-resource-grammar
2 parents 3afc6d3 + 3dae1cf commit e962cc3

File tree

774 files changed

+719830
-101454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

774 files changed

+719830
-101454
lines changed

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Check that the RGL can successfully build
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-20.04
10+
env:
11+
GF_VERSION: 3.11
12+
DEST: gf-rgl
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
18+
- name: Download GF
19+
uses: dsaltares/fetch-gh-release-asset@1.1.1
20+
with:
21+
repo: 'GrammaticalFramework/gf-core'
22+
version: 'tags/${{ env.GF_VERSION }}'
23+
file: 'gf-${{ env.GF_VERSION }}-ubuntu-20.04.deb'
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Install GF
27+
run: |
28+
sudo dpkg -i gf-${GF_VERSION}-ubuntu-20.04.deb
29+
30+
- name: Build RGL
31+
run: |
32+
mkdir -p ${DEST}
33+
bash Setup.sh --dest=${DEST} --gf=gf --verbose

Setup.bat

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,6 @@ if "%dest%"=="" (
3737
)
3838
:BreakLibPath
3939

40-
set DATA_DIR=..\gf-core\DATA_DIR
41-
if "%dest%"=="" (
42-
REM Look in already compiled GF folder
43-
if exist %DATA_DIR% (
44-
for /f "delims=" %%x in (%DATA_DIR%) do (
45-
if not "%%x"=="" (
46-
set dest=%%x\lib
47-
goto BreakDataDir
48-
)
49-
)
50-
)
51-
)
52-
:BreakDataDir
53-
5440
if "%dest%"=="" (
5541
echo Unable to determine where to install the RGL. Please do one of the following:
5642
echo - Pass the --dest=... flag to this script

Setup.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import System.IO (hPutStrLn,stderr)
88
import System.IO.Error (catchIOError)
99
import System.Exit (ExitCode(..),exitFailure)
1010
import System.Environment (getArgs,lookupEnv)
11-
import System.Process (rawSystem)
12-
import System.FilePath ((</>),splitSearchPath) -- ,takeFileName,addExtension,dropExtension)
11+
import System.Process (rawSystem,readProcess)
12+
import System.FilePath ((</>),splitSearchPath)
1313
import System.Directory (createDirectoryIfMissing,copyFile,getDirectoryContents,removeDirectoryRecursive,findFile)
1414
#if __GLASGOW_HASKELL__>=800
1515
import System.Directory (getModificationTime,setModificationTime)
@@ -61,7 +61,7 @@ errLocation = unlines $
6161
[ "Unable to determine where to install the RGL. Please do one of the following:"
6262
, " - Pass the " ++ destination_flag ++ "... flag to this script"
6363
, " - Set the GF_LIB_PATH environment variable"
64-
, " - Compile & install GF from the gf-core repository (must be in same directory as gf-rgl)"
64+
, " - Compile & install GF from the gf-core repository"
6565
]
6666

6767
-- | Copy single file between directories
@@ -116,10 +116,11 @@ data Info = Info
116116
mkInfo :: IO Info
117117
mkInfo = do
118118
args <- getArgs
119+
let gf = maybe default_gf id (getFlag gf_flag args)
119120
-- Look for install location in a few different places
120121
let mflag = getFlag destination_flag args
121-
mbuilt <- catchIOError (readFile "../gf-core/DATA_DIR" >>= \d -> return (Just (d </> "lib"))) (\e -> return Nothing)
122122
menvar <- lookupEnv "GF_LIB_PATH" >>= return . fmap (head . splitSearchPath)
123+
mbuilt <- catchIOError (readProcess gf ["--version"] "" >>= return . getPath) (\e -> return Nothing)
123124
let
124125
inst_dir =
125126
case catMaybes [mflag,menvar,mbuilt] of
@@ -129,12 +130,18 @@ mkInfo = do
129130
return $ Info
130131
{ infoBuildDir = "dist"
131132
, infoInstallDir = inst_dir
132-
, infoGFPath = maybe default_gf id (getFlag gf_flag args)
133+
, infoGFPath = gf
133134
, infoVerbose = verbose
134135
}
135136
where
136137
default_gf = "gf"
137138

139+
getPath s =
140+
let l = last (lines s)
141+
in if take 14 l == "Shared folder:"
142+
then Just (drop 15 l </> "lib")
143+
else Nothing
144+
138145
getRGLBuildDir :: Info -> Mode -> FilePath
139146
getRGLBuildDir info mode = infoBuildDir info </> getRGLBuildSubDir mode
140147

Setup.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ done
3838
if [ -z "$dest" ]; then
3939
dest=$(echo "$GF_LIB_PATH" | sed 's/:.*$//')
4040
fi
41-
if [ -z "$dest" ] && [ -f "../gf-core/DATA_DIR" ]; then
42-
dest=$(cat ../gf-core/DATA_DIR)
41+
if [ -z "$dest" ] && [ "$(gf --version | tail -1 | cut -c -14)" == "Shared folder:" ]; then
42+
dest=$(gf --version | tail -1 | cut -c 16-)
4343
if [ -n "$dest" ]; then dest="${dest}/lib"; fi
4444
fi
4545
if [ -z "$dest" ]; then
4646
echo "Unable to determine where to install the RGL. Please do one of the following:"
4747
echo " - Pass the --dest=... flag to this script"
4848
echo " - Set the GF_LIB_PATH environment variable"
49-
echo " - Compile & install GF from the gf-core repository (must be in same directory as gf-rgl)"
49+
echo " - Compile & install GF from the gf-core repository"
5050
exit 1
5151
fi
5252

doc/missing-in-rgl-Grammar.tsv

Lines changed: 371 additions & 0 deletions
Large diffs are not rendered by default.

doc/rgl-publications.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ The GF Resource Grammar Library.
159159
//Linguistic Issues in Language Technology//,
160160
2 (2),
161161
2009.
162-
[PDF http://elanguage.net/journals/index.php/lilt/article/viewFile/214/158]
162+
[PDF https://journals.colorado.edu/index.php/lilt/article/view/1205/1047]
163163
#BR
164164
//A systematic presentation of the library from the linguistic point of view.//
165165
//Not only about English, but English examples abound.//

doc/show_missing.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# show missing functions in the RGL languages
2+
# basic usage: python3 show_missing.py >missing-in-rgl-Grammar.tsv
3+
4+
import subprocess
5+
6+
# this is the functions you want to find: default is all funs in Grammar
7+
GF_LIB_PATH = '/Users/aarne/GF/dist/build/rgl/'
8+
ALLTENSES_PATH = GF_LIB_PATH + 'alltenses/'
9+
RGL_SOURCE_PATH = '/Users/aarne/GF/gf-rgl/src/'
10+
GRAMMAR = 'Grammar'
11+
12+
# these are the languages you investigate
13+
LANGS = ['Cze', 'Urd']
14+
15+
# get all functions in GRAMMAR, together with their types
16+
def get_funs(module=GRAMMAR):
17+
cmd = 'echo "pg -funs" | gf -run ' + ALLTENSES_PATH + module + '.gfo'
18+
missing = subprocess.Popen(cmd, text=True, shell=True,
19+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
20+
output = missing.communicate()[0].split(';')
21+
return ([(fun.split()[0].strip(), ' '.join(fun.split()[2:])) for fun in output if fun.split()])
22+
23+
# get all missing functions in GRAMMARLng; this can take a long time
24+
def get_missing_from_compiled(Lng, module=GRAMMAR):
25+
print('investigating', Lng)
26+
cmd = 'echo "pg -missing" | gf -run ' + ALLTENSES_PATH + module + Lng + '.gfo'
27+
missing = subprocess.Popen(cmd, text=True, shell=True,
28+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
29+
output = missing.communicate()[0].split()
30+
return set(output[2:])
31+
32+
# to get all languages in the compiled RGL, use all_langs from here
33+
def all_rgl_compiled_langs():
34+
modules = subprocess.run(['ls', ALLTENSES_PATH], capture_output=True, text=True)
35+
files = str(modules.stdout)
36+
return [file[-7:-4] for file in files.split() if file[:-7].endswith(GRAMMAR)]
37+
38+
# LANGS = all_rgl_compiled_langs() # uncomment this line if you want all languages
39+
40+
41+
# it is much faster to use source files (sending gfos to /tmp)
42+
def str_until(c, s):
43+
i = s.find(c)
44+
if i >= 0:
45+
return s[:i]
46+
else:
47+
return s
48+
49+
def get_missing_from_source(lang, gf_file):
50+
cmd = 'gf -batch -retain -no-pmcfg -src -gfo-dir=/tmp ' + gf_file
51+
missing = subprocess.Popen(cmd, text=True, shell=True,
52+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
53+
output = missing.communicate()[1].split('\n')
54+
missing = (lang, {str_until('\x1b[39;49m', line.split()[-1])
55+
for line in output
56+
if line.strip().startswith('Warning: no linearization of')})
57+
return missing
58+
59+
60+
def all_rgl_source_modules(module=GRAMMAR):
61+
cmd = 'ls ' + RGL_SOURCE_PATH + '*/' + module + '?*.gf'
62+
files = subprocess.Popen(cmd, text=True, shell=True,
63+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
64+
output = files.communicate()[0].split()
65+
return {file[-6:-3]: file for file in output}
66+
67+
LANGS = all_rgl_source_modules() # Lng: file dict
68+
69+
# make a text with tab-separated strings withcolumns fun, type, langs and rows for each fun
70+
def make_table(funs=get_funs(), module=GRAMMAR, langs=LANGS):
71+
header = ['fun', 'type'] + list(langs.keys()) # if dict, otherwise langs ###
72+
rows = [header]
73+
print('\t'.join(header))
74+
75+
# missings = {lang: get_missing_from_compiled(lang, module) for lang in langs}
76+
missings = {lang: get_missing_from_source(lang, file)[1] for lang,file in langs.items()}
77+
for fun in funs:
78+
row = [fun[0], fun[1]]
79+
for lang in langs.keys():
80+
if fun[0] in missings[lang]:
81+
row.append('-')
82+
else:
83+
row.append('+')
84+
rows.append(row)
85+
print('\t'.join(row))
86+
87+
88+
# the output is send to stdout
89+
make_table()
90+
91+
92+
93+

doc/status.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Aarne Ranta
77
The following table gives the languages currently available in the
88
GF Resource Grammar Library.
99

10-
For another view, see the
11-
[The Resource Grammar Library coverage map http://www.postcrashgames.com/gf_world/] .
1210

1311
Corrections and additions are welcome! Notice that only those parts of implementations
1412
that are currently available via https://github.com/GrammaticalFramework/gf-rgl/

doc/synopsis/intro.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ the library, view all functions in a module's scope, and quickly jump to their d
3232
Other relevant documents:
3333
- [The RGL Status Document ../status.html]: the current status of different languages
3434
and the authors of each grammar
35-
- [The Resource Grammar Library coverage map http://www.postcrashgames.com/gf_world/]
3635
- [RGL Documentation and Publications ../rgl-publications.html]: links to publications and other documentation
3736
- [More modules ../gfdoc/sources.html]: extra modules, dictionaries, and
3837
the internals of the resource grammar
@@ -46,7 +45,7 @@ abstract functions and their Universal Dependency labels
4645
- Paper "The GF Resource Grammar Library" by A. Ranta
4746
(//Linguistic Issues in Language Technology//, 2 (2), 2009). An overview of
4847
the library with linguistic motivations.
49-
[PDF http://journals.linguisticsociety.org/elanguage/lilt/article/download/214/214-501-1-PB.pdf]
48+
[PDF https://journals.colorado.edu/index.php/lilt/article/view/1205/1047]
5049
- Paper "Grammars as Software Libraries" by A. Ranta
5150
(In Y. Bertot, G. Huet, J-J. Lévy, and G. Plotkin (eds.),
5251
//From Semantics to Computer Science//, Cambridge University Press,

0 commit comments

Comments
 (0)