├── .githooks
└── pre-commit
├── .github
└── workflows
│ └── test.yml
├── .gitignore
├── .mocharc.json
├── .node-version
├── LICENSE
├── README.md
├── index.html
├── netlify.toml
├── package.json
├── src
├── Deferred.ts
├── index.ts
└── kuromojin.ts
├── test
├── kuromojin-test.ts
└── tsconfig.json
├── tsconfig.json
├── vite.config.mjs
├── web
├── index.css
├── index.ts
└── kuromoji.patch.js
└── yarn.lock
/.githooks/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | npx --no-install lint-staged
3 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: test
2 | on: [push, pull_request]
3 | env:
4 | CI: true
5 | jobs:
6 | test:
7 | name: "Test on Node.js ${{ matrix.node-version }}"
8 | runs-on: ubuntu-latest
9 | strategy:
10 | matrix:
11 | node-version: [ 18, 20 ]
12 | steps:
13 | - name: checkout
14 | uses: actions/checkout@v2
15 | - name: setup Node.js ${{ matrix.node-version }}
16 | uses: actions/setup-node@v1
17 | with:
18 | node-version: ${{ matrix.node-version }}
19 | - name: Install
20 | run: yarn install
21 | - name: Test
22 | run: yarn test
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /dist
2 | /lib
3 | /public/dict
4 | ### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore
5 |
6 | # Logs
7 | logs
8 | *.log
9 |
10 | # Runtime data
11 | pids
12 | *.pid
13 | *.seed
14 |
15 | # Directory for instrumented libs generated by jscoverage/JSCover
16 | lib-cov
17 |
18 | # Coverage directory used by tools like istanbul
19 | coverage
20 |
21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
22 | .grunt
23 |
24 | # node-waf configuration
25 | .lock-wscript
26 |
27 | # Compiled binary addons (http://nodejs.org/api/addons.html)
28 | build/Release
29 |
30 | # Dependency directory
31 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
32 | node_modules
33 |
34 | # Debug log from npm
35 | npm-debug.log
36 |
37 |
38 | ### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Global/JetBrains.gitignore
39 |
40 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
41 |
42 | *.iml
43 |
44 | ## Directory-based project format:
45 | .idea/
46 | # if you remove the above rule, at least ignore the following:
47 |
48 | # User-specific stuff:
49 | # .idea/workspace.xml
50 | # .idea/tasks.xml
51 | # .idea/dictionaries
52 |
53 | # Sensitive or high-churn files:
54 | # .idea/dataSources.ids
55 | # .idea/dataSources.xml
56 | # .idea/sqlDataSources.xml
57 | # .idea/dynamic.xml
58 | # .idea/uiDesigner.xml
59 |
60 | # Gradle:
61 | # .idea/gradle.xml
62 | # .idea/libraries
63 |
64 | # Mongo Explorer plugin:
65 | # .idea/mongoSettings.xml
66 |
67 | ## File-based project format:
68 | *.ipr
69 | *.iws
70 |
71 | ## Plugin-specific files:
72 |
73 | # IntelliJ
74 | out/
75 |
76 | # mpeltonen/sbt-idea plugin
77 | .idea_modules/
78 |
79 | # JIRA plugin
80 | atlassian-ide-plugin.xml
81 |
82 | # Crashlytics plugin (for Android Studio and IntelliJ)
83 | com_crashlytics_export_strings.xml
84 | crashlytics.properties
85 | crashlytics-build.properties
86 |
87 | # Local Netlify folder
88 | .netlify
89 |
90 | /public/dict/
91 |
--------------------------------------------------------------------------------
/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": [
3 | "ts-node-test-register"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/.node-version:
--------------------------------------------------------------------------------
1 | v18.19.0
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 azu
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # kuromojin [](https://github.com/azu/kuromojin/actions?query=workflow%3A"test")
2 |
3 | Provide a high level wrapper for [kuromoji.js](https://github.com/takuyaa/kuromoji.js "kuromoji.js").
4 |
5 | ## Features
6 |
7 | - Promise based API
8 | - Cache Layer
9 | - Fetch the dictionary at once
10 | - Return same tokens for same text
11 |
12 | ## Installation
13 |
14 | npm install kuromojin
15 |
16 | ## Online Playground
17 |
18 | 📝 Require [DecompressionStream](https://developer.mozilla.org/ja/docs/Web/API/DecompressionStream) supported browser
19 |
20 | -
is in a , reset it's formatting to blend in */
327 | background: inherit;
328 | font-size: inherit;
329 | color: inherit;
330 | border: 0;
331 | padding: 0;
332 | margin: 0;
333 | }
334 |
335 | code pre {
336 | /* When is in a , reset it's formatting to blend in */
337 | display: inline;
338 | background: inherit;
339 | font-size: inherit;
340 | color: inherit;
341 | border: 0;
342 | padding: 0;
343 | margin: 0;
344 | }
345 |
346 | details {
347 | /* Make the look more "clickable" */
348 | padding: 0.6rem 1rem;
349 | background: var(--nc-bg-2);
350 | border: 1px solid var(--nc-bg-3);
351 | border-radius: 4px;
352 | }
353 |
354 | summary {
355 | /* Makes the look more like a "clickable" link with the pointer cursor */
356 | cursor: pointer;
357 | font-weight: bold;
358 | }
359 |
360 | details[open] {
361 | /* Adjust the padding while open */
362 | padding-bottom: 0.75rem;
363 | }
364 |
365 | details[open] summary {
366 | /* Adjust the padding while open */
367 | margin-bottom: 6px;
368 | }
369 |
370 | details[open] > *:last-child {
371 | /* Resets the bottom margin of the last element in the while is opened. This prevents double margins/paddings. */
372 | margin-bottom: 0;
373 | }
374 |
375 | dt {
376 | font-weight: bold;
377 | }
378 |
379 | dd::before {
380 | /* Add an arrow to data table definitions */
381 | content: "→ ";
382 | }
383 |
384 | hr {
385 | /* Reset the border of the
separator, then set a better line */
386 | border: 0;
387 | border-bottom: 1px solid var(--nc-bg-3);
388 | margin: 1rem auto;
389 | }
390 |
391 | fieldset {
392 | margin-top: 1rem;
393 | padding: 2rem;
394 | border: 1px solid var(--nc-bg-3);
395 | border-radius: 4px;
396 | }
397 |
398 | legend {
399 | padding: auto 0.5rem;
400 | }
401 |
402 | table {
403 | /* border-collapse sets the table's elements to share borders, rather than floating as separate "boxes". */
404 | border-collapse: collapse;
405 | width: 100%;
406 | }
407 |
408 | td,
409 | th {
410 | border: 1px solid var(--nc-bg-3);
411 | text-align: left;
412 | padding: 0.5rem;
413 | }
414 |
415 | th {
416 | background: var(--nc-bg-2);
417 | }
418 |
419 | tr:nth-child(even) {
420 | /* Set every other cell slightly darker. Improves readability. */
421 | background: var(--nc-bg-2);
422 | }
423 |
424 | table caption {
425 | font-weight: bold;
426 | margin-bottom: 0.5rem;
427 | }
428 |
429 | textarea {
430 | /* Don't let the