Class CognateQlt

  • All Implemented Interfaces:
    Querylet

    public final class CognateQlt
    extends TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
    A Cognate querylet for matching several related text fields where values may be entered into a wrong field.
    • Constructor Summary

      Constructors 
      Constructor Description
      CognateQlt​(int[] fieldIndexes, double[] fieldWeights, double nonCogWeight, java.util.List<java.lang.String> allFields)
      Creates cognate querylet with given parameters.
      CognateQlt​(int[] fieldIndexes, double nonCogWeight, java.util.List<java.lang.String> allFields)
      Default field weights 1.0 are used.
    • Constructor Detail

      • CognateQlt

        public CognateQlt​(int[] fieldIndexes,
                          double[] fieldWeights,
                          double nonCogWeight,
                          java.util.List<java.lang.String> allFields)
        Creates cognate querylet with given parameters.
        Parameters:
        fieldIndexes - must contain only indexes from the list of all fields (which was passed to the constructor). A fieldIndex parameter in other methods refers to the number and order of the fields given here in fieldIndexes.
        fieldWeights - - the weights for each field in the querylet. May be null to set default weight 1.0.
        nonCogWeight - - non-cognate weight applied when a value is entered in a wrong field.
        allFields - - all non-key fields in the data table.
        Throws:
        java.lang.IllegalArgumentException - if 2 or more field indexes are not provided, or if an incorrect number of field weights is provided, or a weight value is invalid, or if no fields are specified in allFields.
      • CognateQlt

        public CognateQlt​(int[] fieldIndexes,
                          double nonCogWeight,
                          java.util.List<java.lang.String> allFields)
        Default field weights 1.0 are used.
        See Also:
        CognateQlt(int[], double[], double, List)
    • Method Detail

      • setFields

        public void setFields​(int[] fieldIndexes,
                              double[] fieldWeights)
        Replaces the list of fields in the querylet.
        Specified by:
        setFields in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Parameters:
        fieldIndexes - must contain only indexes from the list of all fields (which was passed to the constructor). A fieldIndex parameter in other methods refers to the number and order of the fields given here in fieldIndexes.
        fieldWeights - - the weights for each field in the querylet. May be null to set default weight 1.0.
        Throws:
        java.lang.IllegalArgumentException - if 2 or more field indexes are not provided, or if an incorrect number of field weights is provided, or a weight value is invalid.
      • getNetricsQlt

        public com.netrics.likeit.NetricsQuery getNetricsQlt​(java.lang.String[] values)
        Description copied from interface: Querylet
        Constructs a NetricsQuery querylet from the stored XML structure and the given field values. The NetricsQuery can then be used to obtain a feature score from the Patterns server. The querylet must use symmetric score type (if it is supported by the NetricsQuery type that it constructs).
        Parameters:
        values - - The values of all non-key fields in the record. The index of the field value to be used is determined by the field name that is read from the list of all fields stored in XML querylet structure.
        Returns:
        the constructed NetricsQuery querylet.
        Throws:
        java.lang.IllegalArgumentException - if incorrect number of table field values is provided.
      • getFieldNames

        public java.util.List<java.lang.String> getFieldNames()
        Returns:
        a list with names of all fields used in the querylet.
      • asJavaCode

        public java.lang.String asJavaCode​(java.lang.String qltVarName,
                                           java.lang.String valuesVarName,
                                           java.lang.String fieldNamesVarName)
        Description copied from interface: Querylet
        Converts the querylet to a Java code string. Parameters are variable names in Java code. The new querylet must be assigned to qltVarName, then additional Java statements can be added to configure the querylet. The generated querylet must use symmetric score type (if it is supported by the NetricsQuery type that it constructs).
        Parameters:
        qltVarName - - the name of the variable to which the querylet is assigned.
        valuesVarName - - name of variable of type String[] that stores field values.
        fieldNamesVarName - - name of variable of type List<String> that stores all field names in the data table.
        Returns:
        a string with Java code that creates the given querylet.
      • setFieldWeight

        public void setFieldWeight​(int fieldIndex,
                                   double weight)
        Description copied from class: TextQlt
        Sets the weight of the given field.
        Specified by:
        setFieldWeight in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Parameters:
        fieldIndex - - index of the field in the list of fields assigned to this querylet.
        weight - - the new field weight.
      • getFieldWeight

        public double getFieldWeight​(int fieldIndex)
        Specified by:
        getFieldWeight in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Parameters:
        fieldIndex - - index of the field in the list of fields assigned to this querylet.
        Returns:
        the weight of the given field.
      • setMatchEmpty

        public void setMatchEmpty​(boolean value)
        Description copied from class: TextQlt
        Sets the Match Empty parameter. If this is true, matching two empty strings results in an exact match score. If false (default), this results in an empty score.
        Specified by:
        setMatchEmpty in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Parameters:
        value - - the value of the Match Empty parameter.
      • isMatchEmpty

        public java.lang.Boolean isMatchEmpty()
        Specified by:
        isMatchEmpty in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Returns:
        the Match Empty parameter, or null if it was not set and the default is used.
        See Also:
        TextQlt.setMatchEmpty(boolean)
      • setNonCognateWeight

        public void setNonCognateWeight​(double weight)
        Sets non-cognate weight applied when a value is entered in a wrong field.
      • getNonCognateWeight

        public double getNonCognateWeight()
        Gets non-cognate weight applied when a value is entered in a wrong field.
      • setEmptyFieldPenalty

        public void setEmptyFieldPenalty​(double penalty)
        Sets empty field penalty. It is applied to unmatched data that could be attributed to an empty field. A default penalty of 1.0 means the match score is fully penalized for the unmatched data. A penalty of 0.0 means the unmatched data is ignored.
      • getEmptyFieldPenalty

        public java.lang.Double getEmptyFieldPenalty()
        Gets the empty field penalty. See setEmptyFieldPenalty(double).
        Returns:
        the empty field penalty, or null if the default penalty is used.
      • hasThesaurus

        public boolean hasThesaurus()
        Specified by:
        hasThesaurus in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Returns:
        true if thesaurus has been assigned to this querylet.
      • getThesaurusName

        public java.lang.String getThesaurusName()
        Specified by:
        getThesaurusName in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Returns:
        thesaurus name, or null if thesaurus is not assigned
      • getThesaurusWeight

        public double getThesaurusWeight()
        Specified by:
        getThesaurusWeight in class TextQlt<com.tibco.patterns.learn.jaxb.model.CognateQueryType>
        Returns:
        thesaurus weight, or default weight if thesaurus is not assigned. getThesaurusName() should be used first to check if the thesaurus is assigned.