forked from UniversalDependencies/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedata.sh
executable file
·37 lines (29 loc) · 901 Bytes
/
makedata.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -u
set -e
DATA_DIRECTORY="_data"
RELATION_DATA_FILE="$DATA_DIRECTORY/relations.yaml"
LANGUAGES="en-dep fi-dep ud-dep"
# directory names are language names with an underscore prefix.
DIRECTORIES=$(echo " $LANGUAGES" | perl -pe 's/ (\S)/ _$1/g')
# unique relation (document) names from per-language directories
RELATIONS=$(find $DIRECTORIES -name '*.md' -printf '%f\n' |
perl -pe 's/\.md$//' | sort | uniq)
# clear data dir, if any
if [ -e $DATA_DIRECTORY ]; then
rm -rf $DATA_DIRECTORY
fi
mkdir $DATA_DIRECTORY
# generate YAML with relations and languages
for r in $RELATIONS; do
echo "- label: '$r'"
echo " languages:"
for l in $LANGUAGES; do
if [ -e "_$l/$r.md" ]; then
echo " - label: '$l'"
fi
done
done > $RELATION_DATA_FILE
echo "Found" \
$(echo "$RELATIONS" | wc -w) "relations in" \
$(echo "$LANGUAGES" | wc -w) "languages" >&2