install mecab
## prepare
(base) root@rasa-virtual-machine:~/node# wget https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz
--2021-11-16 10:09:02-- https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz
bitbucket.org (bitbucket.org)을(를) 해석하는 중... 104.192.141.1, 2406:da00:ff00::22c5:2ef4, 2406:da00:ff00::22e9:9f55, ...
접속 bitbucket.org (bitbucket.org)|104.192.141.1|:443... 접속됨.
HTTP 요청을 전송했습니다. 응답을 기다리는 중입니다... 302 Found
위치: https://bbuseruploads.s3.amazonaws.com/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz?Signature=7XEG%2B6DvAc3XNI5H%2BYzJH4NxOIg%3D&Expires=1637026717&AWSAccessKeyId=AKIA6KOSE3BNJRRFUUX6&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22mecab-0.996-ko-0.9.2.tar.gz%22&response-content-encoding=None [따라감]
--2021-11-16 10:09:03-- https://bbuseruploads.s3.amazonaws.com/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz?Signature=7XEG%2B6DvAc3XNI5H%2BYzJH4NxOIg%3D&Expires=1637026717&AWSAccessKeyId=AKIA6KOSE3BNJRRFUUX6&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22mecab-0.996-ko-0.9.2.tar.gz%22&response-content-encoding=None
bbuseruploads.s3.amazonaws.com (bbuseruploads.s3.amazonaws.com)을(를) 해석하는 중... 52.216.141.28
접속 bbuseruploads.s3.amazonaws.com (bbuseruploads.s3.amazonaws.com)|52.216.141.28|:443... 접속됨.
HTTP 요청을 전송했습니다. 응답을 기다리는 중입니다... 200 OK
길이: 1414979 (1.3M) [application/x-tar]
다음 위치에 저장: `mecab-0.996-ko-0.9.2.tar.gz'
mecab-0.996-ko-0.9.2.tar.gz 100%[=========================================================>] 1.35M 1.12MB/s / 1.2s
2021-11-16 10:09:05 (1.12 MB/s) - `mecab-0.996-ko-0.9.2.tar.gz' 저장됨 [1414979/1414979]
(base) root@rasa-virtual-machine:~/node# wget https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.0.1-20150920.tar.gz
--2021-11-16 10:09:16-- https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.0.1-20150920.tar.gz
bitbucket.org (bitbucket.org)을(를) 해석하는 중... 104.192.141.1, 2406:da00:ff00::22cd:e0db, 2406:da00:ff00::3403:4be7, ...
접속 bitbucket.org (bitbucket.org)|104.192.141.1|:443... 접속됨.
HTTP 요청을 전송했습니다. 응답을 기다리는 중입니다... 302 Found
위치: https://bbuseruploads.s3.amazonaws.com/a4fcd83e-34f1-454e-a6ac-c242c7d434d3/downloads/7f7f2725-cf12-4c23-8934-bec686cb3f93/me
## build mecab
(base) root@rasa-virtual-machine:~/node# cd mecab-0.996-ko-0.9.2/
(base) root@rasa-virtual-machine:~/node/mecab-0.996-ko-0.9.2# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
## build mecab
(base) root@rasa-virtual-machine:~/node/mecab-ko-dic-2.0.1-20150920# make
/usr/local/libexec/mecab/mecab-dict-index -d . -o . -f UTF-8 -t UTF-8
reading ./unk.def ... 13
emitting double-array: 100% |###########################################|
reading ./IC.csv ... 1306
reading ./XR.csv ... 3637
reading ./Wikipedia.csv ... 36763
reading ./VX.csv ... 125
reading ./MAG.csv ... 14244
reading ./VV.csv ... 7331
reading ./ETN.csv ... 14
(base) root@rasa-virtual-machine:~/node/mecab-0.996-ko-0.9.2# make install
Making install in src
make[1]: 디렉터리 '/root/node/mecab-0.996-ko-0.9.2/src' 들어감
make[2]: 디렉터리 '/root/node/mecab-0.996-ko-0.9.2/src' 들어감
test -z "/usr/local/lib" || /usr/bin/mkdir -p "/usr/local/lib"
/bin/bash ../libtool --mode=install /usr/bin/install -c libmecab.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libmecab.so.2.0.0 /usr/local/lib/libmecab.so.2.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libmecab.so.2.0.0 libmecab.so.2 || { rm -f libmecab.so.2 && ln -s libmecab.so.2.0:
## build mecab dic
(base) root@rasa-virtual-machine:~/node/mecab-ko-dic-2.0.1-20150920# ./autogen.sh
Looking in current directory for macros.
configure.ac:2: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
configure.ac:2: https://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
(base) root@rasa-virtual-machine:~/node/mecab-ko-dic-2.0.1-20150920# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/root/node/mecab-ko-dic-2.0.1-20150920/missing: Unknown `--is-lightweight' option
Try `/root/node/mecab-ko-dic-2.0.1-20150920/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for mecab-config... /usr/local/bin/mecab-config
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
(base) root@rasa-virtual-machine:~/node/mecab-ko-dic-2.0.1-20150920# make
/usr/local/libexec/mecab/mecab-dict-index -d . -o . -f UTF-8 -t UTF-8
reading ./unk.def ... 13
emitting double-array: 100% |###########################################|
reading ./IC.csv ... 1306
reading ./XR.csv ... 3637
reading ./Wikipedia.csv ... 36763
reading ./VX.csv ... 125
reading ./MAG.csv ... 14244
reading ./VV.csv ... 7331
reading ./ETN.csv ... 14
reading ./EC.csv ... 2547
## install mecab-ffi
(base) root@rasa-virtual-machine:~/node# npm install mecab-ffi
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
> ref@1.3.5 install /root/node/node_modules/ref
> node-gyp rebuild
make: 디렉터리 '/root/node/node_modules/ref/build' 들어감
CXX(target) Release/obj.target/binding/src/binding.o
../src/binding.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::WriteObject(Nan::NAN_METHOD_ARGS_TYPE)’:
.
## test
var mecab = require('mecab-ffi');
var paragraph ='추억은 만남보다 이별에 남아 검색 해 줘';
// 형태소 분석
mecab.parse(paragraph, function(err, result) {
console.log(result);
});
## result
(base) root@rasa-virtual-machine:~/node# node test.js
[ [ '추억', 'NNG', '*', 'T', '추억', '*', '*', '*', '*' ],
[ '은', 'JX', '*', 'T', '은', '*', '*', '*', '*' ],
[ '만남', 'NNG', '*', 'T', '만남', '*', '*', '*', '*' ],
[ '보다', 'JKB', '*', 'F', '보다', '*', '*', '*', '*' ],
[ '이별', 'NNG', '*', 'T', '이별', '*', '*', '*', '*' ],
[ '에', 'JKB', '*', 'F', '에', '*', '*', '*', '*' ],
[ '남', 'VV', '*', 'T', '남', '*', '*', '*', '*' ],
[ '아', 'EC', '*', 'F', '아', '*', '*', '*', '*' ],
[ '검색', 'NNG', '*', 'T', '검색', '*', '*', '*', '*' ],
[ '해', 'VV+EC', '*', 'F', '해', 'Inflect', 'VV', 'EC', '하/VV/*+아/EC/*' ],
[ '줘', 'VX+EC', '*', 'F', '줘', 'Inflect', 'VX', 'EC', '주/VX/*+어/EC/*' ] ]
(base) root@rasa-virtual-machine:~/node#
(base) root@rasa-virtual-machine:~/node#
(base) root@rasa-virtual-machine:~/node#
(base) root@rasa-virtual-machine:~/node# node test.js
[ [ '추억', 'NNG', '*', 'T', '추억', '*', '*', '*', '*' ],
[ '은', 'JX', '*', 'T', '은', '*', '*', '*', '*' ],
[ '만남', 'NNG', '*', 'T', '만남', '*', '*', '*', '*' ],
[ '보다', 'JKB', '*', 'F', '보다', '*', '*', '*', '*' ],
[ '이별', 'NNG', '*', 'T', '이별', '*', '*', '*', '*' ],
[ '에', 'JKB', '*', 'F', '에', '*', '*', '*', '*' ],
[ '남', 'VV', '*', 'T', '남', '*', '*', '*', '*' ],
[ '아', 'EC', '*', 'F', '아', '*', '*', '*', '*' ],
[ '검색', 'NNG', '*', 'T', '검색', '*', '*', '*', '*' ],
[ '해', 'VV+EC', '*', 'F', '해', 'Inflect', 'VV', 'EC', '하/VV/*+아/EC/*' ],
[ '줘', 'VX+EC', '*', 'F', '줘', 'Inflect', 'VX', 'EC', '주/VX/*+어/EC/*' ] ]
댓글
댓글 쓰기