Skip to content

InstallMorphologiesScript

eaxelson edited this page Nov 20, 2017 · 2 revisions
#!/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
Clone this wiki locally