This file is indexed.

/usr/bin/hfst-foma-wrapper.sh is in hfst 3.10.0~r2798-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#foma_exec=@FOMACLI@
foma_exec=/usr/bin/hfst_foma
if [ ! -x $foma_exec ] ; then
    echo "$0 could not find executable foma from $foma_exec"
    exit 1
fi

function print_usage() {
    echo "Usage: $0 [-h|-V] [-v|-s|-q] [-f FORMAT] [-F STACK_FILES] [SCRIPTS]"
}

function print_help() {
    echo "Uses foma to parse xfst scripts converts results to HFST3 format"
    echo
    echo "  -h   print this help text"
    echo "  -V   print script version"
    echo "  -v   print verbosely while processing"
    echo "  -q   do not print while processing"
    echo "  -s   alias of -q"
    echo "  -f   select output format as HFST3 supported format names"
    echo "  -F   list files which xfst script saves as stacks that can be converted to HFST3 format"
    echo "  -X   pass option string to foma verbatim"
    echo
    echo "if SCRIPTS and input parameters from X are missing, stdin is used."
    echo "Output is written to stdout."
    echo "If -f is omitted, HFST3 default is used"
    echo "If -F is omitted, we try to guess files to convert automatically"
}

function print_version() {
    echo "hfst-foma-wrapper 0.1"
    echo "Copyright (c) 2010 University of Helsinki"
    echo "Licence GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>"
    echo "This is free software: you are free to change and redistribute it."
    echo "There is NO WARRANTY, to the extent permitted by law."
}

while getopts "vqshVf:F:X:" flag ; do
    case $flag in
    h) print_help; exit 0;;
    V) print_version; exit 0;;
    v) verbose="-v";;
    s|q) quiet="-q";;
    f) format="-f $OPTARG";;
    F) files="$OPTARG";;
    X) fomaopts="$OPTARG";;
    \?) echo "Unknown command line switch $OPTARG, try -h for help"; print_usage; exit 1;;
    esac
done
hfstopts="$quiet $verbose $format"
if [ x$verbose != x-v -a x$quiet != x-q ] ; then
    fomaopts="$fomaopts -p"
    hfstopts=-v
fi
shift $(($OPTIND-1))
if [ -z $@ ] ; then
    if [ "x$verbose" == "x-v" ] ; then
        echo "running $foma_exec $fomaopts"
    fi
    if ! $foma_exec $fomaopts; then 
        echo "$foma_exec failed"
        exit 1
    fi
fi
for f in $@ ; do
    if [ "x$verbose" == "x-v" ] ; then
        echo "running $foma_exec $fomaopts -f $f"
    fi
    if ! $foma_exec $fomaopts -f "$f" ; then
        echo "$foma_exec -f $f failed"
        exit 1
    fi
done


if [ -z $files ] ; then
    scripts="$(echo $fomaopts | sed 's/ -f //') $scripts"
    for f in $@ $scripts; do
        if test -f ./"$f" ; then
            if egrep -q '^(save stack|ss)' ./"$f" ; then
                files="$(egrep '^(save stack|ss)' < "$f" | sed -e 's/^save stack //' -e 's/^ss //') $files"
            fi
      fi
    done
    files=$(echo $files | tr -s ' ' '\n' | sort | uniq)
    if [ "x$verbose" == "x-v" ] ; then
        echo "discovered stack files: $files"
    fi
fi
if [ -z "$files" ] ; then
    echo "Unable to find saved stack files to convert..."
    echo "HFST-xfst can only use -f scripts with save stack command or"
    echo "-l scripts with save stack before interactive part"
    exit 1
fi
for f in $files ; do
    if test -f "$f" ; then
        if [ "x$verbose" == "x-v" ] ; then
            echo "converting $f"
        fi
        printf "load stack $f\nwatt $f.att\nquit" > $f.tmpscript
        if ! $foma_exec -q -f $f.tmpscript ; then
            echo "converting $f from foma to text failed"
            exit 1
        fi
        sed -e 's/		/	@_TAB_@/g' -e 's/	 /	@_SPACE_@/g' < "$f".att > "$f".att2
        mv "$f".att2 "$f".att
        if ! hfst-txt2fst -e '@0@' $verbose $hfstopts $format -i "$f.att" -o "$f" ; then
            echo "converting $f from text to HFST3 failed"
            exit 1
        fi
        rm $f.tmpscript $f.att
    fi
done
# vim: set ft=bash