From 72231250ed81e10d66bfe70701e64fa5fe50f712 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Wed, 15 Jun 2016 23:09:44 +0200 Subject: Publish --- .../search/intent/model/InterpretationNode.java | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java (limited to 'container-search/src/main/java/com/yahoo/search/intent/model/InterpretationNode.java') 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 Jon Bratseth + */ +public class InterpretationNode extends ParentNode { + + 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(); + } + +} -- cgit v1.2.3