Skip to content

Commit

Permalink
Merge pull request #206 from ensan-hcl/tools/dictionary_debugger
Browse files Browse the repository at this point in the history
[Tools] Debug用アプリケーションを追加
  • Loading branch information
ensan-hcl committed May 27, 2023
2 parents 76edd83 + 6dfd09e commit 2e74551
Show file tree
Hide file tree
Showing 36 changed files with 639 additions and 6 deletions.
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 DictionaryDebugger/Assets.xcassets/AppIcon.appiconset/Contents.json
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
}
}
6 changes: 6 additions & 0 deletions DictionaryDebugger/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
46 changes: 46 additions & 0 deletions DictionaryDebugger/CCValueViewer.swift
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")
""")
}
}
}
44 changes: 44 additions & 0 deletions DictionaryDebugger/ContentView.swift
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()
}
}
18 changes: 18 additions & 0 deletions DictionaryDebugger/DictionaryDebuggerApp.swift
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()
}
}
}
52 changes: 52 additions & 0 deletions DictionaryDebugger/KanaKanjiConvertResultViewer.swift
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")
)
}
}
46 changes: 46 additions & 0 deletions DictionaryDebugger/MMValueViewer.swift
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")
""")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 2e74551

Please sign in to comment.