OpenCC // Swift Clang-Format.
This commit is contained in:
parent
9aa781ecfd
commit
5fba88cfeb
|
@ -7,7 +7,7 @@ let package = Package(
|
||||||
products: [
|
products: [
|
||||||
.library(
|
.library(
|
||||||
name: "OpenCC",
|
name: "OpenCC",
|
||||||
targets: ["OpenCC"]),
|
targets: ["OpenCC"])
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
|
|
@ -22,7 +22,11 @@ extension ChineseConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dict(_ name: ChineseConverter.DictionaryName) throws -> ConversionDictionary {
|
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
|
throw ConversionError.fileNotFound
|
||||||
}
|
}
|
||||||
return try DictionaryLoader.dictCache.value(for: path) {
|
return try DictionaryLoader.dictCache.value(for: path) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
@testable import OpenCC
|
@testable import OpenCC
|
||||||
|
|
||||||
let testCases: [(String, ChineseConverter.Options)] = [
|
let testCases: [(String, ChineseConverter.Options)] = [
|
||||||
|
@ -20,7 +21,8 @@ class OpenCCTests: XCTestCase {
|
||||||
|
|
||||||
func testConversion() throws {
|
func testConversion() throws {
|
||||||
func testCase(name: String, ext: String) -> String {
|
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)
|
return try! String(contentsOf: url)
|
||||||
}
|
}
|
||||||
for (name, opt) in testCases {
|
for (name, opt) in testCases {
|
||||||
|
@ -54,7 +56,8 @@ class OpenCCTests: XCTestCase {
|
||||||
|
|
||||||
func testConversionPerformance() throws {
|
func testConversionPerformance() throws {
|
||||||
let cov = try converter(option: [.traditionalize, .twStandard, .twIdiom])
|
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
|
// 1.9 MB, 624k word
|
||||||
let str = try String(contentsOf: url)
|
let str = try String(contentsOf: url)
|
||||||
measure {
|
measure {
|
||||||
|
|
Loading…
Reference in New Issue