All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.joliciel.talismane.machineLearning.features.EqualsOperatorForBoolean Maven / Gradle / Ivy

There is a newer version: 6.1.8
Show newest version
///////////////////////////////////////////////////////////////////////////////
//Copyright (C) 2014 Joliciel Informatique
//
//This file is part of Talismane.
//
//Talismane is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//Talismane is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with Talismane.  If not, see .
//////////////////////////////////////////////////////////////////////////////
package com.joliciel.talismane.machineLearning.features;

import com.joliciel.talismane.TalismaneException;

/**
 * Returns operand1 == operand2. For double values, an error margin of 0.0001 is
 * allowed.
 * 
 * @author Assaf Urieli
 *
 */
public class EqualsOperatorForBoolean extends AbstractCachableFeatureimplements BooleanFeature {
  private BooleanFeature operand1;
  private BooleanFeature operand2;

  public EqualsOperatorForBoolean(BooleanFeature operand1, BooleanFeature operand2) {
    super();
    this.operand1 = operand1;
    this.operand2 = operand2;
    this.setName(operand1.getName() + "==" + operand2.getName());
  }

  @Override
  protected FeatureResult checkInternal(T context, RuntimeEnvironment env) throws TalismaneException {
    FeatureResult featureResult = null;

    FeatureResult operand1Result = operand1.check(context, env);
    if (operand1Result != null) {
      FeatureResult operand2Result = operand2.check(context, env);

      if (operand2Result != null) {
        boolean result = operand1Result.getOutcome().equals(operand2Result.getOutcome());
        featureResult = this.generateResult(result);
      }
    }

    return featureResult;

  }

  public BooleanFeature getOperand1() {
    return operand1;
  }

  public BooleanFeature getOperand2() {
    return operand2;
  }

  public void setOperand1(BooleanFeature operand1) {
    this.operand1 = operand1;
  }

  public void setOperand2(BooleanFeature operand2) {
    this.operand2 = operand2;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy