Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mecab add-user-dic.sh update #29

Open
seungwookim opened this issue Aug 11, 2017 · 0 comments
Open

mecab add-user-dic.sh update #29

seungwookim opened this issue Aug 11, 2017 · 0 comments

Comments

@seungwookim
Copy link
Member

#!/bin/bash

readonly PROG_NAME=$(basename $0)
readonly PROG_DIR=$(readlink -m $(dirname $0))
readonly DIC_PATH=$PROG_DIR/..
readonly USERDIC_PATH=${DIC_PATH}/user-dic
readonly MECAB_EXEC_PATH=/usr/local/libexec/mecab
readonly DICT_INDEX=$MECAB_EXEC_PATH/mecab-dict-index

get_userdics() {
pushd $USERDIC_PATH &> /dev/null
echo $(ls *.csv)
popd &> /dev/null
}

gen_cost() {
local input_dic=$1
echo $input_dic

$DICT_INDEX \
    -m ${DIC_PATH}/model.def \
    -d ${DIC_PATH} \
    -u ${DIC_PATH}/user-${input_dic} \
    -f utf-8 \
    -t utf-8 \
    -a ${USERDIC_PATH}/$input_dic

}

compile() {
pushd $DIC_PATH &> /dev/null
make clean;make
popd &> /dev/null
}

copy() {
local input_dic=$1
echo $input_dic
cp ${USERDIC_PATH}/$input_dic ${DIC_PATH}/user-${input_dic}

}

main() {
echo "generating userdic..."

for dic in $(get_userdics); do
    gen_cost $dic
done

compile

for dic in $(get_userdics); do
    copy $dic
done

}

main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant