Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@gyugyu/kuromoji
Advanced tools
JavaScript implementation of Japanese morphological analyzer. This is a pure JavaScript porting of Kuromoji.
You can see how kuromoji.js works in demo site.
Directory tree is as follows:
build/
kuromoji.js -- JavaScript file for browser (Browserified)
demo/ -- Demo
dict/ -- Dictionaries for tokenizer (gzipped)
example/ -- Examples to use in Node.js
src/ -- JavaScript source
test/ -- Unit test
You can tokenize sentences with only 5 lines of code. If you need working examples, you can see the files under the demo or example directory.
Install with npm package manager:
npm install kuromoji
Load this library as follows:
var kuromoji = require("kuromoji");
You can prepare tokenizer like this:
kuromoji.builder({ dicPath: "path/to/dictionary/dir/" }).build(function (err, tokenizer) {
// tokenizer is ready
var path = tokenizer.tokenize("すもももももももものうち");
console.log(path);
});
You only need the build/kuromoji.js and dict/*.dat.gz files
Install with Bower package manager:
bower install kuromoji
Or you can use the kuromoji.js file and dictionary files from the GitHub repository.
In your HTML:
<script src="url/to/kuromoji.js"></script>
In your JavaScript:
kuromoji.builder({ dicPath: "/url/to/dictionary/dir/" }).build(function (err, tokenizer) {
// tokenizer is ready
var path = tokenizer.tokenize("すもももももももものうち");
console.log(path);
});
The function tokenize() returns an JSON array like this:
[ {
word_id: 509800, // 辞書内での単語ID
word_type: 'KNOWN', // 単語タイプ(辞書に登録されている単語ならKNOWN, 未知語ならUNKNOWN)
word_position: 1, // 単語の開始位置
surface_form: '黒文字', // 表層形
pos: '名詞', // 品詞
pos_detail_1: '一般', // 品詞細分類1
pos_detail_2: '*', // 品詞細分類2
pos_detail_3: '*', // 品詞細分類3
conjugated_type: '*', // 活用型
conjugated_form: '*', // 活用形
basic_form: '黒文字', // 基本形
reading: 'クロモジ', // 読み
pronunciation: 'クロモジ' // 発音
} ]
(This is defined in src/util/IpadicFormatter.js)
See also JSDoc page in details.
FAQs
JavaScript implementation of Japanese morphological analyzer
We found that @gyugyu/kuromoji demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.