--- makemdl.sh.orig	2012-03-01 09:38:37.000000000 +0900
+++ makemdl.sh	2012-03-07 01:36:42.000000000 +0900
@@ -6,19 +6,48 @@
 
 export LANG=C
 
 dir=`cd $(dirname $0) && pwd`
 
 . $dir/conf.sh
 
 export EXOPLIB=$dir/lib
 
-cat $dir/makemodel/tsv/*.tsv > $dir/makemodel/data.tsv
-cat $dir/makemodel/data.tsv > $dir/makemodel/data_pol.tsv
-
-$dir/_train.sh makemodel/model/model $dir/makemodel/data.tsv $dir/makemodel/data.tsv $dir/makemodel/data.tsv $dir/makemodel/data_pol.tsv $dir/makemodel/data.tsv
-rm $dir/makemodel/data.tsv $dir/makemodel/data_pol.tsv
-
-
-
-
+cmd=`basename $0`
 
+usage() {
+  echo "Usage: $cmd [options] [csvfiles]"
+  echo "Options: -h, --help            Show this message"
+  echo "         -d, --dictionary DIR  Specify the dictionary directory"
+  echo "         -m, --model      BASE Specify the base path of model files"
+  echo "         -t, --tmpdir     DIR  Specify the temporary directory"
+  exit -1
+}
+
+csvfiles=*.csv
+model=./model
+
+while test -n "$1"; do
+    case "$1" in
+        -h|--help)       usage ;;
+        -d|--dictionary) dictionary="$2"; shift 2 ;;
+        -m|--model)      model="$2";      shift 2 ;;
+        -t|--tmpdir)     TMPDIR="$2";     shift 2 ;;
+        *)               csvfiles="$@";   break ;;
+    esac
+done
+
+workdir=${TMPDIR}/extractopinion-$$
+mkdir -p $workdir/tsv
+
+for file in $csvfiles
+do
+  f=`basename $file .csv`
+  perl -I $dir/lib $dir/makemodel/csv/csv2tsv.pl $file > $workdir/tsv/$f.tsv
+done
+
+cat $workdir/tsv/*.tsv > $workdir/data.tsv
+cat $workdir/data.tsv  > $workdir/data_pol.tsv
+
+$dir/_train.sh $model $workdir/data.tsv $workdir/data.tsv $workdir/data.tsv $workdir/data_pol.tsv $workdir/data.tsv
+rm $workdir/data.tsv $workdir/data_pol.tsv
+rm -rf $workdir
