{"id":17801795,"url":"https://github.com/xissy/node-mecab-ffi","last_synced_at":"2025-03-17T11:30:51.225Z","repository":{"id":9101099,"uuid":"10880560","full_name":"xissy/node-mecab-ffi","owner":"xissy","description":"A node.js module for binding MeCab asynchronously using foreign function interface.","archived":false,"fork":false,"pushed_at":"2016-04-07T21:40:27.000Z","size":19,"stargazers_count":45,"open_issues_count":1,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T23:09:55.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xissy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-23T08:18:37.000Z","updated_at":"2024-07-09T18:33:12.000Z","dependencies_parsed_at":"2022-08-27T22:00:57.646Z","dependency_job_id":null,"html_url":"https://github.com/xissy/node-mecab-ffi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xissy%2Fnode-mecab-ffi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xissy%2Fnode-mecab-ffi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xissy%2Fnode-mecab-ffi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xissy%2Fnode-mecab-ffi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xissy","download_url":"https://codeload.github.com/xissy/node-mecab-ffi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858573,"owners_count":20359375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-27T12:39:40.005Z","updated_at":"2025-03-17T11:30:50.888Z","avatar_url":"https://github.com/xissy.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-mecab-ffi\n\nA node.js module for binding MeCab asynchronously using foreign function interface.\nThis module supports MacOS(surely Unix/Linux) and multi-thread safety.\n\nIf you want to use this module for Korean, please read the Korean [README](./README_ko.md)\n\n## Installation\n\nnode-mecab-ffi depends on [MeCab](http://mecab.googlecode.com/svn/trunk/mecab/doc/index.html) v0.996 or higher.\n\nWarning: \nTo use libmecab in MacOS, you must install the newest gcc, automake and autoconf first and compile MeCab and dictonary with it. \nRefer to [here](http://www.ficksworkshop.com/blog/14-coding/65-installing-gcc-on-mac). Otherwise it could split errors which cannot find dictionary directory or showing abort trap when you try to parse input strings.\n\nVia [npm](https://npmjs.org):\n```\n$ npm install mecab-ffi\n```  \n\nVia git directly:\n```\n$ npm install git+https://github.com/xissy/node-mecab-ffi.git\n```\n\n## Quick Start\n\n### Load in the module\n\n```\nvar mecab = require('mecab-ffi');\n```\n\n### Parse a string\n\n#### Asynchronously\n\n```javascript\n//Korean Example\nmecab.parse('한글 형태소 분석기를 테스트', function(err, result) {\n  console.log (result);\n});\n\n//Result\n[ [ '한글', 'NNG', '*', 'T', '한글', '*', '*', '*', '*', '*' ],\n[ '형태소',\n  'NNG',\n  '*',\n  'F',\n  '형태소',\n  'Compound',\n  '*',\n  '*',\n  '형태+소',\n  '형태/NNG/*/1/1+형태소/Compound/*/0/2+소/NNG/*/1/1' ],\n[ '분석기',\n  'NNG',\n  '*',\n  'F',\n  '분석기',\n  'Compound',\n  '*',\n  '*',\n  '분석+기',\n  '분석/NNG/*/1/1+분석기/Compound/*/0/2+기/NNG/*/1/1' ],\n[ '를', 'JKO', '*', 'T', '를', '*', '*', '*', '*', '*' ],\n[ '테스트', 'NNG', '*', 'F', '테스트', '*', '*', '*', '*', '*' ] ]\n\n//Japaness Example\nmecab.parse('ホリエモン市', function(err, result) {\n  console.log (result);\n});\n\n//Result\n[ [ 'ホリエモン', 'SL', '*', '*', '*', '*', '*', '*', '*', '*' ],\n  [ '市', 'NNG', '*', 'F', '시', '*', '*', '*', '*', '*' ] ]\n\n```\n\n#### Synchronously\n```javascript\nresult = mecab.parseSync('한글 형태소 분석기를 테스트');\nconsole.log (result);\n\n//Result\n\n[ [ '한글', 'NNG', '*', 'T', '한글', '*', '*', '*', '*', '*' ],\n  [ '형태소',\n\t'NNG',\n\t'*',\n\t'F',\n\t'형태소',\n\t'Compound',\n\t'*',\n\t'*',\n\t'형태+소',\n\t'형태/NNG/*/1/1+형태소/Compound/*/0/2+소/NNG/*/1/1' ],\n  [ '분석기',\n\t'NNG',\n\t'*',\n\t'F',\n\t'분석기',\n\t'Compound',\n\t'*',\n\t'*',\n\t'분석+기',\n\t'분석/NNG/*/1/1+분석기/Compound/*/0/2+기/NNG/*/1/1' ],\n  [ '를', 'JKO', '*', 'T', '를', '*', '*', '*', '*', '*' ],\n  [ '테스트', 'NNG', '*', 'F', '테스트', '*', '*', '*', '*', '*' ] ]\n\n```\n\n### Extract nouns\n\n#### Noun list\n```javascript\nmecab.extractNounMap('한글 형태소 분석기를 테스트', function(err, result) {\n\tconsole.log (result);\n})\n\n//Result\n{ '한글': 1, '한글 형태소': 1, '형태소': 1, '형태소 분석기': 1, '분석기': 1, '테스트': 1 }\n```\n\n#### Noun Map\n```javascript\nvar string = \"황사바람 부는 거리에서 전경들이 점심을 먹는다.\";\nmecab.extractNounMap(string, function(err, result) {\n\tconsole.log (result);\n})\n\n//Result\n{ '황사': 1,\n  '황사 바람': 1,\n  '바람': 1,\n  '바람 부': 1,\n  '부': 1,\n  '거리': 1,\n  '전경': 1,\n  '점심': 1 }\n\n```\n\n#### Noun list sorted by count\n```javascript\nvar string = \"황사바람 부는 거리에서 전경들이 점심을 먹는다.\";\nmecab.extractSortedNounCounts(string, function(err, result) {\n\tconsole.log (result);\n});\n\n//Result\n[ { noun: '황사', count: 1 },\n  { noun: '황사 바람', count: 1 },\n  { noun: '바람', count: 1 },\n  { noun: '바람 부', count: 1 },\n  { noun: '부', count: 1 },\n  { noun: '거리', count: 1 },\n  { noun: '전경', count: 1 },\n  { noun: '점심', count: 1 } ]\n```\n\n### Get Dice-Coefficient\n\n#### by two strings\n```javascript\nvar string1 = \"황사바람 부는 거리에서 전경들이 점심을 먹는다.\";\nvar string2 = \"강풍이 불고 거리에서 전경이 밥을 먹는다.\";\nmecab.getDiceCoefficientByString(string1, string2, function(err, result) {\n\tconsole.log (result);\n});\n\n//Result \n2\n```\n\n#### by two noun maps\nYou muse use three Async functions to make two maps and to compare. Without questions, you can use callback as below:\n```javascript\nvar string1 = \"황사바람 부는 거리에서 전경들이 점심을 먹는다.\",\n    string2 = \"강풍이 불고 거리에서 전경이 밥을 먹는다.\",\n    shareData = {};\n\nmecab.extractNounMap(string1, function (err, mapA) {\n    shareData[\"mapA\"] = mapA;\n    mecab.extractNounMap(string2, function (err, mapB) {\n        shareData[\"mapB\"] = mapB;\n        mecab.getDiceCoefficientByNounMap(shareData.mapA, shareData.mapB, function(err, result) {\n            console.log (result);\n\t   });\n    }); \n});\n\n//Result\n2\n\n```\nYou, however, can use Promise patter, new ara of javascript with ES6 or promise library like bluebird. \nWith bluebird, the code is easier to read and understand. \n```javascript\nvar mecab = require('mecab-ffi'),\n  Promise = require('bluebird'),\n  join = Promise.join;\n\nvar fAsyncExtractNounMap = Promise.promisify(mecab.extractNounMap),\n    fAsyncgetDiceCoefficientByNounMap = Promise.promisify(mecab.getDiceCoefficientByNounMap),\n    string1 = \"황사바람 부는 거리에서 전경들이 점심을 먹는다.\",\n    string2 = \"강풍이 불고 거리에서 전경이 밥을 먹는다.\";\n\nvar fMap1 = fAsyncExtractNounMap(string1),\n    fMap2 = fAsyncExtractNounMap(string2);\n\njoin (fMap1, fMap2, function (map1, map2) {\n    return fAsyncgetDiceCoefficientByNounMap (map1, map2);\n}).then(function (result) {\n    console.log (result)\n})\n\n//Result\n2\n```\n\n\n## License\n\nReleased under the MIT License\n\nCopyright (c) 2013 Taeho Kim \u003cxissysnd@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/xissy/node-mecab-ffi/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxissy%2Fnode-mecab-ffi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxissy%2Fnode-mecab-ffi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxissy%2Fnode-mecab-ffi/lists"}