Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 59383cc5 rédigé par Ayush Kumar Shah's avatar Ayush Kumar Shah
Parcourir les fichiers

Merge branch '2-add-inside-relationship-mapping' into 'main'

Resolve "Add Inside relationship mapping"

Closes #2

See merge request dprl/lgeval!2
parents 6167cd70 f72737a7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
################################################################
# Makefile
#
# LgEval
# Feb 8, 2022 - R. Zanibbi
#################################################################
all: conda
# Install python environment for LgEval
conda:
./install
# 'make conda-remove' - remove LgEval conda environment
conda-remove:
conda env remove -n lgeval
......@@ -100,11 +100,31 @@ In addition to metrics, the library provides visualization of label graphs at th
2. perl (**with LibXML**)
3. python 3.x
4. Graphviz (for 'dot')
5. BeautifulSoup4 (`pip install beautifulsoup4`) (required for pretty printing output mathml)
Make sure that *CROHMELibDir* and *LgEvalDir* are defined in
your shell enviroment, e.g. by including the following in your .bashrc initialization script for bash shell. The last line adds the
tools to your search path.
5. Conda (e.g., from Anaconda) and pip for Python environments
**Conda LgEval Environment Install (preferred approach).** To install
the conda environment for lgeval, which will set up both Python packages and
necessary paths for LgEval command line tools, issue:
```
make
```
After installation, the LgEval conda environment can be started by issuing:
```
conda activate lgeval
```
at which point all LgEval tools (e.g., `evaluate`) should be usable as commands at the command line.
To stop using the lgeval conda environment, issue:
```
conda deactivate
```
Note: this will reset shell variables to their previous values.
**Alternative: Bash shell modification (for LgEval and CROHMELib).**
To use the LgEval tools from the command anywhere on your system, make sure that *CROHMELibDir* and *LgEvalDir* are defined in
your shell enviroment, e.g. by including the following in your .bashrc initialization script for bash shell. The last line adds the
tools to your search path.
export LgEvalDir=<path_to_LgEval>
export CROHMELibDir=<path_to_CROHMELib>
......
......@@ -22,6 +22,13 @@ then
exit 0
fi
# RZ: Debug
#echo ""
#echo "[ lg2mml ]"
#echo " LgEvalDir $LgEvalDir"
#echo " PATH $PATH"
#echo " PYTHONPATH $PYTHONPATH"
BNAME=`basename $1 .lg`
python $LgEvalDir/src/lg2txt.py $1 $LgEvalDir/translate/mathMLMap.csv $LgEvalDir/translate/infty_to_crohme.csv > $BNAME.mml
*.mml
#!/bin/bash
# This should be run from the top level directory (lgeval/)
echo "Running test for issue 2 (inside relationship mapping)..."
# NOTE: Assumes 'make' has been run, and lgeval conda env. built
# This provides necessary packages AND paths
source `conda info | grep 'base environment' | awk '{print $4}'`/etc/profile.d/conda.sh
conda activate lgeval
# Show environment (for checking and debugging)
echo "Environment Variables:"
echo " LgEvalDir $LgEvalDir"
echo " PYTHONPATH $PYTHONPATH"
echo " PATH $PATH"
echo ""
TEST_FILES=`ls tests/sqrt_lg/*.lg`
for file in $TEST_FILES
do
lg2mml $file
filename=`basename $file .lg`
echo Input:" "$file
echo ">> MathML: $filename.mml <<"
echo ""
cat $filename.mml
echo ""
done
# Clean up MML files
# Delete ONLY the files that we created.
echo "Deleting .mml files..."
for file in $TEST_FILES
do
rm `basename $file .lg`.mml
done
# Deactivate lgeval environment
conda deactivate
echo "done."
#!/bin/bash
################################################################
# Functions
################################################################
# Report message
mymsg () {
echo " >> $@"
echo ""
}
# Pass number of arguments sent to outer script and success message to invoke.
testSuccess () {
if [ $? -ne 0 ]
then
echo ""
echo "** Installation error ** -- please review error messages above."
# Pass any additional argument, program will not halt.
if [ $1 -eq 0 ]
then
exit $?
else
echo "** Continuing..."
echo ""
fi
else
# Success.
mymsg $2
fi
}
################################################################
# LgEval Conda Environment
################################################################
# Set up Conda environment
echo "[ Creating LgEval Python Environment ]"
CENV=`conda info --envs`
if grep -w "lgeval" <<< "$CENV"
then
mymsg "Conda lgeval environment already created."
else
conda create -n lgeval python=3.6.9
testSuccess $# "Environment (lgeval) created successfully."
CONDSH=`conda info | grep 'base environment' | awk '{print $4}'`/etc/profile.d/conda.sh
source $CONDSH
conda activate lgeval
pip install -r requirements.txt
testSuccess $# "Additional packages installed successfully."
# Set environment variables in scripts run by conda on start/end of activation
# Define and record existing path definitions
LGEVALDIR=`pwd`
PARENTDIR=`cd ..;pwd`
OLDPYTHONPATH=$PYTHONPATH
OLDPATH=$PATH
OLDLGEVALDIR=$LgEvalDir
# Create shell files executed on lgeval conda env activate/deactivate
cd $CONDA_PREFIX
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
ACTIVE_ENV=./etc/conda/activate.d/env_vars.sh
DEACTIVE_ENV=./etc/conda/deactivate.d/end_vars.sh
# Activation script
echo "#!/bin/bash" > $ACTIVE_ENV
echo export LgEvalDir="$LGEVALDIR" >> $ACTIVE_ENV
echo export PYTHONPATH="$PARENTDIR:$PYTHONPATH" >> $ACTIVE_ENV
echo export PATH="$LGEVALDIR/bin:$PATH" >> $ACTIVE_ENV
echo "" >> $ACTIVE_ENV
echo export OLDLGEVALDIR="$OLDLGEVALDIR" >> $ACTIVE_ENV
echo export OLDPYTHONPATH="$PYTHONPATH" >> $ACTIVE_ENV
echo export OLDPATH="$PATH" >> $ACTIVE_ENV
# Deactivation script
echo "#!/bin/bash" > $DEACTIVE_ENV
echo export LgEvalDir=$OLDLGEVALDIR >> $DEACTIVE_ENV
echo export PYTHONPATH=$OLDPYTHONPATH >> $DEACTIVE_ENV
echo export PATH=$OLDPATH >> $DEACTIVE_ENV
echo "" >> $DEACTIVE_ENV
echo unset OLDLGEVALDIR >> $DEACTIVE_ENV
echo unset OLDPYTHONPATH >> $DEACTIVE_ENV
echo unset OLDPATH >> $DEACTIVE_ENV
mymsg "Created environment variables for lgeval conda shell."
conda deactivate
fi
# IUD, CROHME19_754
# Objects(3):
O, 2_1, 2, 1.0, 2
O, _1, \sqrt, 1.0, 0
O, x_1, x, 1.0, 1
# Relations from SRT:
R, _1, x_1, Inside, 1.0
R, x_1, 2_1, Sup, 1.0
# IUD, CROHME19_21
# Objects(6):
O, _1, -, 1.0, 4
O, c_1, c, 1.0, 6
O, _2, \sqrt, 1.0, 5
O, M_1, M, 1.0, 0
O, rarr_1, \rightarrow, 1.0, 1, 2
O, M_2, M, 1.0, 3
# Relations from SRT:
R, M_1, rarr_1, Right, 1.0
R, _1, M_2, Above, 1.0
R, _1, _2, Below, 1.0
R, _2, c_1, Inside, 1.0
R, rarr_1, _1, Right, 1.0
# IUD, CROHME19_1189
# Objects(25):
O, -_1, -, 1.0, 0
O, 4_3, 4, 1.0, 18, 19
O, 4_2, 4, 1.0, 10, 11
O, (_1, (, 1.0, 3
O, gamma_1, \gamma, 1.0, 4
O, +_1, +, 1.0, 5, 6
O, b_1, b, 1.0, 15
O, log_1, \log, 1.0, 7, 8, 9
O, 4_1, 4, 1.0, 1, 2
O, _1, -, 1.0, 31
O, _2, \sqrt, 1.0, 26, 25
O, 1_1, 1, 1.0, 27
O, 1_2, 1, 1.0, 34
O, 3_1, 3, 1.0, 37
O, -_2, -, 1.0, 28
O, +_3, +, 1.0, 16, 17
O, )_1, ), 1.0, 12
O, _3, \sqrt, 1.0, 32, 33
O, +_2, +, 1.0, 13, 14
O, B_1, B, 1.0, 20
O, x_2, x, 1.0, 38, 39
O, pi_1, \pi, 1.0, 21, 23, 22
O, 2_1, 2, 1.0, 24
O, +_4, +, 1.0, 35, 36
O, x_1, x, 1.0, 29, 30
# Relations from SRT:
R, (_1, gamma_1, Right, 1.0
R, )_1, +_2, Right, 1.0
R, +_1, log_1, Right, 1.0
R, +_2, b_1, Right, 1.0
R, +_3, _1, Right, 1.0
R, +_4, 3_1, Right, 1.0
R, -_1, 4_1, Right, 1.0
R, -_2, x_1, Right, 1.0
R, 1_1, -_2, Right, 1.0
R, 1_2, +_4, Right, 1.0
R, 3_1, x_2, Right, 1.0
R, 4_1, (_1, Right, 1.0
R, 4_2, )_1, Right, 1.0
R, 4_3, B_1, Right, 1.0
R, B_1, pi_1, Right, 1.0
R, _1, 4_3, Above, 1.0
R, _1, _3, Below, 1.0
R, _2, -_2, Inside, 1.0
R, _2, 1_1, Inside, 1.0
R, _3, +_4, Inside, 1.0
R, _3, 1_2, Inside, 1.0
R, b_1, +_3, Right, 1.0
R, gamma_1, +_1, Right, 1.0
R, log_1, 4_2, Right, 1.0
R, pi_1, 2_1, Sup, 1.0
R, pi_1, _2, Right, 1.0
......@@ -366,6 +366,7 @@ ANY,SUBSC,SUPER,->,<msubsup>,PARENT,SUBSC,SUPER,</msubsup>
Right,->,<mrow>,PARENT,CHILD,</mrow>
R,->,<mrow>,PARENT,CHILD,</mrow>
r,->,<mrow>,PARENT,CHILD,</mrow>
Inside,->,<mrow>,PARENT,CHILD,</mrow>
HOR,->,<mrow>,PARENT,CHILD,</mrow>
^,->,<msup>,PARENT,CHILD,</msup>
_,->,<msub>,PARENT,CHILD,</msub>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter