Class LabelledWithConfidence<T>

Object
LabelledWithConfidence<T>
Type Parameters:
T - element to be associated with a confidence score.
All Implemented Interfaces:
Comparable<LabelledWithConfidence<T>>

public class LabelledWithConfidence<T> extends Object implements Comparable<LabelledWithConfidence<T>>
Like WithConfidence but additionally adds a label.
Author:
Owen Feehan
  • Constructor Details

    • LabelledWithConfidence

      public LabelledWithConfidence(T element, double confidence, String label)
      Create for given element, confidence and label.
      Parameters:
      element - the underlying element with whom a confidence and label is associated.
      confidence - the confidence associated with element.
      label - the label associated with the element.
    • LabelledWithConfidence

      public LabelledWithConfidence(String label, WithConfidence<T> withConfidence)
      Creates a new LabelledWithConfidence instance.
      Parameters:
      label - The label associated with the element.
      withConfidence - The element with associated confidence.
  • Method Details

    • map

      public <S> LabelledWithConfidence<S> map(Function<T,S> transform)
      Maps the existing object to another object, while retaining an identical confidence score.
      Type Parameters:
      S - type to map to
      Parameters:
      transform - converts the existing element into the new type
      Returns:
      a newly created WithConfidence object containing the transformed element but preserving the confidence.
    • getElement

      public T getElement()
      The underlying element with whom a confidence and label is associated.
      Returns:
      the element.
    • getConfidence

      public double getConfidence()
      The confidence associated with element.
      Returns:
      the confidence.
    • compareTo

      public int compareTo(LabelledWithConfidence<T> other)
      Specified by:
      compareTo in interface Comparable<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getLabel

      public String getLabel()
      The label associated with the element.
    • getWithConfidence

      public WithConfidence<T> getWithConfidence()
      The element with associated confidence.