mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-12-03 02:58:27 +00:00
[Experimental] InputGraphの構造を変更し、LookupGraphによる辞書引きを実装 (#46)
* implement byfix lookup * find failing test * implement backward search * add more test cases * add new file * split files * Improve InputGraph Architecture * implement dictionary search
This commit is contained in:
@@ -125,4 +125,27 @@ extension LOUDS {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/// indexとの対応を維持したバージョン
|
||||
static func getDataForLoudstxt3(_ identifier: String, indices: [Int], option: ConvertRequestOptions) -> [Int: [DicdataElement]] {
|
||||
let binary: Data
|
||||
do {
|
||||
let url = getLoudstxt3URL(identifier, option: option)
|
||||
binary = try Data(contentsOf: url)
|
||||
} catch {
|
||||
debug("getDataForLoudstxt3: \(error)")
|
||||
return [:]
|
||||
}
|
||||
|
||||
let lc = binary[0..<2].toArray(of: UInt16.self)[0]
|
||||
let header_endIndex: UInt32 = 2 + UInt32(lc) * UInt32(MemoryLayout<UInt32>.size)
|
||||
let ui32array = binary[2..<header_endIndex].toArray(of: UInt32.self)
|
||||
var result: [Int: [DicdataElement]] = [:]
|
||||
for index in indices {
|
||||
let startIndex = Int(ui32array[index])
|
||||
let endIndex = index == (lc - 1) ? binary.endIndex : Int(ui32array[index + 1])
|
||||
result[index] = parseBinary(binary: binary[startIndex ..< endIndex])
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user