use of org.talend.dataquality.indicators.SoundexFreqIndicator in project tdq-studio-se by Talend.
the class SoundexFreqIndicatorImplTest method testHandleObject_2.
/**
* when do not UsedMapDBMode Test method for
* {@link org.talend.dataquality.indicators.impl.SoundexFreqIndicatorImpl#handle(java.lang.Object)}.
*/
@Test
public void testHandleObject_2() {
Object empty = null;
// java case
SoundexFreqIndicator soundexFreqIndicator = IndicatorsFactory.eINSTANCE.createSoundexFreqIndicator();
((SoundexFreqIndicatorImpl) soundexFreqIndicator).setUsedMapDBMode(false);
soundexFreqIndicator.reset();
soundexFreqIndicator.handle(empty);
// $NON-NLS-1$
soundexFreqIndicator.handle("mac");
// $NON-NLS-1$
soundexFreqIndicator.handle("mic");
soundexFreqIndicator.handle(empty);
// $NON-NLS-1$
soundexFreqIndicator.handle("mic");
// $NON-NLS-1$
soundexFreqIndicator.handle("mac");
// $NON-NLS-1$
soundexFreqIndicator.handle("machine");
soundexFreqIndicator.handle(empty);
// $NON-NLS-1$
soundexFreqIndicator.handle("machine");
// $NON-NLS-1$
soundexFreqIndicator.handle("unique");
soundexFreqIndicator.finalizeComputation();
Assert.assertEquals(false, soundexFreqIndicator.getUniqueValues().isEmpty());
Assert.assertEquals(1, soundexFreqIndicator.getUniqueValues().size());
// $NON-NLS-1$
Assert.assertEquals(2, soundexFreqIndicator.getValueToDistinctFreq().get("mic").intValue());
// $NON-NLS-1$
Assert.assertNull(soundexFreqIndicator.getValueToDistinctFreq().get("Null field"));
// $NON-NLS-1$
Assert.assertEquals(1, soundexFreqIndicator.getValueToDistinctFreq().get("machine").intValue());
// $NON-NLS-1$
Assert.assertEquals(1, soundexFreqIndicator.getValueToDistinctFreq().get("unique").intValue());
// $NON-NLS-1$
Assert.assertEquals(4, soundexFreqIndicator.getValueToFreq().get("mic").intValue());
// $NON-NLS-1$
Assert.assertNull(soundexFreqIndicator.getValueToDistinctFreq().get("Null field"));
// $NON-NLS-1$
Assert.assertEquals(2, soundexFreqIndicator.getValueToFreq().get("machine").intValue());
// $NON-NLS-1$
Assert.assertEquals(1, soundexFreqIndicator.getValueToDistinctFreq().get("unique").intValue());
}
use of org.talend.dataquality.indicators.SoundexFreqIndicator in project tdq-studio-se by Talend.
the class SoundexFreqIndicatorImplTest method testHandleObject_1.
/**
* when UsedMapDBMode Test method for
* {@link org.talend.dataquality.indicators.impl.SoundexFreqIndicatorImpl#handle(java.lang.Object)}.
*/
@Test
public void testHandleObject_1() {
Object empty = null;
// mapDB case
SoundexFreqIndicator soundexFreqIndicator = IndicatorsFactory.eINSTANCE.createSoundexFreqIndicator();
((SoundexFreqIndicatorImpl) soundexFreqIndicator).setUsedMapDBMode(true);
ResourceUtils.createAnalysis(soundexFreqIndicator);
soundexFreqIndicator.reset();
soundexFreqIndicator.handle(empty);
// $NON-NLS-1$
soundexFreqIndicator.handle("mac");
// $NON-NLS-1$
soundexFreqIndicator.handle("mic");
soundexFreqIndicator.handle(empty);
// $NON-NLS-1$
soundexFreqIndicator.handle("mic");
// $NON-NLS-1$
soundexFreqIndicator.handle("mac");
// $NON-NLS-1$
soundexFreqIndicator.handle("machine");
soundexFreqIndicator.handle(empty);
// $NON-NLS-1$
soundexFreqIndicator.handle("machine");
// $NON-NLS-1$
soundexFreqIndicator.handle("unique");
soundexFreqIndicator.finalizeComputation();
Assert.assertEquals(true, soundexFreqIndicator.getUniqueValues().isEmpty());
// $NON-NLS-1$
Assert.assertEquals(2, soundexFreqIndicator.getValueToDistinctFreq().get("mic").intValue());
Assert.assertEquals(0, soundexFreqIndicator.getValueToDistinctFreq().get(empty).intValue());
// $NON-NLS-1$
Assert.assertEquals(1, soundexFreqIndicator.getValueToDistinctFreq().get("machine").intValue());
// $NON-NLS-1$
Assert.assertEquals(1, soundexFreqIndicator.getValueToDistinctFreq().get("unique").intValue());
// $NON-NLS-1$
Assert.assertEquals(4, soundexFreqIndicator.getValueToFreq().get("mic").intValue());
Assert.assertEquals(3, soundexFreqIndicator.getValueToFreq().get(empty).intValue());
// $NON-NLS-1$
Assert.assertEquals(2, soundexFreqIndicator.getValueToFreq().get("machine").intValue());
// $NON-NLS-1$
Assert.assertEquals(1, soundexFreqIndicator.getValueToFreq().get("unique").intValue());
}
use of org.talend.dataquality.indicators.SoundexFreqIndicator in project tdq-studio-se by Talend.
the class IndicatorCommonUtil method handleFrequency.
/**
* DOC xqliu Comment method "handleFrequency".
*
* @param indicator
* @return
*/
private static Object handleFrequency(Indicator indicator) {
FrequencyExt[] frequencyExt = null;
if (UDIHelper.isUDI(indicator)) {
UserDefIndicator udi = (UserDefIndicator) indicator;
Set<Object> valueSet = udi.getDistinctValues();
if (valueSet == null) {
return null;
}
frequencyExt = new FrequencyExt[valueSet.size()];
int i = 0;
for (Object o : valueSet) {
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(o);
frequencyExt[i].setValue(udi.getCount(o));
frequencyExt[i].setFrequency(udi.getFrequency(o));
i++;
}
} else if (IndicatorEnum.DatePatternFreqIndicatorEnum.getIndicatorType().isInstance(indicator)) {
DatePatternFreqIndicator datePatternFrequency = (DatePatternFreqIndicator) indicator;
Map<String, Long> results = datePatternFrequency.getResult();
frequencyExt = new FrequencyExt[results.size()];
int i = 0;
for (String key : results.keySet()) {
Long value = results.get(key);
Double frequency = datePatternFrequency.getFrequency(key);
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(key);
frequencyExt[i].setValue(value);
frequencyExt[i].setFrequency(frequency);
i++;
}
} else {
FrequencyIndicator frequency = (FrequencyIndicator) indicator;
Set<Object> valueSet = frequency.getDistinctValues();
if (valueSet == null) {
return null;
}
frequencyExt = new FrequencyExt[valueSet.size()];
int i = 0;
for (Object o : valueSet) {
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(o);
if (IndicatorsPackage.eINSTANCE.getSoundexFreqIndicator().equals(frequency.eClass()) || IndicatorsPackage.eINSTANCE.getSoundexLowFreqIndicator().equals(frequency.eClass())) {
// MOD scorreia 2009-03-23 display distinct count when working with Soundex
frequencyExt[i].setValue(((SoundexFreqIndicator) frequency).getDistinctCount(o));
} else {
frequencyExt[i].setValue(frequency.getCount(o));
}
frequencyExt[i].setFrequency(frequency.getFrequency(o));
i++;
}
}
return frequencyExt;
}
use of org.talend.dataquality.indicators.SoundexFreqIndicator in project tdq-studio-se by Talend.
the class IndicatorParametersImplTest method testEBasicSetContainerInternalEObjectInt.
/**
* Test method for
* {@link org.talend.dataquality.indicators.impl.IndicatorParametersImpl#eBasicSetContainer(org.eclipse.emf.ecore.InternalEObject, int)}
* .
*/
@Test
public void testEBasicSetContainerInternalEObjectInt() {
IndicatorDefaultValueServiceUtil.getIstance().getIndicatorDVService().setFrequencyLimitResult(FREQUENCYRESULTLIMIT);
IndicatorDefaultValueServiceUtil.getIstance().getIndicatorDVService().setLowFrequencyLimitResult(LOWFREQUENCYRESULTLIMIT);
// freqyency value indicator
FrequencyIndicator createFrequencyIndicator = IndicatorsFactory.eINSTANCE.createFrequencyIndicator();
createFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createFrequencyIndicator.getParameters().getTopN());
// low freqyency value indicator
LowFrequencyIndicator createLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createLowFrequencyIndicator();
createLowFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createLowFrequencyIndicator.getParameters().getTopN());
// date freqyency value indicator
DateFrequencyIndicator createDateFrequencyIndicator = IndicatorsFactory.eINSTANCE.createDateFrequencyIndicator();
createDateFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createDateFrequencyIndicator.getParameters().getTopN());
// date low freqyency value indicator
DateLowFrequencyIndicator createDateLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createDateLowFrequencyIndicator();
createDateLowFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createDateLowFrequencyIndicator.getParameters().getTopN());
// week freqyency value indicator
WeekFrequencyIndicator createWeekFrequencyIndicator = IndicatorsFactory.eINSTANCE.createWeekFrequencyIndicator();
createWeekFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createWeekFrequencyIndicator.getParameters().getTopN());
// week low freqyency value indicator
WeekLowFrequencyIndicator createWeekLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createWeekLowFrequencyIndicator();
createWeekLowFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createWeekLowFrequencyIndicator.getParameters().getTopN());
// Month freqyency value indicator
MonthFrequencyIndicator createMonthFrequencyIndicator = IndicatorsFactory.eINSTANCE.createMonthFrequencyIndicator();
createMonthFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createMonthFrequencyIndicator.getParameters().getTopN());
// Month low freqyency value indicator
MonthLowFrequencyIndicator createMonthLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createMonthLowFrequencyIndicator();
createMonthLowFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createMonthLowFrequencyIndicator.getParameters().getTopN());
// quarter freqyency value indicator
QuarterFrequencyIndicator createQuarterFrequencyIndicator = IndicatorsFactory.eINSTANCE.createQuarterFrequencyIndicator();
createQuarterFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createQuarterFrequencyIndicator.getParameters().getTopN());
// quarter low freqyency value indicator
QuarterLowFrequencyIndicator createQuarterLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createQuarterLowFrequencyIndicator();
createQuarterLowFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createQuarterLowFrequencyIndicator.getParameters().getTopN());
// year freqyency value indicator
YearFrequencyIndicator createYearFrequencyIndicator = IndicatorsFactory.eINSTANCE.createYearFrequencyIndicator();
createYearFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createYearFrequencyIndicator.getParameters().getTopN());
// year low freqyency value indicator
YearLowFrequencyIndicator createYearLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createYearLowFrequencyIndicator();
createYearLowFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createYearLowFrequencyIndicator.getParameters().getTopN());
// bin freqyency value indicator
BinFrequencyIndicator createBinFrequencyIndicator = IndicatorsFactory.eINSTANCE.createBinFrequencyIndicator();
createBinFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createBinFrequencyIndicator.getParameters().getTopN());
// bin low freqyency value indicator
BinLowFrequencyIndicator createBinLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createBinLowFrequencyIndicator();
createBinLowFrequencyIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createBinLowFrequencyIndicator.getParameters().getTopN());
// pattern freqyency value indicator
PatternFreqIndicator createPatternFreqIndicator = IndicatorsFactory.eINSTANCE.createPatternFreqIndicator();
createPatternFreqIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createPatternFreqIndicator.getParameters().getTopN());
// pattern low freqyency value indicator
PatternLowFreqIndicator createPatternLowFreqIndicator = IndicatorsFactory.eINSTANCE.createPatternLowFreqIndicator();
createPatternLowFreqIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createPatternLowFreqIndicator.getParameters().getTopN());
// east asia freqyency value indicator
EastAsiaPatternFreqIndicator createEastAsiaPatternFreqIndicator = IndicatorsFactory.eINSTANCE.createEastAsiaPatternFreqIndicator();
createEastAsiaPatternFreqIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createEastAsiaPatternFreqIndicator.getParameters().getTopN());
// east asia low freqyency value indicator
EastAsiaPatternLowFreqIndicator createEastAsiaPatternLowFreqIndicator = IndicatorsFactory.eINSTANCE.createEastAsiaPatternLowFreqIndicator();
createEastAsiaPatternLowFreqIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createEastAsiaPatternLowFreqIndicator.getParameters().getTopN());
// soundex freqyency value indicator
SoundexFreqIndicator createSoundexFreqIndicator = IndicatorsFactory.eINSTANCE.createSoundexFreqIndicator();
createSoundexFreqIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createSoundexFreqIndicator.getParameters().getTopN());
// soundex low freqyency value indicator
SoundexLowFreqIndicator createSoundexLowFreqIndicator = IndicatorsFactory.eINSTANCE.createSoundexLowFreqIndicator();
createSoundexLowFreqIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(LOWFREQUENCYRESULTLIMIT, createSoundexLowFreqIndicator.getParameters().getTopN());
// Date pattern freqyency value indicator
DatePatternFreqIndicator createDatePatternFreqIndicator = IndicatorsFactory.eINSTANCE.createDatePatternFreqIndicator();
createDatePatternFreqIndicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
Assert.assertEquals(FREQUENCYRESULTLIMIT, createDatePatternFreqIndicator.getParameters().getTopN());
}
Aggregations