mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-08-22 15:05:26 +00:00
Merge pull request #8 from ensan-hcl/docs/add_document
Add more documents
This commit is contained in:
56
README.md
56
README.md
@ -1,10 +1,37 @@
|
||||
# AzooKeyKanakanjiConverter
|
||||
|
||||
azooKeyのかな漢字変換モジュールを切り出したライブラリです。
|
||||
[azooKey](https://github.com/ensan-hcl/azooKey)のかな漢字変換モジュールを切り出したライブラリです。
|
||||
|
||||
## KanaKanjiConverterModule
|
||||
かな漢字変換を受け持つモジュールです。
|
||||
|
||||
### セットアップ
|
||||
* Xcodeprojの場合、XcodeでAdd Packageしてください。
|
||||
* Swift Packageの場合、Package.swiftの`Package`の引数に`dependencies`以下の記述を追加してください。
|
||||
```swift
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/ensan-hcl/AzooKeyKanaKanjiConverter", from: "0.1.0")
|
||||
],
|
||||
```
|
||||
また、ターゲットの`dependencies`にも同様に追加してください。
|
||||
```swift
|
||||
.target(
|
||||
name: "MyPackage",
|
||||
dependencies: [
|
||||
.product(name: "KanaKanjiConverterModule", package: "AzooKeyKanaKanjiConverter")
|
||||
],
|
||||
),
|
||||
```
|
||||
|
||||
* [Google DriveからazooKeyの辞書をダウンロード](https://drive.google.com/drive/folders/1Kh7fgMFIzkpg7YwP3GhWTxFkXI-yzT9E?usp=sharing)する必要があります。最新のバージョンのフォルダの中にある「Dictionary」というフォルダを右クリックし、フォルダごとダウンロードします。ついで、本モジュールを利用するアプリケーションのリソースとして配置してください。
|
||||
|
||||
|
||||
> [!IMPORTANT]
|
||||
> リソースを追加する際、Folder Referenceをコピーしてください。AzooKeyKanaKanjiConverterはフォルダ構造が存在することを前提に動作します。
|
||||
|
||||
|
||||
|
||||
### 使い方
|
||||
```swift
|
||||
import KanaKanjiConverterModule
|
||||
|
||||
@ -21,11 +48,32 @@ print(results.mainResults.first!.text) // azooKeyは新時代のキーボード
|
||||
```
|
||||
`ConvertRequestOptions`は、変換リクエストに必要な情報を指定します。詳しくはコードに書かれたドキュメントコメントを参照してください。
|
||||
|
||||
### `ConvertRequestOptions`
|
||||
`ConvertRequestOptions`は変換リクエストに必要な設定値です。例えば以下のように設定します。
|
||||
|
||||
```swift
|
||||
let options = ConvertRequestOptions(
|
||||
// 日本語予測変換
|
||||
requireJapanesePrediction: true,
|
||||
// 英語予測変換
|
||||
requireEnglishPrediction: false,
|
||||
// 入力言語
|
||||
keyboardLanguage: .ja_JP,
|
||||
// 学習タイプ
|
||||
learningType: .nothing,
|
||||
// 辞書データのURL(先ほど追加した辞書リソースを指定)
|
||||
dictionaryResourceURL: Bundle.main.bundleURL.appending(path: "Dictionary", directoryHint: .isDirectory),
|
||||
// 学習データを保存するディレクトリのURL(書類フォルダを指定)
|
||||
memoryDirectoryURL: .documentsDirectory,
|
||||
// ユーザ辞書データのあるディレクトリのURL(書類フォルダを指定)
|
||||
sharedContainerURL: .documentsDirectory,
|
||||
// メタデータ
|
||||
metadata: .init(appVersionString: "Version X")
|
||||
)
|
||||
```
|
||||
### 辞書データ
|
||||
|
||||
利用時は、ConvertRequestOptionsの`dictionaryResourceURL`に辞書データのディレクトリのURLを指定する必要があります。
|
||||
|
||||
辞書データは[Google Drive](https://drive.google.com/drive/folders/1Kh7fgMFIzkpg7YwP3GhWTxFkXI-yzT9E?usp=sharing)からダウンロードすることができます。
|
||||
上記のとおり、利用時は、ConvertRequestOptionsの`dictionaryResourceURL`に辞書データのディレクトリのURLを指定する必要があります。辞書データは[Google Drive](https://drive.google.com/drive/folders/1Kh7fgMFIzkpg7YwP3GhWTxFkXI-yzT9E?usp=sharing)からダウンロードすることができます。
|
||||
|
||||
また、以下のフォーマットであれば自前で用意した辞書データを利用することもできます。カスタム辞書データのサポートは限定的なので、ソースコードを確認の上ご利用ください。
|
||||
|
||||
|
@ -28,7 +28,7 @@ public struct ConvertRequestOptions {
|
||||
/// - memoryDirectoryURL: 学習データの保存先を指定します。書き込み可能なディレクトリを指定してください。
|
||||
/// - sharedContainerURL: ユーザ辞書など、キーボード外で書き込んだ設定データの保存されているディレクトリを指定します。
|
||||
/// - metadata: メタデータを指定します。詳しくは`ConvertRequestOptions.Metadata`を参照してください。
|
||||
public init(N_best: Int = 10, requireJapanesePrediction: Bool, requireEnglishPrediction: Bool, keyboardLanguage: KeyboardLanguage, typographyLetterCandidate: Bool = false, unicodeCandidate: Bool = true, englishCandidateInRoman2KanaInput: Bool, fullWidthRomanCandidate: Bool = false, halfWidthKanaCandidate: Bool, learningType: LearningType, maxMemoryCount: Int = 65536, shouldResetMemory: Bool = false, dictionaryResourceURL: URL, memoryDirectoryURL: URL, sharedContainerURL: URL, metadata: ConvertRequestOptions.Metadata) {
|
||||
public init(N_best: Int = 10, requireJapanesePrediction: Bool, requireEnglishPrediction: Bool, keyboardLanguage: KeyboardLanguage, typographyLetterCandidate: Bool = false, unicodeCandidate: Bool = true, englishCandidateInRoman2KanaInput: Bool = false, fullWidthRomanCandidate: Bool = false, halfWidthKanaCandidate: Bool = false, learningType: LearningType, maxMemoryCount: Int = 65536, shouldResetMemory: Bool = false, dictionaryResourceURL: URL, memoryDirectoryURL: URL, sharedContainerURL: URL, metadata: ConvertRequestOptions.Metadata) {
|
||||
self.N_best = N_best
|
||||
self.requireJapanesePrediction = requireJapanesePrediction
|
||||
self.requireEnglishPrediction = requireEnglishPrediction
|
||||
|
Reference in New Issue
Block a user