From 90fbd47ca02f1a723134302ca978a7f9ef0eac04 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 2 Dec 2023 17:03:54 -0500 Subject: Starting to get some puzzles randomized --- generator/generator.h | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 generator/generator.h (limited to 'generator/generator.h') diff --git a/generator/generator.h b/generator/generator.h new file mode 100644 index 0000000..a97b0b0 --- /dev/null +++ b/generator/generator.h @@ -0,0 +1,114 @@ +#ifndef GENERATOR_H_D5C6A724 +#define GENERATOR_H_D5C6A724 + +#include +#include +#include +#include +#include + +enum PuzzleType { + kWhiteTop = 0, + kWhiteBottom = 1, + kYellowTop = 2, + kYellowMiddle = 3, + kBlackTop = 4, + kBlackMiddle = 5, +}; + +class generator { + public: + // Constructor + + generator(std::string agidPath, std::string wordNetPath, + std::string cmudictPath, std::string wordfreqPath, + std::string outputPath); + + // Action + + void run(); + + private: + // Helpers + + size_t LookupOrCreatePronunciation(const std::string& phonemes); + + size_t LookupOrCreateForm(const std::string& form); + + size_t LookupOrCreateWord(const std::string& word); + + void AddPronunciationToForm(size_t pronunciation_id, size_t form_id); + + void AddFormToWord(size_t form_id, size_t word_id); + + void AddWordToSynset(size_t word_id, int wnid); + + void AddFormToAnagramSet(size_t form_id, const std::string& sorted_letters); + + void AddPronunciationToAnaphoneSet(size_t pronunciation_id, + const std::string& sorted_phonemes); + + // Input + + std::string agidPath_; + std::string wordNetPath_; + std::string cmudictPath_; + std::string wordfreqPath_; + + // Output + + std::string outputPath_; + + // Indexes + + struct Pronunciation { + size_t id; + std::string phonemes; + std::string prerhyme; + std::string rhyme; + std::vector form_ids; + std::optional anaphone_set_id; + std::string stressless_phonemes; + }; + + struct Form { + size_t id; + std::string text; + std::vector word_ids; + std::vector pronunciation_ids; + std::optional anagram_set_id; + std::optional reverse_form_id; + + std::unordered_map> puzzles; + }; + + struct Word { + size_t id; + size_t base_form_id; + std::vector form_ids; + std::vector synsets; + }; + + std::vector pronunciations_; + std::unordered_map pronunciation_by_phonemes_; + std::unordered_map> pronunciations_by_rhyme_; + std::unordered_map> + pronunciations_by_blank_phonemes_; + + std::vector> anaphone_sets_; + std::unordered_map anaphone_set_by_sorted_phonemes_; + + std::vector
forms_; + std::unordered_map form_by_text_; + + std::vector> anagram_sets_; + std::unordered_map anagram_set_by_sorted_letters_; + + std::vector words_; + std::unordered_map word_by_base_; + + std::vector> synsets_; + std::unordered_map synset_by_wnid_; +}; + +#endif /* end of include guard: GENERATOR_H_D5C6A724 */ \ No newline at end of file -- cgit 1.4.1