aboutsummaryrefslogtreecommitdiffstats
path: root/demo.sh
diff options
context:
space:
mode:
authorYigit Sever2019-09-19 00:17:45 +0300
committerYigit Sever2019-09-19 00:17:45 +0300
commit4ffdd84d704d9040cd493b0ca8e53fb15278be26 (patch)
tree56655ffb637edfcf31a1268722c541414336ecd9 /demo.sh
parentf9bc1db3284f2bf05f7b1cf55ab912363c6e8440 (diff)
downloadEvaluating-Dictionary-Alignment-4ffdd84d704d9040cd493b0ca8e53fb15278be26.tar.gz
Evaluating-Dictionary-Alignment-4ffdd84d704d9040cd493b0ca8e53fb15278be26.tar.bz2
Evaluating-Dictionary-Alignment-4ffdd84d704d9040cd493b0ca8e53fb15278be26.zip
Include demo script, untested
diffstat (limited to 'demo.sh')
-rw-r--r--demo.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/demo.sh b/demo.sh
new file mode 100644
index 0000000..51346f3
--- /dev/null
+++ b/demo.sh
@@ -0,0 +1,85 @@
1#!/bin/bash
2#
3# Copyright © 2019 Yiğit Sever <yigit.sever@tedu.edu.tr>
4#
5# Permission is hereby granted, free of charge, to any person obtaining
6# a copy of this software and associated documentation files (the "Software"),
7# to deal in the Software without restriction, including without limitation
8# the rights to use, copy, modify, merge, publish, distribute, sublicense,
9# and/or sell copies of the Software, and to permit persons to whom the
10# Software is furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included
13# in all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
21# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22#
23#
24
25ROOT="$(pwd)"
26SCRIPTS="${ROOT}/scripts"
27WNET="${ROOT}/wordnets"
28EMBS="${ROOT}/embeddings"
29DICT="${ROOT}/dictionaries"
30
31TRAIN_DIR="${DICT}/train"
32TEST_DIR="${DICT}/test"
33
34TAB_DIR="${WNET}/tab_files"
35READY="${WNET}/ready"
36mkdir -p "${WNET}"
37
38wget -nc -q http://compling.hss.ntu.edu.sg/omw/wns/bul.zip -P "${WNET}"
39unzip -o -q "${WNET}/bul.zip" -d "${WNET}"
40
41mkdir -p "${TAB_DIR}"
42"${SCRIPTS}/tab_creator.pl" "${WNET}/bul/wn-data-bul.tab" "${TAB_DIR}"
43
44python "${SCRIPTS}/prep_lookup.py" -s "en" -t "bg"
45
46mkdir -p "${READY}"
47mv "${ROOT}"/*.def "${READY}"
48
49mkdir -p "${DICT}"
50
51wget -nc -q https://object.pouta.csc.fi/OPUS-OpenSubtitles/v2018/dic/bg-en.dic.gz -P "${DICT}" # Bulgarian - English
52gunzip -q "${DICT}/bg-en.dic.gz"
53
54export LC_CTYPE=en_US.UTF-8
55export LC_ALL=en_US.UTF-8
56
57perl "${SCRIPTS}/train_dic_creator.pl" "en" "bg" "${DICT}"
58
59mkdir -p "${TRAIN_DIR}"
60mkdir -p "${TEST_DIR}"
61
62mv "${DICT}"/*.train "${TRAIN_DIR}"
63mv "${DICT}"/*.test "${TEST_DIR}"
64rm -f "${DICT}"/*.dic
65
66wget -nc -q https://dl.fbaipublicfiles.com/fasttext/vectors-crawl/cc.bg.300.vec.gz -P "${EMBS}" # Bulgarian
67wget -nc -q https://dl.fbaipublicfiles.com/fasttext/vectors-english/crawl-300d-2M.vec.zip -P "${EMBS}" # English
68mv "${EMBS}/cc.bg.300.vec" "${EMBS}/bg.vec"
69gunzip "${EMBS}/cc.bg.300.vec.gz"
70mv "${EMBS}/cc.bg.300.vec" "${EMBS}/bg.vec"
71unzip -q "${EMBS}/crawl-300d-2M.vec.zip" -d "${EMBS}"
72mv "${EMBS}/crawl-300d-2M.vec" "${EMBS}/en.vec"
73
74
75for lang_code in bg en; do
76 sed -i '1,500001!d' "${EMBS}/${lang_code}.vec"
77 sed -i '1 s/^.*$/500000 300/' "${EMBS}/${lang_code}.vec"
78done
79
80python "${ROOT}/vecmap/map_embeddings.py" --supervised \
81 "${TRAIN_DIC_DIR}/en_bg.train" \
82 "${EMBS}/en.vec" \
83 "${EMBS}/bg.vec" \
84 "${MAP_TO}/en_to_bg.vec" \
85 "${MAP_TO}/bg_to_en.vec" > /dev/null 2>&1