HFST: A script for installing morphologies on Hippu

#!/bin/sh

# This script downloads and installs HFST morphologies and acompanying scripts
# Requires HFST installation, wget, tar, make, install
# Author: Martin Matthiesen, CSC based on a script by Erik Axelson


# Base URL for download
DOWNLOAD_URL=http://sourceforge.net/projects/hfst/files/resources/morphological-transducers/

# Languages to install
LANGUAGES="omorfi english finnish french german italian swedish turkish"

# Determine HFST_ROOT
if ( which hfst-lookup >& /dev/null ) then
    HFST_LOOKUP=`which hfst-lookup`
    HFST_ROOT=`dirname $HFST_LOOKUP|sed 's%/bin$%%'`
else
    echo hfst-lookup not found, is hfst installed? Aborting.
    exit 1
fi


# Set download directory
TEMP_DIR=/tmp/hfst
mkdir -p $TEMP_DIR
cd $TEMP_DIR

echo Morphology installer
echo This script installs the hfst morphologies for the languages: $LANGUAGES
echo
echo Installing using prefix $HFST_ROOT
echo Downloading to and installing from  $TEMP_DIR
echo
echo Hit enter to continue, CTRL-C to stop.
read


# Get, extract and install morphologies
for LANG in $LANGUAGES; do 
    PACKAGE=hfst-$LANG-installable.tar.gz;
    PACKAGE_DIR=`basename $PACKAGE .tar.gz`;

    # Get package if it does not exist
    echo "### Getting $PACKAGE (if needed)..."
    if !([ -f $PACKAGE ]) then
   wget $DOWNLOAD_URL/$PACKAGE;
    fi

    # Unpack if not done earlier
    echo "### Unpacking $PACKAGE (if needed)..."
    if !([ -f $PACKAGE_DIR/Makefile ]) then 
   tar -xzvf $PACKAGE;
    fi

    # Install to HFST_ROOT
    echo "### Installing $PACKAGE ..."
    if ! (make -C $PACKAGE_DIR install prefix=$HFST_ROOT); then
   echo "### ERROR ###: Error in installing "$LANG to $HFST_ROOT;
    fi
done



-- ErikAxelson - 2013-11-01

Topic revision: r4 - 2015-09-03 - MartinMatthiesen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback