@Test public void calculateRatingUnigramPlusBigramShouldBe3() { mockDal = Mockito.mock(IAnalyticsHorizontalDal.class); AnalyticsHorizontal analyticsHorizontal = new AnalyticsHorizontal(); analyticsHorizontal.setId(1); analyticsHorizontal.setRating(2); CompositionTimeSlot TS1 = new CompositionTimeSlot() {{ setHarmonicLoopAltId(4); }}; TS1.setId(1); CompositionTimeSlot TS2 = new CompositionTimeSlot() {{ setHarmonicLoopAltId(2); }}; TS2.setId(2); CompositionTimeSlot TS3 = new CompositionTimeSlot() {{ setHarmonicLoopAltId(3); }}; TS3.setId(3); CompositionTimeSlot TS4 = new CompositionTimeSlot() {{ setHarmonicLoopAltId(4); }}; TS4.setId(4); List<CompositionTimeSlot> timeSlots = new ArrayList<>(); timeSlots.add(TS1); timeSlots.add(TS2); timeSlots.add(TS3); timeSlots.add(TS4); AnalyticsHorizontal analyticsHorizontal2 = new AnalyticsHorizontal(); analyticsHorizontal2.setId(1); analyticsHorizontal2.setRating(2); CompositionTimeSlot TS1B = new CompositionTimeSlot() {{ setHarmonicLoopAltId(1); }}; TS1B.setId(1); CompositionTimeSlot TS2B = new CompositionTimeSlot() {{ setHarmonicLoopAltId(2); }}; TS2B.setId(2); CompositionTimeSlot TS3B = new CompositionTimeSlot() {{ setHarmonicLoopAltId(3); }}; TS3B.setId(3); CompositionTimeSlot TS4B = new CompositionTimeSlot() {{ setHarmonicLoopAltId(4); }}; TS4B.setId(4); List<CompositionTimeSlot> timeSlotsB = new ArrayList<>(); timeSlotsB.add(TS1B); timeSlotsB.add(TS2B); timeSlotsB.add(TS3B); timeSlotsB.add(TS4B); analyticsHorizontal.setComposition_time_slots(timeSlots); analyticsHorizontal2.setComposition_time_slots(timeSlotsB); List<AnalyticsHorizontal> mockList = new ArrayList<>(); mockList.add(analyticsHorizontal); mockList.add(analyticsHorizontal2); Iterable<AnalyticsHorizontal> mockIterable = mockList; Mockito.when(mockDal.findAll()).thenReturn(mockIterable); harmonicLoopAltTimeseriesClassifier = new HarmonicLoopAltTimeseriesClassifier(false, "", "", mockDal, mockIterable); HarmonicLoop pbWeightable = new HarmonicLoop(); pbWeightable.setId(3); ProgressionUnitBar pbCurrent = new ProgressionUnitBar(); pbCurrent.setHarmonicLoopAlt(new HarmonicLoop() {{ setId(3); }}); ProgressionUnitBar pbPrior = new ProgressionUnitBar(); pbPrior.setHarmonicLoopAlt(new HarmonicLoop() {{ setId(2); }}); ProgressionUnitBar pbTwoPrior = new ProgressionUnitBar(); pbTwoPrior.setHarmonicLoopAlt(new HarmonicLoop() {{ setId(1); }}); int rating = harmonicLoopAltTimeseriesClassifier.calculateRating(pbWeightable, pbCurrent, pbPrior, pbTwoPrior); Assert.assertEquals(3, rating); }
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; }
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; } }
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  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); }
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  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); WeightClass classify(IWeightable weightable, ProgressionUnitBar currentBar, ProgressionUnitBar oneBarPrior, ProgressionUnitBar secondBarPrior); int calculateRating(IWeightable weightable, ProgressionUnitBar currentBar, ProgressionUnitBar oneBarPrior, ProgressionUnitBar secondBarPrior); }
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  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); WeightClass classify(IWeightable weightable, ProgressionUnitBar currentBar, ProgressionUnitBar oneBarPrior, ProgressionUnitBar secondBarPrior); int calculateRating(IWeightable weightable, ProgressionUnitBar currentBar, ProgressionUnitBar oneBarPrior, ProgressionUnitBar secondBarPrior);  }