kuroshiro.js

kuroshiro.js 是一个用于处理日文文字转换的 JavaScript 库。

它提供了一些功能,比如将日文文字转换为假名(平假名和片假名)、将假名转换为罗马字母等。这个库可以帮助开发者在处理日文文字时实现简单的转换和处理操作。

项目原始地址:https://github.com/hexenq/kuroshiro

直接可用的 release 文件:https://github.com/cencuansen/kuroshiro

使用示例:furigana 模式(注音假名、振假名)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>日文假名标注工具</title>
    <script src="kuroshiro.js"></script>
    <script src="kuroshiro-analyzer-kuromoji.js"></script>
</head>
<body>
<div id="res"></div>

<script>
    const res = document.getElementById('res');
    const kuroshiro = new Kuroshiro();

    kuroshiro.init(new KuromojiAnalyzer()).then((result) => {
        kuroshiro.convert("教室に学生がいる", {
            mode: 'furigana',
            to: "hiragana"
        }).then((result) => {
            res.innerHTML = result;
        })
    })
</script>
</body>
</html>
注音假名使用效果
注音假名效果

注音假名生成结果有问题,解决:https://github.com/hexenq/kuroshiro/commit/aaa61f9da8e1cf25b4ee658fcc72b05e7765d3a5

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值