mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-08-22 15:05:26 +00:00
refactor: rename api
This commit is contained in:
@ -298,7 +298,7 @@ public final class DicdataStore {
|
||||
}
|
||||
}
|
||||
// 短期記憶についてはこの位置で処理する
|
||||
for data in self.learningManager.temporaryThroughMatch(charIDs: consume charIDs, depth: 0 ..< .max) {
|
||||
for data in self.learningManager.movingTowardPrefixSearchOnTemporaryMemory(charIDs: consume charIDs, depth: 0 ..< .max) {
|
||||
if info.penalty.isZero {
|
||||
temporaryMemoryDicdata.append(data)
|
||||
}
|
||||
@ -478,7 +478,7 @@ public final class DicdataStore {
|
||||
}
|
||||
if learningManager.enabled {
|
||||
// temporalな学習結果にpenaltyを加えて追加する
|
||||
dicdata.append(contentsOf: self.learningManager.temporaryThroughMatch(charIDs: consume maxIDs, depth: depth))
|
||||
dicdata.append(contentsOf: self.learningManager.movingTowardPrefixSearchOnTemporaryMemory(charIDs: consume maxIDs, depth: depth))
|
||||
}
|
||||
for (key, value) in stringToEndIndex {
|
||||
let convertTarget = String(key)
|
||||
|
@ -584,7 +584,7 @@ struct TemporalLearningMemoryTrie {
|
||||
return nodes[index].dataIndices.map {self.dicdata[$0]}
|
||||
}
|
||||
|
||||
func throughMatch(chars: [UInt8], depth: Range<Int>) -> [DicdataElement] {
|
||||
func movingTowardPrefixSearch(chars: [UInt8], depth: Range<Int>) -> [DicdataElement] {
|
||||
var index = 0
|
||||
var indices: [Int] = []
|
||||
for (offset, char) in chars.enumerated() {
|
||||
@ -718,11 +718,11 @@ final class LearningManager {
|
||||
return self.temporaryMemory.perfectMatch(chars: charIDs)
|
||||
}
|
||||
|
||||
func temporaryThroughMatch(charIDs: [UInt8], depth: Range<Int>) -> [DicdataElement] {
|
||||
func movingTowardPrefixSearchOnTemporaryMemory(charIDs: [UInt8], depth: Range<Int>) -> [DicdataElement] {
|
||||
guard let options, options.learningType.needUsingMemory else {
|
||||
return []
|
||||
}
|
||||
return self.temporaryMemory.throughMatch(chars: charIDs, depth: depth)
|
||||
return self.temporaryMemory.movingTowardPrefixSearch(chars: charIDs, depth: depth)
|
||||
}
|
||||
|
||||
func temporaryPrefixMatch(charIDs: [UInt8]) -> [DicdataElement] {
|
||||
|
@ -27,7 +27,7 @@ final class TemporalLearningMemoryTrieTests: XCTestCase {
|
||||
XCTAssertEqual(result1.first?.word, element1.word)
|
||||
XCTAssertTrue(result1.first?.metadata.contains(.isLearned) ?? false)
|
||||
|
||||
let result2 = trie.throughMatch(chars: chars(for: element2.ruby), depth: (element2.ruby.count - 1)..<element2.ruby.count)
|
||||
let result2 = trie.movingTowardPrefixSearch(chars: chars(for: element2.ruby), depth: (element2.ruby.count - 1)..<element2.ruby.count)
|
||||
XCTAssertEqual(result2.map { $0.word }, [element2.word])
|
||||
|
||||
let prefixResult = trie.prefixMatch(chars: chars(for: "テス"))
|
||||
|
Reference in New Issue
Block a user