com.joliciel.talismane.machineLearning.features.MultiplyOperator Maven / Gradle / Ivy
///////////////////////////////////////////////////////////////////////////////
//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.
*
* @author Assaf Urieli
*
*/
public class MultiplyOperator extends AbstractCachableFeatureimplements DoubleFeature {
private DoubleFeature operand1;
private DoubleFeature operand2;
public MultiplyOperator(DoubleFeature operand1, DoubleFeature 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);
FeatureResult operand2Result = operand2.check(context, env);
if (operand1Result != null && operand2Result != null) {
double result = operand1Result.getOutcome() * operand2Result.getOutcome();
featureResult = this.generateResult(result);
}
return featureResult;
}
public DoubleFeature getOperand1() {
return operand1;
}
public DoubleFeature getOperand2() {
return operand2;
}
public void setOperand1(DoubleFeature operand1) {
this.operand1 = operand1;
}
public void setOperand2(DoubleFeature operand2) {
this.operand2 = operand2;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy