mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-08-22 06:55:26 +00:00
feat: enable InternalImportsByDefault feature flag
This commit is contained in:
@ -7,6 +7,7 @@ import Foundation
|
||||
let swiftSettings: [SwiftSetting] = [
|
||||
.enableUpcomingFeature("ExistentialAny"),
|
||||
.enableUpcomingFeature("MemberImportVisibility"),
|
||||
.enableUpcomingFeature("InternalImportsByDefault"),
|
||||
.interoperabilityMode(.Cxx, .when(traits: ["Zenzai"]))
|
||||
]
|
||||
|
||||
|
@ -2,8 +2,8 @@ import KanaKanjiConverterModuleWithDefaultDictionary
|
||||
import ArgumentParser
|
||||
|
||||
@main
|
||||
public struct Anco: AsyncParsableCommand {
|
||||
public static let configuration = CommandConfiguration(
|
||||
struct Anco: AsyncParsableCommand {
|
||||
static let configuration = CommandConfiguration(
|
||||
abstract: "Anco is A(zooKey) Kana-Ka(n)ji (co)nverter",
|
||||
subcommands: [
|
||||
Subcommands.Run.self,
|
||||
@ -17,5 +17,5 @@ public struct Anco: AsyncParsableCommand {
|
||||
defaultSubcommand: Subcommands.Run.self
|
||||
)
|
||||
|
||||
public init() {}
|
||||
init() {}
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ extension Subcommands {
|
||||
if stable {
|
||||
result.execution_time = 0
|
||||
result.timestamp = 0
|
||||
result.items.mutatingForeach {
|
||||
result.items.mutatingForEach {
|
||||
$0.entropy = Double(Int($0.entropy * 10)) / 10
|
||||
$0.outputs.mutatingForeach {
|
||||
$0.outputs.mutatingForEach {
|
||||
$0.score = Double(Int($0.score))
|
||||
}
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ extension Subcommands {
|
||||
if stable {
|
||||
result.execution_time = 0
|
||||
result.timestamp = 0
|
||||
result.items.mutatingForeach {
|
||||
$0.outputs.mutatingForeach {
|
||||
result.items.mutatingForEach {
|
||||
$0.outputs.mutatingForEach {
|
||||
$0.score = Double(Int($0.score))
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright © 2022 ensan. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
public import Foundation
|
||||
|
||||
public struct ConvertRequestOptions: Sendable {
|
||||
/// 変換リクエストに必要な設定データ
|
||||
|
@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import Algorithms
|
||||
import Foundation
|
||||
package import Foundation
|
||||
import SwiftUtils
|
||||
import EfficientNGram
|
||||
|
||||
@ -19,7 +19,7 @@ import EfficientNGram
|
||||
}
|
||||
|
||||
private var converter = Kana2Kanji()
|
||||
public static let defaultSpecialCandidateProviders: [any SpecialCandidateProvider] = [
|
||||
nonisolated public static let defaultSpecialCandidateProviders: [any SpecialCandidateProvider] = [
|
||||
CalendarSpecialCandidateProvider(),
|
||||
EmailAddressSpecialCandidateProvider(),
|
||||
UnicodeSpecialCandidateProvider(),
|
||||
@ -582,7 +582,7 @@ import EfficientNGram
|
||||
result.append(contentsOf: clause_candidates)
|
||||
result.append(contentsOf: word_candidates)
|
||||
|
||||
result.mutatingForeach { item in
|
||||
result.mutatingForEach { item in
|
||||
item.withActions(self.getAppropriateActions(item))
|
||||
item.parseTemplate()
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public final class DicdataStore {
|
||||
self.closeKeyboard()
|
||||
case .importOSUserDict(let dicdata), .importDynamicUserDict(let dicdata):
|
||||
self.dynamicUserDict = dicdata
|
||||
self.dynamicUserDict.mutatingForeach {
|
||||
self.dynamicUserDict.mutatingForEach {
|
||||
$0.metadata = .isFromUserDictionary
|
||||
}
|
||||
case let .forgetMemory(candidate):
|
||||
@ -258,12 +258,12 @@ public final class DicdataStore {
|
||||
data.append(contentsOf: LOUDS.getDataForLoudstxt3(identifier + "\(key)", indices: value.map {$0 & 2047}, cache: self.loudstxts[identifier + "\(key)"], option: self.requestOptions))
|
||||
}
|
||||
if identifier == "memory" {
|
||||
data.mutatingForeach {
|
||||
data.mutatingForEach {
|
||||
$0.metadata = .isLearned
|
||||
}
|
||||
}
|
||||
if identifier == "user" {
|
||||
data.mutatingForeach {
|
||||
data.mutatingForEach {
|
||||
$0.metadata = .isFromUserDictionary
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright © 2020 ensan. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
package import Foundation
|
||||
import SwiftUtils
|
||||
|
||||
extension LOUDS {
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright © 2023 ensan. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
public import Foundation
|
||||
import SwiftUtils
|
||||
|
||||
/// `TextReplacer`は前後の文脈に基づいて、現在のカーソル位置の語の置き換えを提案するためのモジュールである。
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright © 2020 ensan. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
public import Foundation
|
||||
import SwiftUtils
|
||||
|
||||
public struct TemplateData: Codable, Sendable {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Foundation
|
||||
package import Foundation
|
||||
import SwiftUtils
|
||||
import EfficientNGram
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
@_exported import KanaKanjiConverterModule
|
||||
import Foundation
|
||||
@_exported public import KanaKanjiConverterModule
|
||||
public import Foundation
|
||||
|
||||
public extension ConvertRequestOptions {
|
||||
static func withDefaultDictionary(
|
||||
|
@ -5,20 +5,20 @@
|
||||
// Created by ensan on 2023/04/30.
|
||||
//
|
||||
|
||||
import Algorithms
|
||||
package import Algorithms
|
||||
import Foundation
|
||||
|
||||
public extension Sequence {
|
||||
package extension Sequence {
|
||||
/// Returns a sequence that contains the elements of this sequence followed by the elements of the given sequence.
|
||||
/// - Parameters:
|
||||
/// - sequence: A sequence of elements to chain.
|
||||
/// - Returns: A sequence that contains the elements of this sequence followed by the elements of the given sequence.
|
||||
@inlinable func chained<S: Sequence<Element>>(_ sequence: S) -> Chain2Sequence<Self, S> {
|
||||
func chained<S: Sequence<Element>>(_ sequence: S) -> Chain2Sequence<Self, S> {
|
||||
chain(self, sequence)
|
||||
}
|
||||
}
|
||||
|
||||
public extension Collection {
|
||||
package extension Collection {
|
||||
/// Returns a `Set` containing the elements of this sequence with transformed values.
|
||||
/// - Parameters:
|
||||
/// - transform: A closure that transforms each element of this sequence into a value that can be hashed.
|
||||
@ -60,18 +60,18 @@ public extension Collection {
|
||||
}
|
||||
}
|
||||
|
||||
public extension MutableCollection {
|
||||
package extension MutableCollection {
|
||||
/// Calls the given closure with a pointer to the array's mutable contiguous storage.
|
||||
/// - Parameter
|
||||
/// - transform: A closure that takes a pointer to the array's mutable contiguous storage.
|
||||
@inlinable mutating func mutatingForeach(transform closure: (inout Element) throws -> Void) rethrows {
|
||||
@inlinable mutating func mutatingForEach(transform closure: (inout Element) throws -> Void) rethrows {
|
||||
for index in self.indices {
|
||||
try closure(&self[index])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension Collection {
|
||||
package extension Collection {
|
||||
/// Returns a SubSequence containing the elements of this sequence up to the first element that does not satisfy the given predicate.
|
||||
/// - Parameters:
|
||||
/// - condition: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included.
|
||||
@ -85,7 +85,7 @@ public extension Collection {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Collection where Self.Element: Equatable {
|
||||
package extension Collection where Self.Element: Equatable {
|
||||
/// Returns a Bool value indicating whether the collection has the given prefix.
|
||||
/// - Parameters:
|
||||
/// - prefix: A collection to search for at the start of this collection.
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum CharacterUtils {
|
||||
package enum CharacterUtils {
|
||||
/// 小書きのかなカナ集合
|
||||
private static let kogakiKana: Set<Character> = [
|
||||
"ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ゕ", "ゖ", "っ", "ゃ", "ゅ", "ょ", "ゎ",
|
||||
@ -26,12 +26,12 @@ public enum CharacterUtils {
|
||||
}
|
||||
|
||||
/// ローマ字(a-z, A-Zか否か)
|
||||
@inlinable public static func isRomanLetter(_ character: Character) -> Bool {
|
||||
@inlinable package static func isRomanLetter(_ character: Character) -> Bool {
|
||||
character.isASCII && character.isCased
|
||||
}
|
||||
|
||||
/// 自分が小書きであれば該当する文字を返す。
|
||||
public static func kogaki(_ character: Character) -> Character {
|
||||
package static func kogaki(_ character: Character) -> Character {
|
||||
switch character {
|
||||
case "あ": return "ぁ"
|
||||
case "い": return "ぃ"
|
||||
@ -62,7 +62,7 @@ public enum CharacterUtils {
|
||||
}
|
||||
|
||||
/// 小書きから大書きを返す
|
||||
public static func ogaki(_ character: Character) -> Character {
|
||||
package static func ogaki(_ character: Character) -> Character {
|
||||
switch character {
|
||||
case "ぁ": return "あ"
|
||||
case "ぃ": return "い"
|
||||
@ -93,11 +93,11 @@ public enum CharacterUtils {
|
||||
}
|
||||
|
||||
/// 濁点付きか否か
|
||||
public static func isDakuten(_ character: Character) -> Bool {
|
||||
package static func isDakuten(_ character: Character) -> Bool {
|
||||
dakutenKana.contains(character)
|
||||
}
|
||||
/// 濁点をつけて返す
|
||||
public static func dakuten(_ character: Character) -> Character {
|
||||
package static func dakuten(_ character: Character) -> Character {
|
||||
switch character {
|
||||
case"う": return "ゔ"
|
||||
case"か": return "が"
|
||||
@ -145,7 +145,7 @@ public enum CharacterUtils {
|
||||
}
|
||||
}
|
||||
/// 濁点を外して返す
|
||||
public static func mudakuten(_ character: Character) -> Character {
|
||||
package static func mudakuten(_ character: Character) -> Character {
|
||||
switch character {
|
||||
case"ゔ": return "う"
|
||||
case"が": return "か"
|
||||
@ -193,14 +193,14 @@ public enum CharacterUtils {
|
||||
}
|
||||
}
|
||||
/// 半濁点かどうか
|
||||
public static func isHandakuten(_ character: Character) -> Bool {
|
||||
package static func isHandakuten(_ character: Character) -> Bool {
|
||||
[
|
||||
"ぱ", "ぴ", "ぷ", "ぺ", "ぽ",
|
||||
"パ", "ピ", "プ", "ペ", "ポ"
|
||||
].contains(character)
|
||||
}
|
||||
/// 半濁点をつけて返す
|
||||
public static func handakuten(_ character: Character) -> Character {
|
||||
package static func handakuten(_ character: Character) -> Character {
|
||||
switch character {
|
||||
case"は": return "ぱ"
|
||||
case"ひ": return "ぴ"
|
||||
@ -216,7 +216,7 @@ public enum CharacterUtils {
|
||||
}
|
||||
}
|
||||
/// 半濁点を外して返す
|
||||
public static func muhandakuten(_ character: Character) -> Character {
|
||||
package static func muhandakuten(_ character: Character) -> Character {
|
||||
switch character {
|
||||
case"ぱ": return "は"
|
||||
case"ぴ": return "ひ"
|
||||
@ -233,7 +233,7 @@ public enum CharacterUtils {
|
||||
}
|
||||
|
||||
/// 濁点、小書き、半濁点などを相互に変換する関数。
|
||||
public static func requestChange(_ character: Character) -> String {
|
||||
package static func requestChange(_ character: Character) -> String {
|
||||
if character.isLowercase {
|
||||
return character.uppercased()
|
||||
}
|
||||
@ -285,7 +285,7 @@ public enum CharacterUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Character {
|
||||
package extension Character {
|
||||
/// Returns the Katakanized version of the character.
|
||||
@inlinable func toKatakana() -> Character {
|
||||
if self.unicodeScalars.count != 1 {
|
||||
|
@ -6,14 +6,14 @@
|
||||
// Copyright © 2022 ensan. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
package import Foundation
|
||||
|
||||
extension Data {
|
||||
package extension Data {
|
||||
/// Converts this data to an array of the given type.
|
||||
/// - Parameter:
|
||||
/// - type: The type to convert this data to.
|
||||
/// - Returns: An array of the given type.
|
||||
@inlinable public func toArray<T>(of type: T.Type) -> [T] {
|
||||
func toArray<T>(of type: T.Type) -> [T] {
|
||||
self.withUnsafeBytes {pointer -> [T] in
|
||||
Array(
|
||||
UnsafeBufferPointer(
|
||||
|
@ -8,16 +8,16 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension StringProtocol {
|
||||
package extension StringProtocol {
|
||||
/// ローマ字と数字のみかどうか
|
||||
/// - note: 空文字列の場合`false`を返す。
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
var onlyRomanAlphabetOrNumber: Bool {
|
||||
!isEmpty && range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
|
||||
}
|
||||
/// ローマ字のみかどうか
|
||||
/// - note: 空文字列の場合`false`を返す。
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
var onlyRomanAlphabet: Bool {
|
||||
!isEmpty && range(of: "[^a-zA-Z]", options: .regularExpression) == nil
|
||||
}
|
||||
@ -35,20 +35,21 @@ public extension StringProtocol {
|
||||
}
|
||||
/// 英語として許容可能な文字のみで構成されているか。
|
||||
/// - note: 空文字列の場合`false`を返す。
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
var isEnglishSentence: Bool {
|
||||
!isEmpty && range(of: "[^0-9a-zA-Z\n !'_<>\\[\\]{}*@`\\^|~=\"#$%&\\+\\(\\),\\-\\./:;?’\\\\]", options: .regularExpression) == nil
|
||||
}
|
||||
|
||||
/// 仮名か
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
var isKana: Bool {
|
||||
!isEmpty && range(of: "[^ぁ-ゖァ-ヶ]", options: .regularExpression) == nil
|
||||
}
|
||||
|
||||
/// Returns a String value in which Hiraganas are all converted to Katakana.
|
||||
/// - Returns: A String value in which Hiraganas are all converted to Katakana.
|
||||
@inlinable func toKatakana() -> String {
|
||||
@usableFromInline
|
||||
func toKatakana() -> String {
|
||||
// カタカナはutf16で常に2バイトなので、utf16単位で処理して良い
|
||||
let result = self.utf16.map { scalar -> UInt16 in
|
||||
if 0x3041 <= scalar && scalar <= 0x3096 {
|
||||
@ -62,7 +63,8 @@ public extension StringProtocol {
|
||||
|
||||
/// Returns a String value in which Katakana are all converted to Hiragana.
|
||||
/// - Returns: A String value in which Katakana are all converted to Hiragana.
|
||||
@inlinable func toHiragana() -> String {
|
||||
@usableFromInline
|
||||
func toHiragana() -> String {
|
||||
// ひらがなはutf16で常に2バイトなので、utf16単位で処理して良い
|
||||
let result = self.utf16.map { scalar -> UInt16 in
|
||||
if 0x30A1 <= scalar && scalar <= 0x30F6 {
|
||||
|
Reference in New Issue
Block a user