class HarmonicLoopAltTimeseriesClassifier {

    public int calculateRating(IWeightable weightable, ProgressionUnitBar currentBar, ProgressionUnitBar oneBarPrior, ProgressionUnitBar secondBarPrior) {

        Application.logger.debug("LOG: HarmonicAlt Sequence Weighting ...");

        int rating = 0;

        Iterable<AnalyticsHorizontal> analyticsHorizontals = getAnalyticsHorizontals();

        for (AnalyticsHorizontal analyticsHorizontal : analyticsHorizontals) {

            boolean hasBigram = false;

            for (Integer i = 0; i < analyticsHorizontal.getComposition_time_slots().size(); i++) {

                if (i > 1 && bigramIsNotNull(oneBarPrior, secondBarPrior, analyticsHorizontal, i)) {

                    if (weightable.getId().equals(analyticsHorizontal.getComposition_time_slots().get(i).getHarmonicLoopAltId())
                            && oneBarPrior.getHarmonicLoopAlt().getId().equals(analyticsHorizontal.getComposition_time_slots().get(i - 1).getHarmonicLoopAltId())
                            && secondBarPrior.getHarmonicLoopAlt().getId().equals(analyticsHorizontal.getComposition_time_slots().get(i - 2).getHarmonicLoopAltId())) {

                        rating = SequenceClassiferUtils.incrementBigramRating(analyticsHorizontal.getRating(), rating);

                        hasBigram = true;
                    }
                }
            }

            if (!hasBigram) {

                for (Integer i = 0; i < analyticsHorizontal.getComposition_time_slots().size(); i++) {

                    if (i > 0 && unigramIsNotNull(oneBarPrior, analyticsHorizontal, i)) {

                        if (weightable.getId().equals(analyticsHorizontal.getComposition_time_slots().get(i).getHarmonicLoopAltId())
                                && oneBarPrior.getHarmonicLoopAlt().getId().equals(analyticsHorizontal.getComposition_time_slots().get(i - 1).getHarmonicLoopAltId())) {

                            rating = SequenceClassiferUtils.incrementUnigramRating(analyticsHorizontal.getRating(), rating);
                        }
                    }
                }
            }
        }

        return rating;
    }

    @Autowired public  HarmonicLoopAltTimeseriesClassifier(@Value("${bypass_seqence_ratings}") boolean bypassSeqenceRatings,
                                               @Value("${cache_key_hive_cache}") String cacheKeyHiveCache,
                                               @Value("${cache_key_timeseries}") String cacheKeyTimeseries,
                                               IAnalyticsHorizontalDal analyticsHorizontalDal,
                                               Iterable<AnalyticsHorizontal> analyticsHorizontals);

}