feat: add forget memory test

This commit is contained in:
Miwa / Ensan
2025-06-01 21:39:33 +09:00
parent 53cb1e3b41
commit 7af6d81ef6
4 changed files with 47 additions and 9 deletions

View File

@@ -226,7 +226,7 @@ public final class DicdataStore {
}
}
private func perfectMatchLOUDS(query: String, charIDs: [UInt8]) -> [Int] {
func perfectMatchLOUDS(query: String, charIDs: [UInt8]) -> [Int] {
guard let louds = self.loadLOUDS(query: query) else {
return []
}

View File

@@ -626,7 +626,7 @@ final class LearningManager {
debug("Error: louds/charID.chidが存在しません。このエラーは深刻ですが、テスト時には無視できる場合があります。Description: \(error)")
}
}
private var char2UInt8: [Character: UInt8] = [:]
var char2UInt8: [Character: UInt8] = [:]
static var today: UInt16 {
UInt16(Int(Date().timeIntervalSince1970) / 86400) - 19000
@@ -662,6 +662,13 @@ final class LearningManager {
self.options = newOptions
return false
}
// `char2Int8`
if newOptions.dictionaryResourceURL != self.options.dictionaryResourceURL {
Self.updateChar2Int8(bundleURL: newOptions.dictionaryResourceURL, target: &self.char2UInt8)
}
//
self.options = newOptions
//
self.memoryCollapsed = LongTermLearningMemory.memoryCollapsed(directoryURL: newOptions.memoryDirectoryURL)
if self.memoryCollapsed && newOptions.learningType.needUsingMemory {
@@ -670,7 +677,7 @@ final class LearningManager {
tempTrie: TemporalLearningMemoryTrie(),
directoryURL: newOptions.memoryDirectoryURL,
maxMemoryCount: newOptions.maxMemoryCount,
char2UInt8: char2UInt8
char2UInt8: self.char2UInt8
)
} catch {
debug(#file, #function, "automatic merge failed", error)
@@ -681,12 +688,6 @@ final class LearningManager {
//
debug(#file, #function, "LearningManager init: Memory Collapsed")
}
// `char2Int8`
if newOptions.dictionaryResourceURL != self.options.dictionaryResourceURL {
Self.updateChar2Int8(bundleURL: newOptions.dictionaryResourceURL, target: &char2UInt8)
}
//
self.options = newOptions
switch self.options.learningType {
case .inputAndOutput, .onlyOutput: break