mirror of
https://github.com/slhaf/Partner.git
synced 2026-06-27 17:49:16 +08:00
fix(impression): correct impression update behavior
This commit is contained in:
@@ -33,24 +33,28 @@ class Entity @JvmOverloads constructor(
|
|||||||
): IndexableData = impressionLock.withLock {
|
): IndexableData = impressionLock.withLock {
|
||||||
if (newImpression == null) {
|
if (newImpression == null) {
|
||||||
impressions.computeIfAbsent(impression) { IndexableData(confidence) }
|
impressions.computeIfAbsent(impression) { IndexableData(confidence) }
|
||||||
.also { it.confidence = confidence }
|
.also {
|
||||||
|
it.confidence = confidence
|
||||||
|
if (it.confidence >= 0.9) {
|
||||||
|
featureLock.withLock { features[impression] = it }
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
impressions.remove(impression)
|
impressions.remove(impression)
|
||||||
IndexableData(confidence).also {
|
IndexableData(confidence).also {
|
||||||
impressions[newImpression] = it
|
impressions[newImpression] = it
|
||||||
}
|
if (it.confidence >= 0.9) {
|
||||||
}.also {
|
featureLock.withLock { features[newImpression] = it }
|
||||||
if (it.confidence >= 0.9) {
|
}
|
||||||
featureLock.withLock { features[impression] = it }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateFeature(feature: String, newFeature: String? = null, confidence: Double = 1.0) = featureLock.withLock {
|
fun updateFeature(feature: String, newFeature: String? = null, confidence: Double = 1.0) = featureLock.withLock {
|
||||||
if (newFeature == null) {
|
if (newFeature == null) {
|
||||||
features.computeIfAbsent(feature){ IndexableData(confidence) }
|
features.computeIfAbsent(feature) { IndexableData(confidence) }
|
||||||
.also { it.confidence = confidence }
|
.also { it.confidence = confidence }
|
||||||
}else{
|
} else {
|
||||||
features.remove(feature)
|
features.remove(feature)
|
||||||
IndexableData(confidence).also {
|
IndexableData(confidence).also {
|
||||||
features[newFeature] = it
|
features[newFeature] = it
|
||||||
|
|||||||
Reference in New Issue
Block a user