Skip to content

Commit

Permalink
[Template merge] Simplify test script, use helper scripts in the core…
Browse files Browse the repository at this point in the history
… instead
  • Loading branch information
snomos committed Jan 18, 2023
1 parent 8a9d994 commit 9e9db0d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion m4/giella-macros.m4
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ AC_MSG_RESULT([$GIELLA_CORE])
###############################################################
### This is the version of the Giella Core that we require. ###
### UPDATE AS NEEDED.
_giella_core_min_version=0.17.1
_giella_core_min_version=0.18.0
# GIELLA_CORE/GTCORE env. variable, required by the infrastructure to find scripts:
AC_ARG_VAR([GIELLA_CORE], [directory for the Giella infra core scripts and other required resources])
Expand Down
2 changes: 2 additions & 0 deletions test/src/morphology/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## Copyright: Sámediggi/Divvun/UiT
## Licence: GPL v3+

TESTS_ENVIRONMENT = export GIELLA_CORE=$(GIELLA_CORE);

######## Test targets: ###########

# List here (space separated) all test scripts that should be run
Expand Down
31 changes: 8 additions & 23 deletions test/src/morphology/tag_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,29 @@ lexctags=$(mktemp -t giella-tag_test.XXXXXXXXXXX)
roottags=$(mktemp -t giella-tag_test.XXXXXXXXXXX)
trap 'rm -f "${lexctags}" "${roottags}"' EXIT

# Ensure we're in langs/sme:
# cd "$(dirname "$0")"/../../.. || exit 1
# Get giella-core from the test environment:
giella_core=$GIELLA_CORE

# If verbose:
if [[ $1 == "-v" ]]; then
echo "$0: Are there tags not declared in root.lexc or misspelled?"
fi

# Extract USED tags:
sed -e '1,/LEXICON Root/d' < \
../../../src/fst/lexicon.tmp.lexc | # Extract all lines after LEXICON Root
cut -d'!' -f1 | # get rid of comments
grep ';' | # Get only lines with
cut -d';' -f1 | # get everything in front of ;
tr ' \t' '\n' | # turn all spaces and tabs into newlines
grep -E '[\+|@]' | # grep relevant stuff only
cut -d':' -f1 | # get rid of surface side
sed 's/+/¢+/g' | # prepare for tag isolation
sed 's/@@/@¢@/g' | # prepare for flag diacritic splitting
tr '¢"#' '\n' | # replace some symbols with newlines = split tags
grep -E '^(\+|@)[A-Za-z]' | # grep only relevant lines / symbols
perl -pe "s#^(\+[^@]+)@#\1\n@#g" | # do a final split of +Tag@C.FLAG@
perl -pe "s#^(@[^@]+@)#\1\n#g" | # do a final cleanup of @C.FLAG@abc
grep -E '^(\+|@)[A-Za-z]' | # grep only relevant lines / symbols
sed 's/\-$//' | # Get rid of final hyphens, they are bogus
${giella_core}/scripts/extract-used-tags.sh | # Extract tags, local mods after this line:
LC_ALL=no_NO.UTF8 sort -u \
> "${lexctags}"

# Extract DEFINED tags:
sed -n '/LEXICON Root/q;p' \
../../../src/fst/lexicon.tmp.lexc | # Extract all lines before LEXICON Root
cut -d'!' -f1 | # Remove comments
sed 's/Multichar_Symbols//' | # Remove the string Multichar_Symbols
tr ' \t' '\n' | # Change all spaces and tabs to newlines
grep -E '^(\+|@)' | # Extract tags and flag diacritics
${giella_core}/scripts/extract-defined-tags.sh | # Extract tags, local mods after this line:
LC_ALL=no_NO.UTF8 sort -u \
> "${roottags}"

# Compare the two sets of tags, report and fail if there is a diff:
check=$(LC_ALL=no_NO.UTF8 comm -23 "${lexctags}" "${roottags}")
if [[ -n "${check}" ]]; then
echo "$0: Have a look at these:"
Expand All @@ -54,6 +42,3 @@ if [[ -n "${check}" ]]; then
elif [[ $1 == "-v" ]]; then
echo "$0: No errors found."
fi

#cat src/fst/clitics.lexc src/fst/compounding.lexc src/fst/affixes/*lexc |cut -d '!' -f1 | grep ';' |tr -s ' ' | sed 's/^ //' |grep ':' |cut -d ':' -f1 | sed 's/\+/¢+/g' | tr '¢' '\n' |sort | uniq -c |sort -n |less
# visuell test: cat src/fst/clitics.lexc src/fst/compounding.lexc src/fst/affixes/*lexc |cut -d '!' -f1 | grep ';' |tr -s ' ' | sed 's/^ //' |grep ':' |cut -d ':' -f1 | tr -d '0' | sed 's/\+/¢+/g' | tr '¢' '\n' |egrep -v '^(\+|\@|<)' |grep -v '^$' |less

0 comments on commit 9e9db0d

Please sign in to comment.