blob: 3649e4b2f96060b8f21a3d21cb723feaca127ac9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.intent.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* A node which is not a leaf in the intent tree
*
* @author bratseth
*/
public abstract class ParentNode<T extends Node> extends Node {
private List<T> children=new ArrayList<>();
public ParentNode() {
super(1.0);
}
public ParentNode(double score) {
super(score);
}
/**
* This returns the children of this node in the intent tree.
* This is never null. Children can be added and removed from this list to modify this node.
*/
public List<T> children() { return children; }
@Override void addSources(double weight,Map<Source,SourceNode> sources) {
for (T child : children)
child.addSources(weight*getScore(),sources);
}
}
|