LMAssembly // Add temporary data support for LMCoreEX.
This commit is contained in:
parent
73b8d04425
commit
eb7076e318
|
@ -227,6 +227,13 @@ extension vChewingLM {
|
||||||
lmAssociates.valuesFor(pair: pair)
|
lmAssociates.valuesFor(pair: pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func insertTemporaryData(key: String, unigram: Megrez.Unigram, isFiltering: Bool) {
|
||||||
|
_ =
|
||||||
|
isFiltering
|
||||||
|
? lmFiltered.temporaryMap[key, default: []].append(unigram)
|
||||||
|
: lmUserPhrases.temporaryMap[key, default: []].append(unigram)
|
||||||
|
}
|
||||||
|
|
||||||
/// 根據給定的索引鍵來確認各個資料庫陣列內是否存在對應的資料。
|
/// 根據給定的索引鍵來確認各個資料庫陣列內是否存在對應的資料。
|
||||||
/// - Parameter key: 索引鍵。
|
/// - Parameter key: 索引鍵。
|
||||||
/// - Returns: 是否在庫。
|
/// - Returns: 是否在庫。
|
||||||
|
|
|
@ -19,6 +19,8 @@ extension vChewingLM {
|
||||||
@frozen public struct LMCoreEX {
|
@frozen public struct LMCoreEX {
|
||||||
/// 資料庫辭典。索引內容為注音字串,資料內容則為字串首尾範圍、方便自 strData 取資料。
|
/// 資料庫辭典。索引內容為注音字串,資料內容則為字串首尾範圍、方便自 strData 取資料。
|
||||||
var rangeMap: [String: [Range<String.Index>]] = [:]
|
var rangeMap: [String: [Range<String.Index>]] = [:]
|
||||||
|
/// 資料庫追加辭典。
|
||||||
|
var temporaryMap: [String: [Megrez.Unigram]] = [:]
|
||||||
/// 資料庫字串陣列。
|
/// 資料庫字串陣列。
|
||||||
var strData: String = ""
|
var strData: String = ""
|
||||||
/// 聲明原始檔案內第一、二縱列的內容是否彼此顛倒。
|
/// 聲明原始檔案內第一、二縱列的內容是否彼此顛倒。
|
||||||
|
@ -78,6 +80,7 @@ extension vChewingLM {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
temporaryMap.removeAll()
|
||||||
} catch {
|
} catch {
|
||||||
vCLog("\(error)")
|
vCLog("\(error)")
|
||||||
vCLog("↑ Exception happened when reading data at: \(path).")
|
vCLog("↑ Exception happened when reading data at: \(path).")
|
||||||
|
@ -129,6 +132,9 @@ extension vChewingLM {
|
||||||
grams.append(Megrez.Unigram(value: theValue, score: theScore))
|
grams.append(Megrez.Unigram(value: theValue, score: theScore))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let arrOtherRecords: [Megrez.Unigram] = temporaryMap[key] {
|
||||||
|
grams.append(contentsOf: arrOtherRecords)
|
||||||
|
}
|
||||||
return grams
|
return grams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue