Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong result when convert to furigana #60

Closed
cj1128 opened this issue Jan 26, 2019 · 6 comments
Closed

wrong result when convert to furigana #60

cj1128 opened this issue Jan 26, 2019 · 6 comments
Assignees
Labels

Comments

@cj1128
Copy link

cj1128 commented Jan 26, 2019

I am trying to convert 渡り鳥 using code bellow:

const Kuroshiro = require("kuroshiro")
const a = require("kuroshiro-analyzer-kuromoji")
const kuroshiro = new Kuroshiro()
;(async () => {
  await kuroshiro.init(new a())
  const str = "渡り鳥"
  const res = await kuroshiro.convert(str, {mode:"furigana", to:"hiragana"});
  console.log(res)
})()

And get the result

<ruby>渡<rp>(</rp><rt>わたりど</rt><rp>)</rp></ruby>り<ruby>鳥<rp>(</rp><rt></rt><rp>)</rp></ruby>

which is wrong, the correct result should be

<ruby>渡<rp>(</rp><rt>わた</rt><rp>)</rp></ruby>り<ruby>鳥<rp>(</rp><rt>どり</rt><rp>)</rp></ruby>

BTW, the async api is a real pain, we should make it sync, at least when used with kuromoji analyzer.

@hexenq hexenq added the bug label Mar 3, 2019
@hexenq hexenq self-assigned this Mar 3, 2019
@halfsprit
Copy link

异步模式太糟糕,至少初始化时应该是同步模式,初始化是耗时的步骤,不应该每次计算时又初始化一次。

@cj1128
Copy link
Author

cj1128 commented Mar 11, 2019

@halfsprit 这个库接口设计为异步是有原因的,因为部分 analyzer 是异步的。当然,这个设计不太好,因为存在异步 analyzer,导致所有接口都异步了 = = 初始化并不存在什么问题吧,因为可以只初始化一次的。

@halfsprit
Copy link

analyzer 里面似乎也只有readFile是异步的,但是readFile好像也有同步版本,是不是使用readFile的同步版本就能解决这个问题呢?

@cj1128
Copy link
Author

cj1128 commented Mar 11, 2019

@halfspritreadFile 关系不大,有部分 analyzer 是基于 web api 的,必须异步,比如 kuroshiro-analyzer-yahoo-webapi

@halfsprit
Copy link

利用kuroshiro的库,编写了一个小工具,除了初始化要点时间外,后面就是即时进行转换。
链接:https://pan.baidu.com/s/1VMZQlCvR3jCq-0JSC04R7A
提取码:rvga
sshot-1

@KristerV
Copy link

as a non-japanese speaker i'd love to know what the verdict is (is the hiragana accurate or not) :)

@hexenq hexenq mentioned this issue Jun 7, 2021
@hexenq hexenq closed this as completed in aaa61f9 Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants