mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +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()) {
|
if (domains.isEmpty()) {
|
||||||
return@write emptyList()
|
return@write emptyList()
|
||||||
}
|
}
|
||||||
|
val primaryDomain = domains.first()
|
||||||
|
|
||||||
val domainWeights = domains
|
val domainWeights = domains
|
||||||
.distinct()
|
.distinct()
|
||||||
@@ -52,7 +53,8 @@ class ContextWorkspace {
|
|||||||
activeBlocks += ResolvedContextBlock(
|
activeBlocks += ResolvedContextBlock(
|
||||||
block = block,
|
block = block,
|
||||||
domainWeight = matchedDomains.sumOf { domainWeights.getValue(it) },
|
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.activationScore }
|
||||||
.thenBy { it.block.blockContent.encodeToXmlString() }
|
.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(
|
private data class ResolvedContextBlock(
|
||||||
val block: ContextBlock,
|
val block: ContextBlock,
|
||||||
val domainWeight: Int,
|
val domainWeight: Int,
|
||||||
val activationScore: Double
|
val activationScore: Double,
|
||||||
|
val forceFullRender: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
data class ContextBlock @JvmOverloads constructor(
|
data class ContextBlock @JvmOverloads constructor(
|
||||||
|
|||||||
Reference in New Issue
Block a user