Project sequence evidence through item mappings
This commit is contained in:
@@ -273,8 +273,7 @@ func sequenceHistoryAt(contributions map[string]sequenceHistoryContributionIndex
|
||||
|
||||
type sequenceHistoryContributionIndex struct {
|
||||
sequenceHistoryContribution
|
||||
outputIndexes []int
|
||||
inputIndexes []int
|
||||
projection sequenceItemProjectionIndex
|
||||
replacedOutputs map[int]struct{}
|
||||
}
|
||||
|
||||
@@ -286,26 +285,7 @@ func indexSequenceHistoryContributions(values []sequenceHistoryContribution) map
|
||||
for _, value := range values {
|
||||
contribution := sequenceHistoryContributionIndex{sequenceHistoryContribution: value}
|
||||
if value.mode == sequenceHistoryMapped {
|
||||
maxOutput := -1
|
||||
for _, projection := range value.items {
|
||||
if projection.outputIndex > maxOutput {
|
||||
maxOutput = projection.outputIndex
|
||||
}
|
||||
}
|
||||
contribution.outputIndexes = make([]int, len(value.items))
|
||||
for inputIndex := range contribution.outputIndexes {
|
||||
contribution.outputIndexes[inputIndex] = -1
|
||||
}
|
||||
contribution.inputIndexes = make([]int, maxOutput+1)
|
||||
for outputIndex := range contribution.inputIndexes {
|
||||
contribution.inputIndexes[outputIndex] = -1
|
||||
}
|
||||
for _, projection := range value.items {
|
||||
if projection.inputIndex >= 0 && projection.inputIndex < len(contribution.outputIndexes) && projection.outputIndex >= 0 && projection.outputIndex < len(contribution.inputIndexes) {
|
||||
contribution.outputIndexes[projection.inputIndex] = projection.outputIndex
|
||||
contribution.inputIndexes[projection.outputIndex] = projection.inputIndex
|
||||
}
|
||||
}
|
||||
contribution.projection = newSequenceItemProjectionIndex(value.items)
|
||||
contribution.replacedOutputs = make(map[int]struct{}, len(value.replacements))
|
||||
for _, replacement := range value.replacements {
|
||||
contribution.replacedOutputs[replacement.outputIndex] = struct{}{}
|
||||
@@ -317,17 +297,19 @@ func indexSequenceHistoryContributions(values []sequenceHistoryContribution) map
|
||||
}
|
||||
|
||||
func (contribution sequenceHistoryContributionIndex) outputForInput(inputIndex int) int {
|
||||
if inputIndex < 0 || inputIndex >= len(contribution.outputIndexes) {
|
||||
outputIndex, ok := contribution.projection.outputForInput(inputIndex)
|
||||
if !ok {
|
||||
return -1
|
||||
}
|
||||
return contribution.outputIndexes[inputIndex]
|
||||
return outputIndex
|
||||
}
|
||||
|
||||
func (contribution sequenceHistoryContributionIndex) inputForOutput(outputIndex int) int {
|
||||
if outputIndex < 0 || outputIndex >= len(contribution.inputIndexes) {
|
||||
inputIndex, ok := contribution.projection.inputForOutput(outputIndex)
|
||||
if !ok {
|
||||
return -1
|
||||
}
|
||||
return contribution.inputIndexes[outputIndex]
|
||||
return inputIndex
|
||||
}
|
||||
|
||||
func applySequenceHistory(target **document.Node, incoming *document.Node, contribution sequenceHistoryContributionIndex) {
|
||||
|
||||
Reference in New Issue
Block a user