This commit is contained in:
ensan-hcl
2023-09-23 01:52:22 +09:00
parent 958593dccb
commit b38e6b6fa4
6 changed files with 11 additions and 13 deletions

View File

@@ -36,7 +36,7 @@ public enum CIDData: Sendable {
case .EOS: return 1316
}
}
public static func isJoshi(cid: Int) -> Bool {
return 147 <= cid && cid <= 368
}

View File

@@ -10,4 +10,4 @@ public struct ConversionResult: Sendable {
public var mainResults: [Candidate]
///
public var firstClauseResults: [Candidate]
}
}

View File

@@ -144,7 +144,6 @@ import SwiftUtils
return result
}
///
/// - Parameters:
/// - inputData:
@@ -622,7 +621,7 @@ import SwiftUtils
return self.processResult(inputData: inputData, result: result, options: options)
}
///
public func requestPredictionCandidates(leftSideCandidate: Candidate, options: ConvertRequestOptions) -> [PredictionCandidate] {
//
@@ -646,7 +645,7 @@ import SwiftUtils
}
}
}
//
let predictionResults = self.converter.getPredictionCandidates(prepart: leftSideCandidate, N_best: 15)
//
@@ -659,16 +658,16 @@ import SwiftUtils
}
}
emojiCandidates = self.getUniquePredictionCandidate(emojiCandidates)
var results: [PredictionCandidate] = []
var seenCandidates: Set<String> = []
results.append(contentsOf: emojiCandidates.suffix(3))
seenCandidates.formUnion(emojiCandidates.suffix(3).map{$0.text})
seenCandidates.formUnion(emojiCandidates.suffix(3).map {$0.text})
let predictions = self.getUniquePredictionCandidate(predictionResults, seenCandidates: seenCandidates).min(count: (10 - results.count) / 2, sortedBy: {$0.value > $1.value})
results.append(contentsOf: predictions)
seenCandidates.formUnion(predictions.map{$0.text})
seenCandidates.formUnion(predictions.map {$0.text})
let zeroHints = self.getUniquePredictionCandidate(zeroHintResults, seenCandidates: seenCandidates)
results.append(contentsOf: zeroHints.min(count: 10 - results.count, sortedBy: {$0.value > $1.value}))

View File

@@ -54,19 +54,18 @@ extension Kana2Kanji {
prefixCandidate.value -= self.dicdataStore.getMMValue(previousMid, element.mid)
}
prefixCandidate.data = prefixCandidateData
prefixCandidate.text = prefixCandidateData.reduce(into: "") { $0 += $1.word }
prefixCandidate.correspondingCount = prefixCandidateData.reduce(into: 0) { $0 += $1.ruby.count }
}
totalWord.insert(contentsOf: element.word, at: totalWord.startIndex)
totalRuby.insert(contentsOf: element.ruby, at: totalRuby.startIndex)
totalData.insert(element, at: 0)
let dicdata = self.dicdataStore.getPredictionLOUDSDicdata(key: totalRuby).filter {
DicdataStore.predictionUsable[$0.rcid] && $0.word.hasPrefix(totalWord)
}
for data in dicdata {
let ccValue = self.dicdataStore.getCCValue(prefixCandidateData.last?.rcid ?? CIDData.BOS.cid, data.lcid)
let includeMMValueCalculation = DicdataStore.includeMMValueCalculation(data)

View File

@@ -18,7 +18,7 @@ public struct PredictionCandidate {
self.isTerminal = false
}
}
public var text: String
public var value: PValue
public var type: PredictionType