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

docs: update docs #39

Merged
merged 1 commit into from
Aug 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<a name="1.0.0-rc.2"></a>
## [1.0.0-rc.2](https://github.com/hexenq/kuroshiro/compare/1.0.0-rc.1...1.0.0-rc.2) (2018-08-05)

### Miscellaneous

* Update docs

<a name="1.0.0-rc.1"></a>
## [1.0.0-rc.1](https://github.com/hexenq/kuroshiro/compare/0.2.4...1.0.0-rc.1) (2018-07-26)

Expand Down
25 changes: 18 additions & 7 deletions README.jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kuroshiroは日本語文をローマ字や仮名なとに変換できるライ
|Yahoo Web API|✓|✓|[kuroshiro-analyzer-yahoo-webapi](https://github.com/hexenq/kuroshiro-analyzer-yahoo-webapi)|[Hexen Qi](https://github.com/hexenq)|

## 使い方
### Node.js
### Node.js (又はWebpackなどのモジュールバンドラを使ってる時)
npmでインストール:
```sh
$ npm install kuroshiro
Expand All @@ -38,17 +38,23 @@ kuroshiroをロードします:

*ES6 Module `import` と CommonJS `require`、どちらでもOK*
```js
import * as Kuroshiro from "kuroshiro";
import Kuroshiro from "kuroshiro";
```

インスタンス化します:
```js
const kuroshiro = new Kuroshiro();
```

形態素解析器のインスタンスを引数にしてkuroshiroを初期化する:
形態素解析器のインスタンスを引数にしてkuroshiroを初期化する ([API説明](#init(analyzer))を参考にしてください):
```js
// 这里使用了async/await, 你同样也可以使用Promise
// この例では,まずnpm installとimportを通じてkuromojiの形態素解析器を導入します
import KuromojiAnalyzer from "kuroshiro-analyzer-kuromoji";

// ...

// 初期化
// ここでasync/awaitを使ってますが, Promiseも使えます
await kuroshiro.init(new KuromojiAnalyzer());
```

Expand All @@ -58,19 +64,24 @@ const result = await kuroshiro.convert("感じ取れたら手を繋ごう、重
```

### ブラウザ
`dist/kuroshiro.min.js`を導入し、そしてHTMLに:
`dist/kuroshiro.min.js`を導入し (その前に`npm install`と`npm run build`を通じて`kuroshiro.min.js`を生成します)、そしてHTMLに:
```html
<script src="url/to/kuroshiro.min.js"></script>
```

この例では`kuroshiro-analyzer-kuromoji.min.js`の導入は必要です。詳しくは[kuroshiro-analyzer-kuromoji](https://github.com/hexenq/kuroshiro-analyzer-kuromoji)を参考にしてください
```html
<script src="url/to/kuroshiro-analyzer-kuromoji.min.js"></script>
```

インスタンス化します:
```js
var kuroshiro = new Kuroshiro();
```

形態素解析器のインスタンスを引数にしてkuroshiroを初期化するから,変換を実行します:
```js
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "/dict" }))
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "url/to/dictFiles" }))
.then(function () {
return kuroshiro.convert("感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!", { to: "hiragana" });
})
Expand All @@ -89,7 +100,7 @@ const kuroshiro = new Kuroshiro();

### インスタンス関数
#### init(analyzer)
形態素解析器のインスタンスを引数にしてkuroshiroを初期化する。前述の[形態素解析器プラグイン](#形態素解析器プラグイン)を利用できます。形態素解析器の初期化方法は各自のドキュメントを参照してください。
形態素解析器のインスタンスを引数にしてkuroshiroを初期化する。先に形態素解析器の導入と初期化は必要です。前述の[形態素解析器プラグイン](#形態素解析器プラグイン)を利用できます。形態素解析器の初期化方法は各自のドキュメントを参照してください。

__引数__

Expand Down
50 changes: 18 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You can check the demo [here](http://hexenq.com/kuroshiro/demo/index.html).
|Yahoo Web API|✓|✓|[kuroshiro-analyzer-yahoo-webapi](https://github.com/hexenq/kuroshiro-analyzer-yahoo-webapi)|[Hexen Qi](https://github.com/hexenq)|

## Usage
### Node.js
### Node.js (or using a module bundler (e.g. Webpack))
Install with npm package manager:
```sh
$ npm install kuroshiro
Expand All @@ -38,16 +38,22 @@ Load the library:

*Support both ES6 Module `import` and CommonJS `require`*
```js
import * as Kuroshiro from "kuroshiro";
import Kuroshiro from "kuroshiro";
```

Instantiate:
```js
const kuroshiro = new Kuroshiro();
```

Initiate kuroshiro with an instance of analyzer:
Initialize kuroshiro with an instance of analyzer (You could check the [apidoc](#init(analyzer)) for more information):
```js
// For this example, you should npm install and import the kuromoji analyzer first
import KuromojiAnalyzer from "kuroshiro-analyzer-kuromoji";

// ...

// Initialize
// Here uses async/await, you could also use Promise
await kuroshiro.init(new KuromojiAnalyzer());
```
Expand All @@ -58,19 +64,24 @@ const result = await kuroshiro.convert("感じ取れたら手を繋ごう、重
```

### Browser
Add `kuroshiro.min.js` in `dist` to your frontend project, and in your HTML:
Add `dist/kuroshiro.min.js` to your frontend project (you may first build it from source with `npm run build` after `npm install`), and in your HTML:
```html
<script src="url/to/kuroshiro.min.js"></script>
```

For this example, you should also include `kuroshiro-analyzer-kuromoji.min.js` which you could get from [kuroshiro-analyzer-kuromoji](https://github.com/hexenq/kuroshiro-analyzer-kuromoji)
```html
<script src="url/to/kuroshiro-analyzer-kuromoji.min.js"></script>
```

Instantiate:
```js
var kuroshiro = new Kuroshiro();
```

Initiate kuroshiro with an instance of analyzer, then convert what you want:
Initialize kuroshiro with an instance of analyzer, then convert what you want:
```js
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "/dict" }))
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "url/to/dictFiles" }))
.then(function () {
return kuroshiro.convert("感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!", { to: "hiragana" });
})
Expand All @@ -79,31 +90,6 @@ kuroshiro.init(new KuromojiAnalyzer({ dictPath: "/dict" }))
})
```

### Using a module bundler (e.g. Webpack)
Install with npm package manager:
```sh
$ npm install kuroshiro
```

Look for the dictionaries (12 files) in `node_modules/kuromoji/dict` and move them to a folder that is not processed by Webpack.
```js
import kuroshiro from 'kuroshiro'

kuroshiro.init(
{
dicPath: 'path/to/folder/not/processed/by/Wepback'
},
(err) => {
if(err){
console.error(err);
} else {
// kuroshiro is ready
const result = kuroshiro.convert('感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!');
console.log(result);
}
});
```

## API
### Constructor
__Examples__
Expand All @@ -114,7 +100,7 @@ const kuroshiro = new Kuroshiro();

### Instance Medthods
#### init(analyzer)
Initiate kuroshiro with an instance of analyzer. You can make use of the [Ready-made Analyzers](#ready-made-analyzer-plugins) listed above. And please refer to documentation of analyzers for analyzer initialization instructions
Initialize kuroshiro with an instance of analyzer. You should first import an analyzer and initialize it. You can make use of the [Ready-made Analyzers](#ready-made-analyzer-plugins) listed above. And please refer to documentation of analyzers for analyzer initialization instructions

__Arguments__

Expand Down
23 changes: 17 additions & 6 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kuroshiro是一款十分方便使用的日文转换注音工具,主要针对
|Yahoo Web API|✓|✓|[kuroshiro-analyzer-yahoo-webapi](https://github.com/hexenq/kuroshiro-analyzer-yahoo-webapi)|[Hexen Qi](https://github.com/hexenq)|

## 如何使用
### Node.js
### Node.js (或使用Webpack等打包工具时)
首先使用npm包管理器进行安装:
```sh
$ npm install kuroshiro
Expand All @@ -39,16 +39,22 @@ $ npm install kuroshiro

*同时支持ES6 Module `import` 和 CommonJS `require`*
```js
import * as Kuroshiro from "kuroshiro";
import Kuroshiro from "kuroshiro";
```

实例化:
```js
const kuroshiro = new Kuroshiro();
```

使用一个解析器实例来初始化kuroshiro:
使用一个解析器实例来初始化kuroshiro (请参考[API说明](#init(analyzer))):
```js
// 在这个示例中,首先npm install并import导入kuromoji解析器
import KuromojiAnalyzer from "kuroshiro-analyzer-kuromoji";

// ...

// 初始化
// 这里使用了async/await, 你同样也可以使用Promise
await kuroshiro.init(new KuromojiAnalyzer());
```
Expand All @@ -59,19 +65,24 @@ const result = await kuroshiro.convert("感じ取れたら手を繋ごう、重
```

### 浏览器
将`dist`中的`kuroshiro.min.js`加入到你的工程,并在HTML中加入:
将`dist/kuroshiro.min.js`加入到你的工程 (你需要先后执行`npm install`和`npm run build`,以把它构建出来),并在HTML中加入:
```html
<script src="url/to/kuroshiro.min.js"></script>
```

在这个示例中, 你还需要引入`kuroshiro-analyzer-kuromoji.min.js`。具体获取方法请参考[kuroshiro-analyzer-kuromoji](https://github.com/hexenq/kuroshiro-analyzer-kuromoji)
```html
<script src="url/to/kuroshiro-analyzer-kuromoji.min.js"></script>
```

实例化:
```js
var kuroshiro = new Kuroshiro();
```

使用一个解析器实例来初始化kuroshiro,然后进行转换操作:
```js
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "/dict" }))
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "url/to/dictFiles" }))
.then(function () {
return kuroshiro.convert("感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!", { to: "hiragana" });
})
Expand All @@ -90,7 +101,7 @@ const kuroshiro = new Kuroshiro();

### 实例方法
#### init(analyzer)
使用一个解析器实例来初始化kuroshiro。你可以使用上面提到的已实现的[解析器插件](#解析器插件)。关于解析器的初始化方法请参照相应解析器的文档说明。
使用一个解析器实例来初始化kuroshiro。你需要首先导入并初始化一个解析器。你可以使用上面提到的已实现的[解析器插件](#解析器插件)。关于解析器的初始化方法请参照相应解析器的文档说明。

__参数__

Expand Down
23 changes: 17 additions & 6 deletions README.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kuroshiro是一款十分方便使用的日文轉換注音工具,主要針對
|Yahoo Web API|✓|✓|[kuroshiro-analyzer-yahoo-webapi](https://github.com/hexenq/kuroshiro-analyzer-yahoo-webapi)|[Hexen Qi](https://github.com/hexenq)|

## 如何使用
### Node.js
### Node.js (或使用Webpack等打包工具時)
首先使用npm包管理器進行安裝:
```sh
$ npm install kuroshiro
Expand All @@ -39,16 +39,22 @@ $ npm install kuroshiro

*同時支持ES6 Module `import` 和 CommonJS `require`*
```js
import * as Kuroshiro from "kuroshiro";
import Kuroshiro from "kuroshiro";
```

實例化:
```js
const kuroshiro = new Kuroshiro();
```

使用一個解析器實例來初始化kuroshiro:
使用一個解析器實例來初始化kuroshiro (請參考[API說明](#init(analyzer))):
```js
// 在這個示例中,首先npm install並import導入kuromoji解析器
import KuromojiAnalyzer from "kuroshiro-analyzer-kuromoji";

// ...

// 初始化
// 這裡使用了async/await, 你同樣也可以使用Promise
await kuroshiro.init(new KuromojiAnalyzer());
```
Expand All @@ -59,19 +65,24 @@ const result = await kuroshiro.convert("感じ取れたら手を繋ごう、重
```

### 瀏覽器
將`dist`中的`kuroshiro.min.js`加入到你的工程,並在HTML中加入:
將`dist`中的`kuroshiro.min.js`加入到你的工程 (你需要先後執行`npm install`和`npm run build`,以把它構建出來),並在HTML中加入:
```html
<script src="url/to/kuroshiro.min.js"></script>
```

在這個示例中, 你還需要引入`kuroshiro-analyzer-kuromoji.min.js`。具體獲取方法請參考[kuroshiro-analyzer-kuromoji](https://github.com/hexenq/kuroshiro-analyzer-kuromoji)
```html
<script src="url/to/kuroshiro-analyzer-kuromoji.min.js"></script>
```

實例化:
```js
var kuroshiro = new Kuroshiro();
```

使用一個解析器實例來初始化kuroshiro,然後進行轉換操作:
```js
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "/dict" }))
kuroshiro.init(new KuromojiAnalyzer({ dictPath: "url/to/dictFiles" }))
.then(function () {
return kuroshiro.convert("感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!", { to: "hiragana" });
})
Expand All @@ -90,7 +101,7 @@ const kuroshiro = new Kuroshiro();

### 實例方法
#### init(analyzer)
使用一個解析器實例來初始化kuroshiro。你可以使用上面提到的已實現的[解析器插件](#解析器插件)。關於解析器的初始化方法請參照相應解析器的文檔說明。
使用一個解析器實例來初始化kuroshiro。你需要首先導入並初始化一個解析器。你可以使用上面提到的已實現的[解析器插件](#解析器插件)。關於解析器的初始化方法請參照相應解析器的文檔說明。

__參數__

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuroshiro",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.2",
"description": "kuroshiro is a Japanese language library for converting Japanese sentence to Hiragana, Katakana or Romaji with furigana and okurigana modes supported.",
"main": "lib/index.js",
"module": "src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Kuroshiro {
}

/**
* Initiate Kuroshiro
* Initialize Kuroshiro
* @memberOf Kuroshiro
* @instance
* @returns {Promise} Promise object represents the result of initialization
Expand Down