aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java
blob: 31fdcd22ce5b8e44e9369ca41b51c8d1710acdbf (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
37
38
39
40
41
42
43
44
45
46
47
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.intent.model;

import com.yahoo.text.interpretation.Interpretation;

/**
 * An interpretation which may have multiple intents. The score of this node is the probability of
 * the wrapped interpretation.
 *
 * @author bratseth
 */
public class InterpretationNode extends ParentNode<IntentNode> {

    private Interpretation interpretation;

    public InterpretationNode(Interpretation interpretation) {
        super(0); // Super score is not used
        this.interpretation=interpretation;
        children().add(new IntentNode(Intent.Default,1.0));
    }

    /** Returns this interpretation. This is never null. */
    public Interpretation getInterpretation() { return interpretation; }

    /** Sets this interpretation */
    public void setInterpretation(Interpretation interpretation) {
        this.interpretation=interpretation;
    }

    /** Returns the probability of the interpretation of this */
    @Override
    public double getScore() {
        return interpretation.getProbability();
    }

    /** Sets the probability of the interpretation of this */
    public void setScore(double score) {
        interpretation.setProbability(score);
    }

    /** Returns interpretations toString() */
    @Override
    public String toString() {
        return interpretation.toString();
    }

}