package com.bbn.kbp.events2014.scorer.bin;

import com.bbn.bue.common.parameters.Parameters;
import com.bbn.kbp.events2014.transformers.DeleteInjureForCorrectDie;
import com.bbn.kbp.events2014.transformers.FixLowercaseXInTemporals;
import com.bbn.kbp.events2014.transformers.MakeAllRealisActual;
import com.bbn.kbp.events2014.transformers.MakeBrokenTimesWrong;
import com.bbn.kbp.events2014.transformers.OnlyMostSpecificTemporal;
import com.bbn.kbp.events2014.transformers.ScoringDataTransformation;
import com.bbn.kbp.events2014.transformers.ScoringDataTransformationSequence;

import com.google.common.collect.Lists;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * Created by jdeyoung on 3/23/15.
 */
public final class Preprocessors {
  private static final Logger log = LoggerFactory.getLogger(Preprocessors.class);

  private Preprocessors() {
  }

  public static ScoringDataTransformation for2014FromParameters(Parameters params) {
    final List<ScoringDataTransformation> transformationsInOrder = Lists.newArrayList();

    if (params.getBoolean("neutralizeRealis")) {
      transformationsInOrder.add(MakeAllRealisActual.create());
    }

    // in the original TAC KBP 2014 evaluation the human submission from LDC had temporal values
    // used lowercase "x" instead of "X". These were not caught by the validator and became
    // recall errors for all other systems.  This transformation fixes this.  Note that
    // adding these changes means the scores from the evaluation can no longer be replicated with the current code,
    // but they were slightly wrong anyway.  You can get the older behavior in release 2.2.0.
    transformationsInOrder.add(FixLowercaseXInTemporals.asTransformationForBoth());

    // in the original TAC KBP 2014 evaluation many invalid temporal responses were erroneously
    // assessed as correct. This fixes that. To replicate the evaluation behavior, use release 2.2.0
    // or older
    transformationsInOrder.add(MakeBrokenTimesWrong.create());

    transformationsInOrder.add(DeleteInjureForCorrectDie.asTransformationForBoth());
    transformationsInOrder.add(OnlyMostSpecificTemporal.asTransformationForBoth());

    if (params.getBoolean("attemptToNeutralizeCoref")) {
      log.info("Attempting to neutralize coref");
      transformationsInOrder.add(CorefNeutralizingPreprocessor.create());
    }
    return ScoringDataTransformationSequence.compose(transformationsInOrder);
  }

  public static ScoringDataTransformation for2015FromParameters(Parameters parameters) {
    throw new UnsupportedOperationException("Implement me");
  }
}


@@ -2557,75 +2557,1032 @@
 aram
-eters) %7B%0A    throw new UnsupportedOperationException(%22Implement me%22
+s) %7B%0A    final List%3CScoringDataTransformation%3E transformationsInOrder = Lists.newArrayList();%0A%0A    if (params.getBoolean(%22neutralizeRealis%22)) %7B%0A      transformationsInOrder.add(MakeAllRealisActual.create());%0A    %7D%0A%0A    // in 2015, we no longe rhave mercy on you if you have a bad time format. This should now%0A    // be caught in the validator%0A%0A    // in the original TAC KBP 2014 evaluation many invalid temporal responses were erroneously%0A    // assessed as correct. This is just here in case the LDC misses marking any wrong.%0A    transformationsInOrder.add(MakeBrokenTimesWrong.create());%0A%0A    transformationsInOrder.add(DeleteInjureForCorrectDie.asTransformationForBoth());%0A    transformationsInOrder.add(OnlyMostSpecificTemporal.asTransformationForBoth());%0A%0A    if (params.getBoolean(%22attemptToNeutralizeCoref%22)) %7B%0A      log.info(%22Attempting to neutralize coref%22);%0A      transformationsInOrder.add(CorefNeutralizingPreprocessor.create());%0A    %7D%0A    return ScoringDataTransformationSequence.compose(transformationsInOrder
 );%0A 

Set up preprocessor for 2015 evaluation