LMInstantiator // Let instances share some LMs.

- Also stop sorting bundled data.
This commit is contained in:
ShikiSuen 2022-05-02 14:57:35 +08:00
parent ca970e46c9
commit 3c64ddcbe9
1 changed files with 24 additions and 9 deletions

View File

@ -29,6 +29,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import Foundation
//
// LMInstantiator 100MB
private let lmCNS = vChewing.LMLite(consolidate: false)
private let lmSymbols = vChewing.LMCore(reverse: true, consolidate: false, defaultScore: -13.0, forceDefaultScore: true)
extension vChewing {
/// LMInstantiator is a facade for managing a set of models including
/// the input method language model, user phrases and excluded phrases.
@ -57,18 +62,27 @@ extension vChewing {
public var isCNSEnabled = false
public var isSymbolEnabled = false
///
/// LMCore key [Unigram]
///
///
/// 使 LMLite
/// LMLite
/// LMLite LMCore
/// 使 LMLiteMono
/// LMReplacements LMAssociates 使
//
/// Reverse
/// Reverse
let lmCore = LMCore(reverse: false, consolidate: false, defaultScore: -9.5, forceDefaultScore: false)
let lmMisc = LMCore(reverse: true, consolidate: false, defaultScore: -1, forceDefaultScore: false)
let lmSymbols = LMLite(consolidate: true)
let lmCNS = LMLite(consolidate: true)
// 使
let lmUserPhrases = LMLite(consolidate: true)
let lmFiltered = LMLite(consolidate: true)
let lmUserSymbols = LMLite(consolidate: true)
// 使
// 使使
let lmUserPhrases = LMLiteMono(consolidate: true)
let lmFiltered = LMLiteMono(consolidate: true)
let lmUserSymbols = LMLiteMono(consolidate: true)
let lmReplacements = LMReplacments()
let lmAssociates = LMAssociates()
@ -77,10 +91,11 @@ extension vChewing {
//
deinit {
// LMInstantiator
// lmCNS.close() // <--
// lmSymbols.close() // <--
lmCore.close()
lmMisc.close()
lmSymbols.close()
lmCNS.close()
lmUserPhrases.close()
lmFiltered.close()
lmUserSymbols.close()
@ -194,7 +209,7 @@ extension vChewing {
IME.prtDebugIntel("Not found in UserSymbolUnigram: \(key)")
}
rawAllUnigrams += lmSymbols.unigramsFor(key: key, score: -11.0)
rawAllUnigrams += lmSymbols.unigramsFor(key: key)
if lmSymbols.unigramsFor(key: key).isEmpty {
IME.prtDebugIntel("Not found in UserUnigram: \(key)")
}