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
804 stars 92 forks source link

React Native init fails #17

Open baijunjie opened 6 years ago

baijunjie commented 6 years ago
import kuroshiro from 'kuroshiro';
kuroshiro.init(function (err) {
    console.log(err);
    //console.log(kuroshiro.convert('感じ取れたら手を繋ごう', { to: 'hiragana' }));
});

6c8056ef-42ea-419a-a818-5151f44a1058

Maybe I need to import the dictionary manually. What should I do?

hexenq commented 6 years ago

I'm not familiar with React Native. Maybe you put the dictionary files in a wrong default folder. Try specifying the dict path by setting dicPath option when initiating kuroshiro.

alexwasner commented 6 years ago

Has anyone found a solution for this?

mornir commented 6 years ago

I have a similar error with Vue. Has anybody figured it out? I think that the problem is related to Webpack. @hexenq I think that you should change the default dicPath. Developers are moving away from Bower and now use npm on the front-end. Also I don't understand why you added dist/dict in the npmignore file.

mornir commented 6 years ago

I solved it by having a look at what the output of the module bundler was and by making sure that the file path to the dictionary was correct.

zi6xuan commented 6 years ago

@mornir How to fix it

mornir commented 6 years ago

@zi6xuan I've updated the readme (see section about module bundlers). Basically, you need to set the dicPath to a folder that is not processed by your module bundler.

zi6xuan commented 6 years ago

simulator screen shot - iphone 6 - 2018-04-23 at 21 53 09 @mornir Can you help me find out what the problem is? I use kuroshiro as the react-native ios

mornir commented 6 years ago

@zi6xuan Sorry, I'm not familiar with React Native. But this definitely looks like a problem with your bundle output.

zi6xuan commented 6 years ago

Thanks for your reply, I thought you are also a reactinative developer

hexenq commented 6 years ago

I'm working on the next major version of kuroshiro that will use rollup to bundle up the main module of kuroshiro, which may get this issue solved.

hexenq commented 6 years ago

Hello everyone. The new major version of kuroshiro has been released. And the latest version is 1.1.0 which supports multiple morphological analyzers and different romanization systems. Give it a try. 😉

shilik commented 5 years ago

@mornir Hi, I noticed that you said it worked with Vue, Have you ever tried it with nativescript-vue? I have got a similar errors while using it with nativescript-vue. It seems kuroshiro is not working well with webpack. Any suggestions?

shilik

mornir commented 5 years ago

@shilik Sorry, I didn't try using it with nativescript-vue. Yes, you need a special Weback pack loader to process the dictionaries files. But I wasn't able to properly configure Webpack. So I just imported the dictionaries directly, without going through Webpack.