LMAssembly // Format tweaks.
This commit is contained in:
parent
04bdb0db47
commit
fd3c48bf02
|
@ -16,17 +16,13 @@ extension vChewingLM {
|
|||
var rangeMap: [String: [(Range<String.Index>, Int)]] = [:]
|
||||
var strData: String = ""
|
||||
|
||||
public var count: Int {
|
||||
rangeMap.count
|
||||
}
|
||||
public var count: Int { rangeMap.count }
|
||||
|
||||
public init() {
|
||||
rangeMap = [:]
|
||||
}
|
||||
|
||||
public var isLoaded: Bool {
|
||||
!rangeMap.isEmpty
|
||||
}
|
||||
public var isLoaded: Bool { !rangeMap.isEmpty }
|
||||
|
||||
internal func cnvNGramKeyFromPinyinToPhona(target: String) -> String {
|
||||
guard target.contains("("), target.contains(","), target.contains(")") else {
|
||||
|
@ -40,9 +36,7 @@ extension vChewingLM {
|
|||
}
|
||||
|
||||
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||
if isLoaded {
|
||||
return false
|
||||
}
|
||||
if isLoaded { return false }
|
||||
|
||||
LMConsolidator.fixEOF(path: path)
|
||||
LMConsolidator.consolidate(path: path, pragma: true)
|
||||
|
@ -72,9 +66,7 @@ extension vChewingLM {
|
|||
}
|
||||
|
||||
public mutating func close() {
|
||||
if isLoaded {
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
|
||||
public func valuesFor(pair: Megrez.Compositor.KeyValuePaired) -> [String] {
|
||||
|
|
|
@ -30,9 +30,7 @@ extension vChewingLM {
|
|||
var shouldForceDefaultScore = false
|
||||
|
||||
/// 資料陣列內承載的資料筆數。
|
||||
public var count: Int {
|
||||
rangeMap.count
|
||||
}
|
||||
public var count: Int { rangeMap.count }
|
||||
|
||||
/// 初期化該語言模型。
|
||||
///
|
||||
|
@ -53,17 +51,13 @@ extension vChewingLM {
|
|||
}
|
||||
|
||||
/// 檢測資料庫辭典內是否已經有載入的資料。
|
||||
public var isLoaded: Bool {
|
||||
!rangeMap.isEmpty
|
||||
}
|
||||
public var isLoaded: Bool { !rangeMap.isEmpty }
|
||||
|
||||
/// 將資料從檔案讀入至資料庫辭典內。
|
||||
/// - parameters:
|
||||
/// - path: 給定路徑。
|
||||
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||
if isLoaded {
|
||||
return false
|
||||
}
|
||||
if isLoaded { return false }
|
||||
|
||||
if allowConsolidation {
|
||||
LMConsolidator.fixEOF(path: path)
|
||||
|
@ -95,9 +89,7 @@ extension vChewingLM {
|
|||
|
||||
/// 將當前語言模組的資料庫辭典自記憶體內卸除。
|
||||
public mutating func close() {
|
||||
if isLoaded {
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
|
||||
// MARK: - Advanced features
|
||||
|
|
|
@ -29,9 +29,7 @@ extension vChewingLM {
|
|||
var shouldForceDefaultScore = false
|
||||
|
||||
/// 資料陣列內承載的資料筆數。
|
||||
public var count: Int {
|
||||
rangeMap.count
|
||||
}
|
||||
public var count: Int { rangeMap.count }
|
||||
|
||||
/// 初期化該語言模型。
|
||||
///
|
||||
|
@ -54,17 +52,13 @@ extension vChewingLM {
|
|||
}
|
||||
|
||||
/// 檢測資料庫辭典內是否已經有載入的資料。
|
||||
public var isLoaded: Bool {
|
||||
!rangeMap.isEmpty
|
||||
}
|
||||
public var isLoaded: Bool { !rangeMap.isEmpty }
|
||||
|
||||
/// 將資料從檔案讀入至資料庫辭典內。
|
||||
/// - parameters:
|
||||
/// - path: 給定路徑。
|
||||
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||
if isLoaded {
|
||||
return false
|
||||
}
|
||||
if isLoaded { return false }
|
||||
|
||||
do {
|
||||
let rawData = try Data(contentsOf: URL(fileURLWithPath: path))
|
||||
|
@ -81,9 +75,7 @@ extension vChewingLM {
|
|||
|
||||
/// 將當前語言模組的資料庫辭典自記憶體內卸除。
|
||||
public mutating func close() {
|
||||
if isLoaded {
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
|
||||
// MARK: - Advanced features
|
||||
|
|
|
@ -14,22 +14,16 @@ extension vChewingLM {
|
|||
@frozen public struct LMPlainBopomofo {
|
||||
var rangeMap: [String: String] = [:]
|
||||
|
||||
public var count: Int {
|
||||
rangeMap.count
|
||||
}
|
||||
public var count: Int { rangeMap.count }
|
||||
|
||||
public init() {
|
||||
rangeMap = [:]
|
||||
}
|
||||
|
||||
public var isLoaded: Bool {
|
||||
!rangeMap.isEmpty
|
||||
}
|
||||
public var isLoaded: Bool { !rangeMap.isEmpty }
|
||||
|
||||
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||
if isLoaded {
|
||||
return false
|
||||
}
|
||||
if isLoaded { return false }
|
||||
|
||||
do {
|
||||
let rawData = try Data(contentsOf: URL(fileURLWithPath: path))
|
||||
|
@ -46,9 +40,7 @@ extension vChewingLM {
|
|||
}
|
||||
|
||||
public mutating func close() {
|
||||
if isLoaded {
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
|
||||
public func valuesFor(key: String) -> [String] {
|
||||
|
|
|
@ -14,22 +14,16 @@ extension vChewingLM {
|
|||
var rangeMap: [String: Range<String.Index>] = [:]
|
||||
var strData: String = ""
|
||||
|
||||
public var count: Int {
|
||||
rangeMap.count
|
||||
}
|
||||
public var count: Int { rangeMap.count }
|
||||
|
||||
public init() {
|
||||
rangeMap = [:]
|
||||
}
|
||||
|
||||
public var isLoaded: Bool {
|
||||
!rangeMap.isEmpty
|
||||
}
|
||||
public var isLoaded: Bool { !rangeMap.isEmpty }
|
||||
|
||||
@discardableResult public mutating func open(_ path: String) -> Bool {
|
||||
if isLoaded {
|
||||
return false
|
||||
}
|
||||
if isLoaded { return false }
|
||||
|
||||
LMConsolidator.fixEOF(path: path)
|
||||
LMConsolidator.consolidate(path: path, pragma: true)
|
||||
|
@ -57,9 +51,7 @@ extension vChewingLM {
|
|||
}
|
||||
|
||||
public mutating func close() {
|
||||
if isLoaded {
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
rangeMap.removeAll()
|
||||
}
|
||||
|
||||
public func dump() {
|
||||
|
|
Loading…
Reference in New Issue