Skip to content

Commit

Permalink
add conll scripts to be called from setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarjoshi90 committed Aug 18, 2019
1 parent 1959e65 commit 7b73b84
Show file tree
Hide file tree
Showing 8 changed files with 3,620 additions and 0 deletions.
642 changes: 642 additions & 0 deletions conll-2012/v3/scripts/conll2coreference.py

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletions conll-2012/v3/scripts/conll2coreference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/bin/bash

function usage {
cat <<EOF
----------------------------------------------------------------------------------------------------
Usage:
-----
${0##*/} <conll-file>
Description:
-----------
Takes a *conll file as input and prints out the corresponding coreference file
----------------------------------------------------------------------------------------------------
EOF
exit;
}


function message
{
echo "----------------------------------------------------------------------------------------------------"
echo
echo $* 1>&2
echo
echo "----------------------------------------------------------------------------------------------------"

}



function r { echo ${1%.*}; }
function t { echo ${1##*/}; }
function e { echo $(t ${1##*.}); }
function h { echo ${1%/*}; }

# define helper function: run a command and print its exit code
function erun () {
debug=0
if [[ $1 == "-d" ]]; then
debug=1
shift;
fi


if [[ $DEBUG -eq 1 ]]; then
debug=1
fi




verbose=0
if [[ $1 == "-v" ]]; then
verbose=1
shift;
fi


if [[ $VERBOSE -eq 1 ]]; then
verbose=1
fi






if [[ $debug -eq 1 ]]; then
echo "debug mode ..."
echo "eval $1"
else
echo "normal mode ..."
if [[ $verbose -eq 1 ]]; then
echo -e "\nrun: $1\n-------------"
fi

eval $1
fi


local code=$?
if [ $code -ne 0 ]; then
echo "Exit code: $code"
exit $code
fi
}




# handle the valid command line options
DEBUG=0
VERBOSE=0
DEBUG_OPTION=""
while getopts vdh opt
do
case "$opt" in
v)
VERBOSE=1;;

d)
DEBUG=1;;

\?)
usage
exit 1;;

h)
usage
exit 0;;

:)
echo "option -$OPTARG requires an argument"
usage
exit 1;;

esac
done
shift `expr $OPTIND - 1`


# at this point $* contains the arguments after interpreting the options

d=$1

# if no arguments are specified, then just print usage
if [[ $# -eq 0 ]]; then
usage
fi


# debugging
if [[ $DEBUG -eq 1 ]]; then
echo "debugging mode is on ..." 1>&2
DEBUG_OPTION="-d"
fi





for file in $(find $d -name "*_conll"); do

if [[ $file =~ "data/english/annotations" ]]; then
LANGUAGE=english
elif [[ $file =~ "data/chinese/annotations" ]]; then
LANGUAGE=chinese
else
LANGUAGE=arabic
fi

echo "language: $LANGUAGE"
coref=${file/_conll/_coref}
echo "$file -> $coref ..."
conll2coreference.py -l $LANGUAGE $file > $coref
done








# complain if the exit status of the last command executed is non-zero
if [[ $? != 0 ]]; then echo "the last command exited with a non-zero status" 1>&2; fi



Loading

0 comments on commit 7b73b84

Please sign in to comment.