Exemplo n.º 1
0
        private void cbConfigs_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedConfig = cbConfigs.Text;

            AwakeTypes = new ServerConfigManager(ConfigDirectory, selectedConfig);

            cbAwakeType.Items.Clear();

            foreach (var awake in AwakeTypes.AwakeTypes)
            {
                cbAwakeType.Items.Add(awake.Name);
            }
        }
Exemplo n.º 2
0
        public AwakeningResolver(ServerConfigManager configManager, AwakeningRoutines awakeRoutines)
        {
            ConfigManager = configManager;
            AwakeRoutines = awakeRoutines;

            // Write the eng.user-words

            /*
             *  string dictionary = "";
             *
             *  foreach (var awake in configManager.AwakeTypes)
             *  {
             *      dictionary += awake.Text + "\n";
             *  }
             *
             *  using (StreamWriter sw = new StreamWriter("tessdata\\eng.user-words"))
             *  {
             *      sw.Write(dictionary);
             *  }
             */

            try
            {
                string characters = "";

                foreach (char c in ConfigManager.WhitelistedCharacters)
                {
                    characters += c;
                }

                var initVars = new Dictionary <string, object>()
                {
                    { "load_system_dawg", false },
                    { "load_freq_dawg", false },
                    // { "user_words_suffix", "user-words" }, // Load custom dictionary from eng.user-words
                    { "tessedit_char_whitelist", "+-%0123456789 " + characters },
                };

                TessEngine = new TesseractEngine("tessdata", ConfigManager.Language, EngineMode.Default, Enumerable.Empty <string>(), initVars, false)
                {
                    DefaultPageSegMode = PageSegMode.SingleBlock
                };
            }
            catch (Exception ex)
            {
                GeneralUtils.DisplayError(ex.ToString());
                Application.Exit();
            }
        }
Exemplo n.º 3
0
        public AwakeningResolver(ServerConfigManager configManager, AwakeningRoutines awakeRoutines)
        {
            ConfigManager = configManager;
            AwakeRoutines = awakeRoutines;

            try {
                TessEngine = new TesseractEngine("tessdata", ConfigManager.Language);

                string characters = "";

                foreach (char c in ConfigManager.WhitelistedCharacters)
                {
                    characters += c;
                }

                TessEngine.SetVariable("tessedit_char_whitelist", "+-%0123456789 " + characters);
                TessEngine.DefaultPageSegMode = PageSegMode.SingleBlock;
            }
            catch (Exception ex) {
                GeneralUtils.DisplayError(ex.ToString());
                Application.Exit();
            }
        }
Exemplo n.º 4
0
        private void ComboBoxConfigsOnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (ComboBoxConfigs.SelectedIndex < 0)
            {
                return;
            }

            string selectedConfig = ComboBoxConfigs.Text;

            try
            {
                _serverConfig = ServerConfigManager.ReadConfig(selectedConfig);
            }
            catch (Exception ex)
            {
                Display.Error($"Failed while parsing the config {selectedConfig} with exception message: {ex.ToString()}");

                ComboBoxConfigs.SelectedIndex = -1;
                _serverConfig = null;
                return;
            }

            RefreshConfigAwakeTypes(_serverConfig.AwakeTypes);
        }