OpenCC // Swift Clang-Format.
This commit is contained in:
parent
8d68d9f380
commit
63c6a3e4be
|
@ -7,7 +7,7 @@ let package = Package(
|
|||
products: [
|
||||
.library(
|
||||
name: "OpenCC",
|
||||
targets: ["OpenCC"]),
|
||||
targets: ["OpenCC"])
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
|
|
|
@ -22,7 +22,11 @@ extension ChineseConverter {
|
|||
}
|
||||
|
||||
func dict(_ name: ChineseConverter.DictionaryName) throws -> ConversionDictionary {
|
||||
guard let path = bundle.path(forResource: name.description, ofType: "ocd2", inDirectory: DictionaryLoader.subdirectory) else {
|
||||
guard
|
||||
let path = bundle.path(
|
||||
forResource: name.description, ofType: "ocd2",
|
||||
inDirectory: DictionaryLoader.subdirectory)
|
||||
else {
|
||||
throw ConversionError.fileNotFound
|
||||
}
|
||||
return try DictionaryLoader.dictCache.value(for: path) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import XCTest
|
||||
|
||||
@testable import OpenCC
|
||||
|
||||
let testCases: [(String, ChineseConverter.Options)] = [
|
||||
|
@ -20,7 +21,8 @@ class OpenCCTests: XCTestCase {
|
|||
|
||||
func testConversion() throws {
|
||||
func testCase(name: String, ext: String) -> String {
|
||||
let url = Bundle.module.url(forResource: name, withExtension: ext, subdirectory: "testcases")!
|
||||
let url = Bundle.module.url(
|
||||
forResource: name, withExtension: ext, subdirectory: "testcases")!
|
||||
return try! String(contentsOf: url)
|
||||
}
|
||||
for (name, opt) in testCases {
|
||||
|
@ -54,7 +56,8 @@ class OpenCCTests: XCTestCase {
|
|||
|
||||
func testConversionPerformance() throws {
|
||||
let cov = try converter(option: [.traditionalize, .twStandard, .twIdiom])
|
||||
let url = Bundle.module.url(forResource: "zuozhuan", withExtension: "txt", subdirectory: "benchmark")!
|
||||
let url = Bundle.module.url(
|
||||
forResource: "zuozhuan", withExtension: "txt", subdirectory: "benchmark")!
|
||||
// 1.9 MB, 624k word
|
||||
let str = try String(contentsOf: url)
|
||||
measure {
|
||||
|
|
Loading…
Reference in New Issue