Difference between revisions of "QLever/script"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
This is a script for getting started with {{Link|target=QLever}} along the lines of the [https://github.com/ad-freiburg/qlever/blob/master/docs/quickstart.md Quickstart] description | This is a script for getting started with {{Link|target=QLever}} along the lines of the [https://github.com/ad-freiburg/qlever/blob/master/docs/quickstart.md Quickstart] description | ||
+ | |||
+ | see | ||
+ | * {{Ticket | ||
+ | |number=562 | ||
+ | |title=qlever bash script | ||
+ | |project=qlever | ||
+ | |createdAt=2022-01-29 17:15:21+00:00 | ||
+ | |closedAt= | ||
+ | |state=open | ||
+ | }} | ||
= usage = | = usage = | ||
<source lang='bash'> | <source lang='bash'> |
Revision as of 08:07, 30 January 2022
This is a script for getting started with QLever along the lines of the Quickstart description
see
usage
./qlever -h
usage: ./qlever [-h|--help]
-h|--help: show this usage
-b|--build: build qlever docker image
-c|--clone: clone qlever
-e|--env: show environment
-wd|--wikidata_download: download wikidata data dump
This helper script simplifies the access to the steps outlined in https://github.com/ad-freiburg/qlever/blob/master/docs/quickstart.md
qlever
#!/bin/bash
# WF 2022-01-28
export QLEVER_HOME=$(pwd)
#ansi colors
#http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
blue='\033[0;34m'
red='\033[0;31m'
green='\033[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\033[0m'
#
# a colored message
# params:
# 1: l_color - the color of the message
# 2: l_msg - the message to display
#
color_msg() {
local l_color="$1"
local l_msg="$2"
echo -e "${l_color}$l_msg${endColor}"
}
#
# error
#
# show an error message and exit
#
# params:
# 1: l_msg - the message to display
error() {
local l_msg="$1"
# use ansi red for error
color_msg $red "Error: $l_msg" 1>&2
exit 1
}
#
# show the usage
#
usage() {
echo "usage: $0 [-h|--help]"
echo " -h|--help: show this usage"
echo " -b|--build: build qlever docker image"
echo " -c|--clone: clone qlever"
echo " -e|--env: show environment"
echo " -wd|--wikidata_download: download wikidata data dump"
}
#
# show the environment
#
show_env() {
color_msg $blue "operating system"
lsb_release -a
color_msg $blue "docker version"
docker --version
color_msg $blue "memory"
free -h
color_msg $blue "diskspace"
df | grep /dev/s
}
#
# clone the qlever code
#
qlever_clone() {
cd $QLEVER_HOME
if [ ! -d qlever-code ]
then
color_msg $blue "cloning qlever - please wait approx 1 min ..."
git clone --recursive https://github.com/ad-freiburg/qlever qlever-code
else
color_msg $green "clone of clever-code already available"
fi
}
#
# build the docker image
#
qlever_build() {
#docker images | grep qlever
#if [ $? -ne 0 ]
#then
cd $QLEVER_HOME/qlever-code
color_msg $blue "building qlever - please wait approx 15 min ..."
# date;docker build -t qlever .;date
date;docker build --file Dockerfiles/Dockerfile.Ubuntu20.04 -t qlever .;date
#else
# color_msg $green "qlever image already build"
#fi
}
#
# wikidata download
#
wikidata_download() {
cd $QLEVER_HOME
target=qlever-indices/wikidata
if [ ! -d $target ]
then
mkdir -p $target
cd $target
config=$QLEVER_HOME/qlever-code/examples/wikidata.settings.json
color_msg $blue "copying config file $config"
cp -p $config .
color_msg $blue "downloading wikidata lexemes ... please wait approx 3 min ..."
date;wget https://dumps.wikimedia.org/wikidatawiki/entities/latest-lexemes.ttl.bz2;date
color_msg $blue "downloading wikidata dump ... please wait approx 6 hours ..."
date;wget https://dumps.wikimedia.org/wikidatawiki/entities/latest-all.ttl.bz2;date
else
color_msg $green "wikidata dump already downloaded"
fi
}
#
# build the wikidata index
#
wikidata_index() {
chmod o+w . && docker run -it --rm -v $QLEVER_HOME/qlever-indices/wikidata:/index --entrypoint bash qlever -c "cd /index && bzcat latest-all.ttl.bz2 latest-lexemes.ttl.bz2 | IndexBuilderMain -F ttl -f - -l -i wikidata -s wikidata.settings.json | tee wikidata.index-log.txt"
}
# commandline option
while [ "$1" != "" ]
do
option=$1
shift
case $option in
-h|--help)
usage;;
-b|--build)
qlever_build;;
-c|--clone)
qlever_clone;;
-e|--env)
show_env;;
-wd|--wikidata_download)
wikidata_download;;
-wi|--wikidata-index)
wikidata_index;;
esac
done