-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from ensan-hcl/tools/dictionary_debugger
[Tools] Debug用アプリケーションを追加
- Loading branch information
Showing
36 changed files
with
639 additions
and
6 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
DictionaryDebugger/Assets.xcassets/AccentColor.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
158 changes: 158 additions & 0 deletions
158
DictionaryDebugger/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "40.png", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "60.png", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "29.png", | ||
"idiom" : "iphone", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "58.png", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "87.png", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "80.png", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "120.png", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "57.png", | ||
"idiom" : "iphone", | ||
"scale" : "1x", | ||
"size" : "57x57" | ||
}, | ||
{ | ||
"filename" : "114.png", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "57x57" | ||
}, | ||
{ | ||
"filename" : "120.png", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"filename" : "180.png", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"filename" : "20.png", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "40.png", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "29.png", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "58.png", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "40.png", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "80.png", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "50.png", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "50x50" | ||
}, | ||
{ | ||
"filename" : "100.png", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "50x50" | ||
}, | ||
{ | ||
"filename" : "72.png", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "72x72" | ||
}, | ||
{ | ||
"filename" : "144.png", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "72x72" | ||
}, | ||
{ | ||
"filename" : "76.png", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"filename" : "152.png", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"filename" : "167.png", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "83.5x83.5" | ||
}, | ||
{ | ||
"filename" : "1024.png", | ||
"idiom" : "ios-marketing", | ||
"scale" : "1x", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// CCValueViewer.swift | ||
// DictionaryDebugger | ||
// | ||
// Created by ensan on 2023/05/27. | ||
// Copyright © 2023 ensan. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import KanaKanjiConverterModule | ||
|
||
struct CCValueViewer: View { | ||
private let dicdataStore: DicdataStore | ||
|
||
init (dicdataStore: DicdataStore) { | ||
self.dicdataStore = dicdataStore | ||
} | ||
|
||
@State private var lcid = 0 | ||
@State private var rcid = 0 | ||
|
||
private func getCCValue() -> PValue? { | ||
if lcid > 1318 || rcid > 1318 { | ||
return nil | ||
} | ||
return dicdataStore.getCCValue(lcid, rcid) | ||
} | ||
|
||
var body: some View { | ||
VStack { | ||
Text("CC Values") | ||
.font(.headline) | ||
IntegerTextField("lcid", text: $lcid.converted(forward: String.init, backward: {Int($0) ?? 0}), range: 0...1318) | ||
.textFieldStyle(.roundedBorder) | ||
.keyboardType(.numberPad) | ||
.submitLabel(.done) | ||
IntegerTextField("rcid", text: $rcid.converted(forward: String.init, backward: {Int($0) ?? 0}), range: 0...1318) | ||
.textFieldStyle(.roundedBorder) | ||
.keyboardType(.numberPad) | ||
.submitLabel(.done) | ||
Text(verbatim: """ | ||
CC Value between \(lcid) and \(rcid): \(getCCValue()?.description ?? "Invalid value") | ||
""") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// ContentView.swift | ||
// DictionaryDebugger | ||
// | ||
// Created by ensan on 2023/05/27. | ||
// Copyright © 2023 ensan. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import KanaKanjiConverterModule | ||
|
||
struct ContentView: View { | ||
@State private var dicdataStore: DicdataStore? = nil | ||
|
||
var body: some View { | ||
ScrollView { | ||
if let dicdataStore { | ||
WordSearcher(dicdataStore: dicdataStore) | ||
Divider() | ||
CCValueViewer(dicdataStore: dicdataStore) | ||
Divider() | ||
MMValueViewer(dicdataStore: dicdataStore) | ||
Divider() | ||
KanaKanjiConvertResultViewer(dicdataStore: dicdataStore) | ||
} else { | ||
ProgressView("Dicdataを読み込んでいます") | ||
} | ||
} | ||
.textSelection(.enabled) | ||
.task { | ||
let task = Task { | ||
let dicdataStore = DicdataStore(convertRequestOptions: .appDefault) | ||
return dicdataStore | ||
} | ||
self.dicdataStore = await task.value | ||
} | ||
} | ||
} | ||
|
||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContentView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// DictionaryDebuggerApp.swift | ||
// DictionaryDebugger | ||
// | ||
// Created by ensan on 2023/05/27. | ||
// Copyright © 2023 ensan. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@main | ||
struct DictionaryDebuggerApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// KanaKanjiConvertResultViewer.swift | ||
// DictionaryDebugger | ||
// | ||
// Created by ensan on 2023/05/27. | ||
// Copyright © 2023 ensan. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import KanaKanjiConverterModule | ||
|
||
struct KanaKanjiConvertResultViewer: View { | ||
private let converter: KanaKanjiConverter | ||
|
||
init (dicdataStore: DicdataStore) { | ||
self.converter = KanaKanjiConverter(dicdataStore: dicdataStore) | ||
} | ||
|
||
@State private var query = "" | ||
@State private var n_best = 10 | ||
@State private var prefix = 10 | ||
|
||
private func requestConversion() -> [Candidate] { | ||
var c = ComposingText() | ||
c.insertAtCursorPosition(query, inputStyle: .roman2kana) | ||
var options = ConvertRequestOptions.appDefault | ||
options.N_best = n_best | ||
let result = converter.requestCandidates(c, options: options) | ||
return result.mainResults | ||
} | ||
|
||
var body: some View { | ||
Text("KanaKanji Converter Viewer") | ||
.font(.headline) | ||
TextField("読みを入力", text: $query) | ||
.textFieldStyle(.roundedBorder) | ||
.submitLabel(.search) | ||
IntegerTextField("n_best", text: $n_best.converted(forward: String.init, backward: {Int($0) ?? 10}), range: 1...1000) | ||
.textFieldStyle(.roundedBorder) | ||
.keyboardType(.numberPad) | ||
.submitLabel(.done) | ||
IntegerTextField("n件表示", text: $prefix.converted(forward: String.init, backward: {Int($0) ?? 10}), range: 1...1000) | ||
.textFieldStyle(.roundedBorder) | ||
.keyboardType(.numberPad) | ||
.submitLabel(.done) | ||
Text(requestConversion() | ||
.prefix(prefix) | ||
.map{"word: \($0.text), value: \($0.value), data: \($0.data.map{$0.debugDescription}.joined(separator: ", "))"} | ||
.joined(separator: "\n") | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// MMValueViewer.swift | ||
// DictionaryDebugger | ||
// | ||
// Created by ensan on 2023/05/27. | ||
// Copyright © 2023 ensan. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import KanaKanjiConverterModule | ||
|
||
struct MMValueViewer: View { | ||
private let dicdataStore: DicdataStore | ||
|
||
init (dicdataStore: DicdataStore) { | ||
self.dicdataStore = dicdataStore | ||
} | ||
|
||
@State private var lmid = 0 | ||
@State private var rmid = 0 | ||
|
||
private func getMMValue() -> PValue? { | ||
if lmid > 502 || rmid > 502 { | ||
return nil | ||
} | ||
return dicdataStore.getMMValue(lmid, rmid) | ||
} | ||
|
||
var body: some View { | ||
VStack { | ||
Text("MM Values") | ||
.font(.headline) | ||
IntegerTextField("lmid", text: $lmid.converted(forward: String.init, backward: {Int($0) ?? 0}), range: 0...1318) | ||
.textFieldStyle(.roundedBorder) | ||
.keyboardType(.numberPad) | ||
.submitLabel(.done) | ||
IntegerTextField("rmid", text: $rmid.converted(forward: String.init, backward: {Int($0) ?? 0}), range: 0...1318) | ||
.textFieldStyle(.roundedBorder) | ||
.keyboardType(.numberPad) | ||
.submitLabel(.done) | ||
Text(verbatim: """ | ||
MM Value between \(lmid) and \(rmid): \(getMMValue()?.description ?? "Invalid value") | ||
""") | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
DictionaryDebugger/Preview Content/Preview Assets.xcassets/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.