use of com.joliciel.talismane.machineLearning.features.IntegerLiteralFeature in project talismane by joliciel-informatique.
the class BetweenCountIf method check.
@Override
public FeatureResult<Integer> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
ParseConfiguration configuration = wrapper.getParseConfiguration();
FeatureResult<PosTaggedTokenWrapper> tokenResult1 = addressFunction1.check(wrapper, env);
FeatureResult<PosTaggedTokenWrapper> tokenResult2 = addressFunction2.check(wrapper, env);
FeatureResult<Integer> featureResult = null;
if (tokenResult1 != null && tokenResult2 != null) {
PosTaggedToken posTaggedToken1 = tokenResult1.getOutcome().getPosTaggedToken();
PosTaggedToken posTaggedToken2 = tokenResult2.getOutcome().getPosTaggedToken();
int index1 = posTaggedToken1.getToken().getIndex();
int index2 = posTaggedToken2.getToken().getIndex();
int minIndex = index1 < index2 ? index1 : index2;
int maxIndex = index1 >= index2 ? index1 : index2;
int countMatching = 0;
for (int i = minIndex + 1; i < maxIndex; i++) {
IntegerFeature<ParseConfigurationWrapper> indexFeature = new IntegerLiteralFeature<ParseConfigurationWrapper>(i);
PosTaggedTokenAddressFunction<ParseConfigurationWrapper> indexFunction = new AddressFunctionSequence(indexFeature);
ParseConfigurationAddress parseConfigurationAddress = new ParseConfigurationAddress(configuration, indexFunction, env);
FeatureResult<Boolean> criterionResult = criterion.check(parseConfigurationAddress, env);
if (criterionResult != null && criterionResult.getOutcome())
countMatching++;
}
featureResult = this.generateResult(countMatching);
}
return featureResult;
}
Aggregations