mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(context): forces the context of the first domain hit to be fully expanded to adapt to the context focus needs within the module
This commit is contained in:
@@ -28,6 +28,7 @@ class ContextWorkspace {
|
||||
if (domains.isEmpty()) {
|
||||
return@write emptyList()
|
||||
}
|
||||
val primaryDomain = domains.first()
|
||||
|
||||
val domainWeights = domains
|
||||
.distinct()
|
||||
@@ -52,7 +53,8 @@ class ContextWorkspace {
|
||||
activeBlocks += ResolvedContextBlock(
|
||||
block = block,
|
||||
domainWeight = matchedDomains.sumOf { domainWeights.getValue(it) },
|
||||
activationScore = activationScore
|
||||
activationScore = activationScore,
|
||||
forceFullRender = primaryDomain in matchedDomains
|
||||
)
|
||||
}
|
||||
|
||||
@@ -64,7 +66,13 @@ class ContextWorkspace {
|
||||
.thenBy { it.activationScore }
|
||||
.thenBy { it.block.blockContent.encodeToXmlString() }
|
||||
)
|
||||
.map { it.block.render() }
|
||||
.map { resolved ->
|
||||
if (resolved.forceFullRender) {
|
||||
resolved.block.blockContent
|
||||
} else {
|
||||
resolved.block.render()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +109,8 @@ class ContextWorkspace {
|
||||
private data class ResolvedContextBlock(
|
||||
val block: ContextBlock,
|
||||
val domainWeight: Int,
|
||||
val activationScore: Double
|
||||
val activationScore: Double,
|
||||
val forceFullRender: Boolean
|
||||
)
|
||||
|
||||
data class ContextBlock @JvmOverloads constructor(
|
||||
|
||||
Reference in New Issue
Block a user