aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2019-09-19 00:22:46 +0300
committerYigit Sever2019-09-19 00:22:46 +0300
commitf930fb325ec68e9522c689132d20ea335b30dbbe (patch)
tree37917602b2de3f251a23b195e4be689fa9ed18f4
parent1890976ed1eee59eda92ceabdcb1c966d6707269 (diff)
parent4ffdd84d704d9040cd493b0ca8e53fb15278be26 (diff)
downloadEvaluating-Dictionary-Alignment-f930fb325ec68e9522c689132d20ea335b30dbbe.tar.gz
Evaluating-Dictionary-Alignment-f930fb325ec68e9522c689132d20ea335b30dbbe.tar.bz2
Evaluating-Dictionary-Alignment-f930fb325ec68e9522c689132d20ea335b30dbbe.zip
Merge branch 'master' of github.com:yigitsever/Evaluating-Dictionary-Alignment
-rw-r--r--demo.sh85
-rwxr-xr-xget_data.sh1
-rwxr-xr-xget_embeddings.sh7
3 files changed, 90 insertions, 3 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
diff --git a/get_data.sh b/get_data.sh
index 2d04678..4f97ad5 100755
--- a/get_data.sh
+++ b/get_data.sh
@@ -67,6 +67,7 @@ mv "${ROOT}"/*.def "${READY}"
67echo "Downloading dictionaries" 67echo "Downloading dictionaries"
68 68
69DICT="${ROOT}/dictionaries" 69DICT="${ROOT}/dictionaries"
70mkdir -p "${DICT}"
70 71
71wget -nc -q https://object.pouta.csc.fi/OPUS-OpenSubtitles/v2018/dic/en-sq.dic.gz -P "${DICT}" # English - Albanian 72wget -nc -q https://object.pouta.csc.fi/OPUS-OpenSubtitles/v2018/dic/en-sq.dic.gz -P "${DICT}" # English - Albanian
72wget -nc -q https://object.pouta.csc.fi/OPUS-OpenSubtitles/v2018/dic/bg-en.dic.gz -P "${DICT}" # Bulgarian - English 73wget -nc -q https://object.pouta.csc.fi/OPUS-OpenSubtitles/v2018/dic/bg-en.dic.gz -P "${DICT}" # Bulgarian - English
diff --git a/get_embeddings.sh b/get_embeddings.sh
index daf839b..47a7a8e 100755
--- a/get_embeddings.sh
+++ b/get_embeddings.sh
@@ -25,6 +25,7 @@ set -o errexit -o pipefail -o noclobber -o nounset
25 25
26ROOT="$(pwd)" 26ROOT="$(pwd)"
27EMBS="${ROOT}/embeddings" 27EMBS="${ROOT}/embeddings"
28DICT="${ROOT}/dictionaries"
28mkdir -p "${EMBS}" 29mkdir -p "${EMBS}"
29 30
30echo "Downloading embeddings" 31echo "Downloading embeddings"
@@ -58,15 +59,15 @@ if [ ! "$(ls -A "${ROOT}/vecmap/")" ]; then
58 echo "VecMap directory seems empty, did you run git submodule init && git submodule update?"; exit 59 echo "VecMap directory seems empty, did you run git submodule init && git submodule update?"; exit
59fi 60fi
60 61
61if [ ! -d "${ROOT}/dictionaries" ]; then 62if [ ! -d "${DICT}" ]; then
62 echo "Dictionaries directory does not exist, did you run ./get_data.sh?"; exit 63 echo "Dictionaries directory does not exist, did you run ./get_data.sh?"; exit
63fi 64fi
64 65
65if [ ! "$(ls -A "${ROOT}/dictionaries/")" ]; then 66if [ ! "$(ls -A "${DICT}")" ]; then
66 echo "Dictionaries directory seems empty, did you run ./get_data.sh?"; exit 67 echo "Dictionaries directory seems empty, did you run ./get_data.sh?"; exit
67fi 68fi
68 69
69TRAIN_DIC_DIR="${ROOT}/dictionaries/train" 70TRAIN_DIC_DIR="${DICT}/train"
70MAP_TO="${ROOT}/bilingual_embeddings" 71MAP_TO="${ROOT}/bilingual_embeddings"
71 72
72mkdir -p "${MAP_TO}" 73mkdir -p "${MAP_TO}"