Skip to content

Commit

Permalink
feat: #98 To turn the non-standard dictionaries generation on and off…
Browse files Browse the repository at this point in the history
…, use a list of integer dictionary ids instead of separate boolean flags.
  • Loading branch information
dmitry-weirdo committed Nov 28, 2024
1 parent 6286c19 commit 47d4a5e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.apache.logging.log4j.kotlin.Logging
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Component
import ru.klavogonki.common.NonStandardDictionary
import ru.klavogonki.statistics.Config
import ru.klavogonki.statistics.export.vocabulary.non_standard.DigitsOneHundredTopExporter
import ru.klavogonki.statistics.export.vocabulary.non_standard.FrequencyVocabularyTopExporter
Expand Down Expand Up @@ -136,18 +137,47 @@ class StatisticsGenerator : Logging {
export(context, generatorConfig.exportSprintTop, sprintTopExporter)

// non-standard vocabularies exporters
export(context, generatorConfig.exportNormalInEnglishTop, normalInEnglishTopExporter)
export(context, generatorConfig.exportMiniMarathonTop, miniMarathonTopExporter)
export(context, generatorConfig.exportShortTextsTop, shortTextsTopExporter)
export(context, generatorConfig.exportFrequencyVocabularyTop, frequencyVocabularyTopExporter)
export(context, generatorConfig.exportOneHundredRussianTop, oneHundredRussianTopExporter)
export(context, generatorConfig.exportDigitsOneHundredTop, digitsOneHundredTopExporter)
export(context, generatorConfig.exportTrainingIndexFingersTop, trainingIndexFingersTopExporter)
export(context, generatorConfig.exportRingFingersTop, ringFingersTopExporter)
export(context, generatorConfig.exportPinkiesPlusTop, pinkiesPlusTopExporter)
export(context, generatorConfig, NonStandardDictionary.NORMAL_IN_ENGLISH, normalInEnglishTopExporter)
export(context, generatorConfig, NonStandardDictionary.MINI_MARATHON, miniMarathonTopExporter)
export(context, generatorConfig, NonStandardDictionary.SHORT_TEXTS, shortTextsTopExporter)
export(context, generatorConfig, NonStandardDictionary.FREQUENCY_VOCABULARY, frequencyVocabularyTopExporter)
export(context, generatorConfig, NonStandardDictionary.ONE_HUNDRED_RUSSIAN, oneHundredRussianTopExporter)
export(context, generatorConfig, NonStandardDictionary.DIGITS_ONE_HUNDRED, digitsOneHundredTopExporter)
export(context, generatorConfig, NonStandardDictionary.TRAINING_INDEX_FINGERS, trainingIndexFingersTopExporter)
export(context, generatorConfig, NonStandardDictionary.RING_FINGERS, ringFingersTopExporter)
export(context, generatorConfig, NonStandardDictionary.PINKIES_PLUS, pinkiesPlusTopExporter)
}

// todo: think about moving StatisticsGeneratorConfig field determination to Exporter interface
private fun export(
context: ExportContext,
generatorConfig: StatisticsGeneratorConfig,
nonStandardDictionary: NonStandardDictionary,
exporter: DataExporter?
) {
export(
context,
generatorConfig,
nonStandardDictionary.id,
exporter
)
}

private fun export(
context: ExportContext,
generatorConfig: StatisticsGeneratorConfig,
nonStandardDictionaryId: Int,
exporter: DataExporter?
) {
val export = generatorConfig.nonStandardDictionariesCodes.contains(nonStandardDictionaryId)

export(
context,
export,
exporter
)
}

private fun export(
context: ExportContext,
export: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,5 @@ data class StatisticsGeneratorConfig(
val exportSprintTop: Boolean = false,

// non-standard vocabularies
val exportNormalInEnglishTop: Boolean = false,
val exportMiniMarathonTop: Boolean = false,
val exportShortTextsTop: Boolean = false,
val exportFrequencyVocabularyTop: Boolean = false,
val exportOneHundredRussianTop: Boolean = false,
val exportDigitsOneHundredTop: Boolean = false,
val exportTrainingIndexFingersTop: Boolean = false,
val exportRingFingersTop: Boolean = false,
val exportPinkiesPlusTop: Boolean = false
val nonStandardDictionariesCodes: List<Int> = emptyList()
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"exportSprintTop": true,

// non-standard vocabularies
"exportNormalInEnglishTop": true,
"exportMiniMarathonTop": true,
"exportShortTextsTop": true,
"exportFrequencyVocabularyTop": true,
"exportOneHundredRussianTop": true,
"exportDigitsOneHundredTop": true,
"exportTrainingIndexFingersTop": true,
"exportRingFingersTop": true,
"exportPinkiesPlusTop": true
"nonStandardDictionariesCodes": [
5539 //, // Обычный in English,
6018, // Мини-марафон, 800 знаков
1789, // Короткие тексты
192, // Частотный словарь
25856, // Соточка
62238, // Цифросоточка
226, // Тренируем указательные
8223, // Безымянные
3714 // Мизинцы+
]
}

0 comments on commit 47d4a5e

Please sign in to comment.