hexenq / kuroshiro

Japanese language library for converting Japanese sentence to Hiragana, Katakana or Romaji with furigana and okurigana modes supported.
https://kuroshiro.org
MIT License
837 stars 94 forks source link

Kuroshiro is not a constructor #85

Closed jwalk00 closed 3 years ago

jwalk00 commented 3 years ago

I cannot for the life of me get this to work. The best result I can achieve is "Kuroshiro is not a constructor".

I have added the two min js files to my project folder, and enqueue them:

<script src="js/kuroshiro.min.js"></script>
<script src="js/kuroshiro-analyzer-kuromoji.min.js"></script>

Then added my own script: <script type="module" src="js/ks.js"></script>

which contains:

var kuroshiro = new Kuroshiro();
await kuroshiro.init(new KuromojiAnalyzer());
var result = await kuroshiro.convert("感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!", {mode:"furigana", to:"hiragana"});
console.log(result);

Then I get: Uncaught TypeError: Kuroshiro is not a constructor at ks.js:2

Does Kuroshiro require the use of webpack/gulp or a Javascript frame work like React/Vue? I'm trying to do it with just base html/css/js files and I don't know if that's just plain wrong...

phamhuuan commented 3 years ago

@jwalk00 try this https://github.com/hexenq/kuroshiro/issues/66#issuecomment-942162775

jwalk00 commented 3 years ago

Fixed this by downgrading to v1.1.2 and using those dist files.

Then applying this fix when I got Analyzer errors: https://github.com/hexenq/kuroshiro/issues/27#issuecomment-686428617

chinenvinicius commented 2 years ago

isnt the v1.1.2 the latest version? @jwalk00

jwalk00 commented 2 years ago

isnt the v1.1.2 the latest version? @jwalk00

1.2.0 is the latest release https://github.com/hexenq/kuroshiro/releases/tag/1.2.0

CQzhangjiawang commented 1 year ago

so, how do you fiexed the problem.

I used the latest 1.2.0 release to npm install, npm run build, and the code is same as to you. but the error alwasy exists.

I need help.

Please help me! @jwalk00

jwalk00 commented 1 year ago

"Fixed this by downgrading to v1.1.2 and using those dist files."

Use v1.1.2