Пример #1
0
        public MainWindow()
        {
            InitializeComponent();
            RtbResult.IsReadOnly = true;
            BtnSave.IsEnabled    = false;
            Load(Path);

            var data          = new DataBaseManager(new MySqlConnectionFactory(), Settings.Server, Settings.DbName, Settings.DbUser, Settings.DbPassword);
            var queryProvider = Settings.AlphabeticalTables
                ? (IQueryProvider) new SqlQueryProviderAlpha(Settings.TableNames)
                : new SqlQueryProvider(Settings.TableNames);

            if (Settings.UseDictionary)
            {
                if (_dictionary == null)
                {
                    _dictionary = LoadDictionary();
                    _main       = _dictionary;
                }
            }
            else
            {
                if (_unigrams == null)
                {
                    _unigrams = LoadUnigrams();
                    _main     = _unigrams;
                }
            }

            _letterChanger = new DiacriticMarksAdder();
            _splitter      = Settings.SentenceSpliterOn ? new SentencesSplitter() : null;
            _iManager      = Settings.IgnorePunctationMarks ? new InterpunctionManager() : null;
            _connector     = (Settings.NoOfMethod == 0) ? (INgramsConnector) new UpDown() : new Hierarchy();

            _analyzer = new DiacriticMarksRestorer(_letterChanger, _main, _splitter, _iManager, _connector);

            _analyzer.SetData(data);
            _analyzer.SetQueryProvider(queryProvider);
            _analyzer.SetNgram(Settings.Type);
            _timer.Elapsed += OnTimerElapsed;

            Style noSpaceStyle = new Style(typeof(Paragraph));

            noSpaceStyle.Setters.Add(new Setter(Paragraph.MarginProperty, new Thickness(0)));
            RtbInput.Resources.Add(typeof(Paragraph), noSpaceStyle);
            RtbResult.Resources.Add(typeof(Paragraph), noSpaceStyle);
        }
Пример #2
0
        /// <summary>
        /// Handles the Click event of the MenuButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void MenuButton_Click(object sender, RoutedEventArgs e)
        {
            var subWindow = new SettingsWindow();

            subWindow.ShowDialog();

            if (!subWindow.ChangeSettings)
            {
                return;
            }

            var data          = new DataBaseManager(new MySqlConnectionFactory(), Settings.Server, Settings.DbName, Settings.DbUser, Settings.DbPassword);
            var queryProvider = Settings.AlphabeticalTables
                ? (IQueryProvider) new SqlQueryProviderAlpha(Settings.TableNames)
                : new SqlQueryProvider(Settings.TableNames);

            if (Settings.UseDictionary)
            {
                if (_dictionary == null)
                {
                    _dictionary = LoadDictionary();
                    _main       = _dictionary;
                }
            }
            else
            {
                if (_unigrams == null)
                {
                    _unigrams = LoadUnigrams();
                    _main     = _unigrams;
                }
            }

            _letterChanger = new DiacriticMarksAdder();
            _splitter      = Settings.SentenceSpliterOn ? new SentencesSplitter() : null;
            _iManager      = Settings.IgnorePunctationMarks ? new InterpunctionManager() : null;
            _connector     = (Settings.NoOfMethod == 0) ? (INgramsConnector) new UpDown() : new Hierarchy();

            _analyzer = new DiacriticMarksRestorer(_letterChanger, _main, _splitter, _iManager, _connector);

            _analyzer.SetData(data);
            _analyzer.SetQueryProvider(queryProvider);
            _analyzer.SetNgram(Settings.Type);
        }
Пример #3
0
        // public List<string> WordsCombinations { get; private set; }
        #endregion

        #region CONSTRUCTORS

        /// <summary>
        /// Initializes a new instance of the <see cref="DiacriticMarksRestorer"/> class.
        /// </summary>
        /// <param name="diacriticAdder">The diacritic adder.</param>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="splitter"></param>
        /// <param name="iManager"></param>
        /// <param name="ngramConnector"></param>
        public DiacriticMarksRestorer(ILetterChanger diacriticAdder = null, IDictionary dictionary = null, IFragmentsSplitter splitter = null, ICharactersIgnorer iManager = null, INgramsConnector ngramConnector = null)
        {
            _diacriticAdder = diacriticAdder ?? new DiacriticMarksAdder();
            if (dictionary == null)
            {
                var logFile = File.ReadAllLines(@"Resources\dictionary");
                var logList = new List <string>(logFile);
                var result  = new Dictionary <string, int>();
                foreach (var item in logList)
                {
                    result.Add(item, 0);
                }
                dictionary = new Dict(result);
            }

            _dictionary     = dictionary;
            _splitter       = splitter;
            _ngramConnector = ngramConnector ?? new Hierarchy();
            _iManager       = iManager;
            _ngramType      = NgramType.Bigram;
        }
Пример #4
0
 internal NGramVariants(NGram orginalNGram, ILetterChanger marksAdder)
 {
     OrginalNGram  = orginalNGram;
     _marksAdder   = marksAdder;
     NgramVariants = new List <NGramVariant>();
 }