public void PredictorWrongKey()
		{
			var predictor = new Predictor("1111");
			var exception = Assert.Throws<YandexLinguisticsException>(() => predictor.GetLangs());
			Assert.AreEqual(
				new YandexLinguisticsException(401, "API key is invalid").ToString(),
				exception.ToString());
		}
Example #2
0
        public void PredictorWrongKey()
        {
            var predictor = new Predictor("1111");
            var exception = Assert.Throws <YandexLinguisticsException>(() => predictor.GetLangs());

            Assert.AreEqual(
                new YandexLinguisticsException(401, "API key is invalid").ToString(),
                exception.ToString());
        }
Example #3
0
        public void PredictorGetLangs()
        {
            var expectedLangs = Predictor.GetLangs();
            var langs         = typeof(PredictorLang).GetFields()
                                .Where(field => field.FieldType == typeof(Lang))
                                .Select(field => (Lang)field.GetValue(null));

            CollectionAssert.AreEquivalent(expectedLangs, langs);
        }
Example #4
0
        public void PredictorGetLangs()
        {
            var langs         = Predictor.GetLangs();
            var expectedLangs = new Lang[]
            {
                Lang.Ru,
                Lang.En,
                Lang.Pl,
                Lang.Uk,
                Lang.De,
                Lang.Fr,
                Lang.Es,
                Lang.It,
                Lang.Tr
            };

            Assert.IsTrue(expectedLangs.All(lang => langs.Contains(lang)));
        }
Example #5
0
		public frmMain()
		{
			Predictor = new Predictor(Settings.Default.PredictorKey);
			Dictionary = new Dictionary(Settings.Default.DictionaryKey);
			Translator = new Translator(Settings.Default.TranslatorKey);
			Speller = new Speller();
			Inflector = new Inflector();

			PredictorTimer = new System.Threading.Timer(_ => UpdatePredictorResult(), null, Timeout.Infinite, Timeout.Infinite);
			DictionaryTimer = new System.Threading.Timer(_ => UpdateDictionaryResult(), null, Timeout.Infinite, Timeout.Infinite);
			TranslatorTimer = new System.Threading.Timer(_ => UpdateTranslatorResult(), null, Timeout.Infinite, Timeout.Infinite);
			SpellerTimer = new System.Threading.Timer(_ => UpdateSpellerResult(), null, Timeout.Infinite, Timeout.Infinite);
			InflectorTimer = new System.Threading.Timer(_ => UpdateInflectorResult(), null, Timeout.Infinite, Timeout.Infinite);

			InitializeComponent();

			tcServices.SelectedIndex = Settings.Default.SelectedTabIndex;

			cmbPredictorLangs.Items.AddRange(Predictor.GetLangs().Select(lang => (object)lang).ToArray());
			cmbDictionaryLangPairs.Items.AddRange(Dictionary.GetLangs().Select(lang => (object)lang).ToArray());
			cmbDictionaryLangUi.Items.Add("");
			cmbDictionaryLangUi.Items.AddRange(Predictor.GetLangs().Select(lang => (object)lang).ToArray());

			cmbPredictorLangs.SelectedItem = Enum.Parse(typeof(Lang), Settings.Default.PredictorLanguage);
			nudMaxHintCount.Value = Settings.Default.PredictorMaxHintCount;
			nudPredictorDelay.Value = Settings.Default.PredictorHintDelay;
			tbPredictorInput.Text = Settings.Default.PredictorInput;

			cmbDictionaryLangPairs.SelectedItem = new LangPair(Settings.Default.DictionaryLangPair);
			cmbDictionaryLangUi.SelectedIndex = 0;
			
			cbFamily.Checked = Settings.Default.DictionaryFamily;
			cbMorpho.Checked = Settings.Default.DictionaryMorpho;
			cbPartOfSpeech.Checked = Settings.Default.DictionaryPartOfSpeech;
			nudPredictorDelay.Value = Settings.Default.DictionaryHintDelay;
			tbDictionaryInput.Text = Settings.Default.DictionaryInput;
			cbDictionaryFormatting.Checked = Settings.Default.DictionaryFormatting;
			rbDictionaryOutput.Text = Settings.Default.DictionaryOutputIndent;

			var langArray = ((Lang[])Enum.GetValues(typeof(Lang))).Select(lang => (object)lang).ToArray();
			cmbTranslatorInputLang.Items.AddRange(langArray);
			cmbTranslatorOutputLang.Items.AddRange(langArray);
			cmbTranslatorInputLang.SelectedItem = (Lang)Enum.Parse(typeof(Lang), Settings.Default.TranslatorInputLang);
			cmbTranslatorOutputLang.SelectedItem = (Lang)Enum.Parse(typeof(Lang), Settings.Default.TranslatorOutputLang);
			nudTranslatorDelay.Value = Settings.Default.TranslatorHintDelay;
			cbTranslatorDetectInputLang.Checked = Settings.Default.TranslatorDetectInputLang;
			tbTranslatorInput.Text = Settings.Default.TranslatorInput;

			cbSpellerRu.Checked = Settings.Default.SpellerRuLang;
			cbSpellerEn.Checked = Settings.Default.SpellerEnLang;
			cbSpellerUk.Checked = Settings.Default.SpellerUkLang;
			SpellerOptions options = (SpellerOptions)Settings.Default.SpellerOptions;
			cbIgnoreUppercase.Checked = options.HasFlag(SpellerOptions.IgnoreUppercase);
			cbIgnoreDigits.Checked = options.HasFlag(SpellerOptions.IgnoreDigits);
			cbIgnoreUrls.Checked = options.HasFlag(SpellerOptions.IgnoreUrls);
			cbFindRepeatWords.Checked = options.HasFlag(SpellerOptions.FindRepeatWords);
			cbIgnoreLatin.Checked = options.HasFlag(SpellerOptions.IgnoreLatin);
			cbNoSuggest.Checked = options.HasFlag(SpellerOptions.NoSuggest);
			cbFlagLatin.Checked = options.HasFlag(SpellerOptions.FlagLatin);
			cbByWords.Checked = options.HasFlag(SpellerOptions.ByWords);
			cbIgnoreCapitalization.Checked = options.HasFlag(SpellerOptions.IgnoreCapitalization);
			nudSpellerDelay.Value = Settings.Default.SpellerHintDelay;
			tbSpellerInput.Text = Settings.Default.SpellerInput;
			cbIncludeErrorWords.Checked = Settings.Default.SpellerIncludeErrorWords;

			tbInflectorInput.Text = Settings.Default.InflectorInput;

			tbPredictorKey.Text = Settings.Default.PredictorKey;
			tbDictionaryKey.Text = Settings.Default.DictionaryKey;
			tbTranslatorKey.Text = Settings.Default.TranslatorKey;
			tbPredictorBaseUrl.Text = Settings.Default.PredictorBaseUrl;
			tbDictionaryBaseUrl.Text = Settings.Default.DictionaryBaseUrl;
			tbTranslatorBaseUrl.Text = Settings.Default.TranslatorBaseUrl;
			tbSpellerBaseUrl.Text = Settings.Default.SpellerBaseUrl;
			tbInflectorBaseUrl.Text = Settings.Default.InflectorBaseUrl;
		}
Example #6
0
        public frmMain()
        {
            Predictor  = new Predictor(Settings.Default.PredictorKey);
            Dictionary = new Dictionary(Settings.Default.DictionaryKey);
            Translator = new Translator(Settings.Default.TranslatorKey);
            Speller    = new Speller();

            PredictorTimer  = new System.Threading.Timer(_ => UpdatePredictorResult(), null, Timeout.Infinite, Timeout.Infinite);
            DictionaryTimer = new System.Threading.Timer(_ => UpdateDictionaryResult(), null, Timeout.Infinite, Timeout.Infinite);
            TranslatorTimer = new System.Threading.Timer(_ => UpdateTranslatorResult(), null, Timeout.Infinite, Timeout.Infinite);
            SpellerTimer    = new System.Threading.Timer(_ => UpdateSpellerResult(), null, Timeout.Infinite, Timeout.Infinite);

            InitializeComponent();

            tcServices.SelectedIndex = Settings.Default.SelectedTabIndex;

            cmbPredictorLangs.Items.AddRange(Predictor.GetLangs().Select(lang => (object)lang).ToArray());
            cmbDictionaryLangPairs.Items.AddRange(Dictionary.GetLangs().Select(lang => (object)lang).ToArray());
            cmbDictionaryLangUi.Items.Add("");
            cmbDictionaryLangUi.Items.AddRange(Predictor.GetLangs().Select(lang => (object)lang).ToArray());

            cmbPredictorLangs.SelectedItem = Enum.Parse(typeof(Lang), Settings.Default.PredictorLanguage);
            nudMaxHintCount.Value          = Settings.Default.PredictorMaxHintCount;
            nudPredictorDelay.Value        = Settings.Default.PredictorHintDelay;
            tbPredictorInput.Text          = Settings.Default.PredictorInput;

            cmbDictionaryLangPairs.SelectedItem = LangPair.Parse(Settings.Default.DictionaryLangPair);
            cmbDictionaryLangUi.SelectedIndex   = 0;

            cbFamily.Checked               = Settings.Default.DictionaryFamily;
            cbMorpho.Checked               = Settings.Default.DictionaryMorpho;
            cbPartOfSpeech.Checked         = Settings.Default.DictionaryPartOfSpeech;
            nudPredictorDelay.Value        = Settings.Default.DictionaryHintDelay;
            tbDictionaryInput.Text         = Settings.Default.DictionaryInput;
            cbDictionaryFormatting.Checked = Settings.Default.DictionaryFormatting;
            rbDictionaryOutput.Text        = Settings.Default.DictionaryOutputIndent;

            var langArray = ((Lang[])Enum.GetValues(typeof(Lang))).Select(lang => (object)lang).ToArray();

            cmbTranslatorInputLang.Items.AddRange(langArray);
            cmbTranslatorOutputLang.Items.AddRange(langArray);
            cmbTranslatorInputLang.SelectedItem  = (Lang)Enum.Parse(typeof(Lang), Settings.Default.TranslatorInputLang);
            cmbTranslatorOutputLang.SelectedItem = (Lang)Enum.Parse(typeof(Lang), Settings.Default.TranslatorOutputLang);
            nudTranslatorDelay.Value             = Settings.Default.TranslatorHintDelay;
            cbTranslatorDetectInputLang.Checked  = Settings.Default.TranslatorDetectInputLang;
            tbTranslatorInput.Text = Settings.Default.TranslatorInput;

            cbSpellerRu.Checked = Settings.Default.SpellerRuLang;
            cbSpellerEn.Checked = Settings.Default.SpellerEnLang;
            cbSpellerUk.Checked = Settings.Default.SpellerUkLang;
            SpellerOptions options = (SpellerOptions)Settings.Default.SpellerOptions;

            cbIgnoreUppercase.Checked      = options.HasFlag(SpellerOptions.IgnoreUppercase);
            cbIgnoreDigits.Checked         = options.HasFlag(SpellerOptions.IgnoreDigits);
            cbIgnoreUrls.Checked           = options.HasFlag(SpellerOptions.IgnoreUrls);
            cbFindRepeatWords.Checked      = options.HasFlag(SpellerOptions.FindRepeatWords);
            cbIgnoreLatin.Checked          = options.HasFlag(SpellerOptions.IgnoreLatin);
            cbNoSuggest.Checked            = options.HasFlag(SpellerOptions.NoSuggest);
            cbFlagLatin.Checked            = options.HasFlag(SpellerOptions.FlagLatin);
            cbByWords.Checked              = options.HasFlag(SpellerOptions.ByWords);
            cbIgnoreCapitalization.Checked = options.HasFlag(SpellerOptions.IgnoreCapitalization);
            nudSpellerDelay.Value          = Settings.Default.SpellerHintDelay;
            tbSpellerInput.Text            = Settings.Default.SpellerInput;
            cbIncludeErrorWords.Checked    = Settings.Default.SpellerIncludeErrorWords;

            tbPredictorKey.Text      = Settings.Default.PredictorKey;
            tbDictionaryKey.Text     = Settings.Default.DictionaryKey;
            tbTranslatorKey.Text     = Settings.Default.TranslatorKey;
            tbPredictorBaseUrl.Text  = Settings.Default.PredictorBaseUrl;
            tbDictionaryBaseUrl.Text = Settings.Default.DictionaryBaseUrl;
            tbTranslatorBaseUrl.Text = Settings.Default.TranslatorBaseUrl;
            tbSpellerBaseUrl.Text    = Settings.Default.SpellerBaseUrl;
        }