diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java b/container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java new file mode 100644 index 00000000000..51e5d00c563 --- /dev/null +++ b/container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java @@ -0,0 +1,45 @@ +// Copyright 2016 Yahoo Inc. 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 <a href="mailto:bratseth@yahoo-inc.com">Jon Bratseth</a> + */ +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 */ + public @Override double getScore() { + return interpretation.getProbability(); + } + + /** Sets the probability of the interpretation of this */ + public void setScore(double score) { + interpretation.setProbability(score); + } + + /** Returns interpretations toString() */ + public @Override String toString() { + return interpretation.toString(); + } + +} |