fasiha / curtiz-japanese-nlp

Use Japanese NLP tools to annotate Curtiz (version 2) Markdown files
The Unlicense
11 stars 2 forks source link

Issues with instalation #8

Open tulerpetontidae opened 1 year ago

tulerpetontidae commented 1 year ago

I've tried to install your package with npm i https://github.com/fasiha/curtiz-japanese-nlp. However, after importing there're some issues. One example of the errors is:

node:internal/modules/cjs/loader:1039
  const err = new Error(message);
              ^

Error: Cannot find module './annotate'
Require stack:
- /Users/b450-admin/PycharmProjects/transcript/node-server/node_modules/curtiz-japanese-nlp/annotateServer.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/b450-admin/PycharmProjects/transcript/node-server/node_modules/curtiz-japanese-nlp/annotateServer.js:18:20)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/b450-admin/PycharmProjects/transcript/node-server/node_modules/curtiz-japanese-nlp/annotateServer.js'
  ]
}

Node.js v18.13.0

What I noticed is that none of the .js files are located in the package, only .ts. Is this the expected behaviour? Could you help me with configuring it?

fasiha commented 1 year ago

I'm so so so sorry for forgetting about this, please forgive me! I've fixed this so the instructions in the README will work! I'll repeat them here just to make sure I don't mess them up:

mkdir curtiz-demo
cd curtiz-demo
# download JmdictFurigana.json (see README for links)
# download and unzip jmdict-eng-3.5.0.json
# download kanjidic2.xml.gz
npm init -y
npm i https://github.com/fasiha/curtiz-japanese-nlp
PORT=8888 JMDICT_SIMPLIFIED_JSON=./jmdict-eng-3.5.0.json npx curtiz-annotate-server

This will print out several lines like

Annotation app listening at http://127.0.0.1:8888, NATIVE mecab=true
3378 entries written
7264 entries written
11120 entries written
...

and then the server will be ready! In another console you can run

curl --data '{"sentence": "へましたらリーダーに切られるだけ"}' \
  -X POST \
  -H "Content-Type: application/json" \
  -o curtiz.json \
  http://127.0.0.1:8888/api/v1/sentence

and this will save the output of the REST API in curtiz.json which you can look at. It'll have details on dictionary hits, conjugations and deconjugations of verbs/adjectives, particles, JDepP bunsetsu dependency trees, kanji entries and breakdowns from Wanikani, etc. 😁

EDIT This assumes you have installed (1) MeCab, (2) Mecab-UniDic, and (3) JDepP on your device! These are big C++ programs so they might be hard to install, let me know.

I'm very happy you're interested in this package, I really like it but I know it's quite hard to use and the documentation is very spotty and it's untested. I am most happy to help answer questions and build docs if you'd like. Right now I'm using this as part of my app quite intensively so it may change, but hopefully only for the better.