// Token: 0x06005B55 RID: 23381 RVA: 0x0019C11A File Offset: 0x0019A31A
 internal SpellingError(Speller speller, ITextPointer start, ITextPointer end)
 {
     Invariant.Assert(start.CompareTo(end) < 0);
     this._speller = speller;
     this._start   = start.GetFrozenPointer(LogicalDirection.Forward);
     this._end     = end.GetFrozenPointer(LogicalDirection.Backward);
 }
Пример #2
0
        static BgNumberSpeller()
        {
            var digitsSpeller = new DigitSpeller();
            var numTo19Speller = new NumbersTo19Speller(digitsSpeller);
            var tensSpeller = new TensSpeller(numTo19Speller);
            var hundredsSpeller = new HundredsSpeller(tensSpeller);
            var thousandsSpeller = new GenericSpeller(
                    childSpeller: hundredsSpeller,
                    settings: new GenericSpellerSettings(1_000, "хиляда", " хиляди", Gender.Female, "хиляден", "хилядна", "хилядно"));
            var millionsSpeller = new GenericSpeller(
                    childSpeller: thousandsSpeller,
                    settings: new GenericSpellerSettings(1_000_000, "един милион", " милиона", Gender.Male, "милионен", "милионна", "милионно"));
            var billionsSpeller = new GenericSpeller(
                    childSpeller: millionsSpeller,
                    settings: new GenericSpellerSettings(1_000_000_000, "един милиард", " милиарда", Gender.Male, "милиарден", "милиардна", "милиардно"));
            var trillionsSpeller = new GenericSpeller(
                    childSpeller: billionsSpeller,
                    settings: new GenericSpellerSettings(1_000_000_000_000, "един трилион", " трилиона", Gender.Male, "трилионен", "трилионна", "трилионно"));
            var kvadrilionsSpeller = new GenericSpeller(
                    childSpeller: trillionsSpeller,
                    settings: new GenericSpellerSettings(1_000_000_000_000_000, "един квадрилион", " квадрилиона", Gender.Male, "квадрилионен", "квадрилионна", "квадрилионно"));
            var kvintalionsSpeller = new GenericSpeller(
                    childSpeller: kvadrilionsSpeller,
                    settings: new GenericSpellerSettings(1_000_000_000_000_000_000, "един квинталион", " квинталиона", Gender.Male, "квинталионен", "квинталионна", "квинталионно"));

            s_speller = new ZeroSpeller(kvintalionsSpeller);
        }
Пример #3
0
 void ICollection <Uri> .Clear()
 {
     _uriList.Clear();
     if (Speller != null)
     {
         Speller.OnDictionaryUriCollectionCleared();
     }
 }
Пример #4
0
        public void TestCases()
        {
            var output = new Speller().Spell(new [] { "hello world", "foo  bar" });

            Assert.AreEqual(2, output.Length);
            Assert.AreEqual("4433555 555666096667775553", output[0]);
            Assert.AreEqual("333666 6660 022 2777", output[1]);
        }
        public async Task TranslateIntoRuTestMethod()
        {
            string message  = "ghbdtn";
            string expected = "привет";
            var    words    = await Speller.CheckText(message);

            string result = words[0].S[0];

            Assert.AreEqual(expected, result);
        }
Пример #6
0
        bool ICollection <Uri> .Remove(Uri item)
        {
            bool removed = _uriList.Remove(item);

            if (removed && (Speller != null))
            {
                Speller.OnDictionaryUriRemoved(item);
            }
            return(removed);
        }
        public async Task TranslateIntoEnTestMethod()
        {
            string message  = "руддщ";
            string expected = "hello";
            var    words    = await Speller.CheckText(message);

            string result = words[0].S[0];

            Assert.AreEqual(expected, result);
        }
Пример #8
0
        void IList <Uri> .RemoveAt(int index)
        {
            Uri uri = _uriList[index];

            _uriList.RemoveAt(index);

            if (Speller != null)
            {
                Speller.OnDictionaryUriRemoved(uri);
            }
        }
Пример #9
0
        public async Task Execute(Message message, TelegramBotClient botClient)
        {
            var chatId = message.Chat.Id;
            var text   = message.Text;
            var words  = await Speller.CheckText(text);

            foreach (var word in words)
            {
                text = text.Replace(word.Word, word.S[0]);
            }

            await botClient.SendTextMessageAsync(chatId, text.ToString(), parseMode : Telegram.Bot.Types.Enums.ParseMode.Markdown);
        }
Пример #10
0
        /// <summary>
        /// Adds new item to the internal collection.
        /// Duplicate items ARE NOT added, but Speller is still notified.
        /// </summary>
        /// <param name="item"></param>
        void ICollection <Uri> .Add(Uri item)
        {
            ValidateUri(item);
            if (!_uriList.Contains(item))
            {
                _uriList.Add(item);
            }

            if (Speller != null)
            {
                Speller.OnDictionaryUriAdded(item);
            }
        }
Пример #11
0
        /// <summary>
        /// Implementation of Insert method. A restriction added by this implementation is that
        /// it will throw exception if the item was already added previously.
        /// This is to avoid ambiguity in respect to the expected position (index) of the inserted item.
        /// Caller will have to check first if item was already added.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="item"></param>
        void IList <Uri> .Insert(int index, Uri item)
        {
            if (_uriList.Contains(item))
            {
                throw new ArgumentException(SR.Get(SRID.CustomDictionaryItemAlreadyExists), "item");
            }

            ValidateUri(item);
            _uriList.Insert(index, item);

            if (Speller != null)
            {
                Speller.OnDictionaryUriAdded(item);
            }
        }
Пример #12
0
 /// <summary>
 /// Sets value at specified index.
 /// Speller is notified that value at the index is being replaced, which means
 /// current value at given offset is removed, and new value is added at the same index.
 /// </summary>
 /// <param name="index"></param>
 /// <returns></returns>
 Uri IList <Uri> .this[int index]
 {
     get
     {
         return(_uriList[index]);
     }
     set
     {
         ValidateUri(value);
         Uri oldUri = _uriList[index];
         if (Speller != null)
         {
             Speller.OnDictionaryUriRemoved(oldUri);
         }
         _uriList[index] = value;
         if (Speller != null)
         {
             Speller.OnDictionaryUriAdded(value);
         }
     }
 }
Пример #13
0
        public string Process(string word)
        {
            if (word.Length < 2)
            {
                return(word);
            }

            if (word.ToCharArray().Any(char.IsDigit))
            {
                return(word);
            }

            if (IgnoreWords.Contains(word))
            {
                return(word);
            }

            var suggestions = Speller.Lookup(word, SymSpell.Verbosity.Closest, MaxDistance);

            return(suggestions.Count == 0 ? word : suggestions[0].term);
        }
Пример #14
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            var text                = activity.Text ?? String.Empty;
            var yandexSpeller       = new Speller();
            var yandexSpellerResult = yandexSpeller.CheckText(text);
            var resutText           = new StringBuilder(text);

            if (yandexSpellerResult.Errors.Any())
            {
                var shift = 0;
                foreach (var error in yandexSpellerResult.Errors)
                {
                    resutText.Insert(error.Position + shift, "**");
                    resutText.Insert(error.Position + error.Length + shift + 2, "**");
                    resutText.Append($"\n\r**{ error.Word}**:{ error.Steer}");
                    shift += 4;
                }
            }

            //var yandexSpeller = new Speller();
            // var yandexSpellerResult = yandexSpeller.CheckText(text);

            // var resulText = new StringBuilder();


            // calculate something for us to return
            // int length = (activity.Text ?? string.Empty).Length;

            // return our reply to the user
            // await context.PostAsync($"You sent {activity.Text} which was {length} characters");await context.PostAsync($"11111111111111 {text} which was {text} characters");
            await context.PostAsync(resutText.ToString());

            context.Wait(MessageReceivedAsync);
        }
Пример #15
0
        public static string Spell(string text)
        {
            if (String.IsNullOrEmpty(text))
            {
                return("String is not correct");
            }
            StringBuilder result = new StringBuilder(text);

            var yandexSpeller = new Speller();
            var yandexResult  = yandexSpeller.CheckText(text);

            if (yandexResult.Errors.Any())
            {
                var shift = 0;
                foreach (var error in yandexResult.Errors)
                {
                    result.Insert(error.Position + shift, "**");
                    result.Insert(error.Position + error.Length + shift + 2, "**");
                    result.Append($"\n\r**{error.Word}**: {error.Steer}");
                    shift += 4;
                }
            }
            return(result.ToString());
        }
        internal static SearchOptions DeserializeSearchOptions(JsonElement element)
        {
            Optional <bool>              count             = default;
            Optional <IList <string> >   facets            = default;
            Optional <string>            filter            = default;
            Optional <string>            highlight         = default;
            Optional <string>            highlightPostTag  = default;
            Optional <string>            highlightPreTag   = default;
            Optional <double>            minimumCoverage   = default;
            Optional <string>            orderby           = default;
            Optional <SearchQueryType>   queryType         = default;
            Optional <ScoringStatistics> scoringStatistics = default;
            Optional <string>            sessionId         = default;
            Optional <IList <string> >   scoringParameters = default;
            Optional <string>            scoringProfile    = default;
            Optional <string>            search            = default;
            Optional <string>            searchFields      = default;
            Optional <SearchMode>        searchMode        = default;
            Optional <QueryLanguage>     queryLanguage     = default;
            Optional <Speller>           speller           = default;
            Optional <Answers>           answers           = default;
            Optional <string>            select            = default;
            Optional <int> skip = default;
            Optional <int> top  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    count = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("facets"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    facets = array;
                    continue;
                }
                if (property.NameEquals("filter"))
                {
                    filter = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("highlight"))
                {
                    highlight = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("highlightPostTag"))
                {
                    highlightPostTag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("highlightPreTag"))
                {
                    highlightPreTag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("minimumCoverage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    minimumCoverage = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("orderby"))
                {
                    orderby = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("queryType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    queryType = property.Value.GetString().ToSearchQueryType();
                    continue;
                }
                if (property.NameEquals("scoringStatistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    scoringStatistics = property.Value.GetString().ToScoringStatistics();
                    continue;
                }
                if (property.NameEquals("sessionId"))
                {
                    sessionId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("scoringParameters"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    scoringParameters = array;
                    continue;
                }
                if (property.NameEquals("scoringProfile"))
                {
                    scoringProfile = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("search"))
                {
                    search = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("searchFields"))
                {
                    searchFields = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("searchMode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    searchMode = property.Value.GetString().ToSearchMode();
                    continue;
                }
                if (property.NameEquals("queryLanguage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    queryLanguage = new QueryLanguage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("speller"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    speller = new Speller(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("answers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    answers = new Answers(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("select"))
                {
                    select = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("skip"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    skip = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("top"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    top = property.Value.GetInt32();
                    continue;
                }
            }
            return(new SearchOptions(Optional.ToNullable(count), Optional.ToList(facets), filter.Value, highlight.Value, highlightPostTag.Value, highlightPreTag.Value, Optional.ToNullable(minimumCoverage), orderby.Value, Optional.ToNullable(queryType), Optional.ToNullable(scoringStatistics), sessionId.Value, Optional.ToList(scoringParameters), scoringProfile.Value, search.Value, searchFields.Value, Optional.ToNullable(searchMode), Optional.ToNullable(queryLanguage), Optional.ToNullable(speller), Optional.ToNullable(answers), select.Value, Optional.ToNullable(skip), Optional.ToNullable(top)));
        }
Пример #17
0
 /// <summary>
 /// Genera les línies d'un fitxer .dic a partir de la llista d'entrades.
 /// No conté cap línia amb el nombre de línies.
 /// Només s'inclouen les entrades que tenen totes les marques incloses dins filtre.
 /// </summary>
 /// <param name="entrades">Les entrades que ha de contenir el fitxer .dic.</param>
 /// <param name="speller">El client per al qual generarem les línies .dic.</param>
 /// <param name="comparador">La funció de comparació.</param>
 /// <returns>Una llista de línies amb el format adequat, ordenada segons el comparador.</returns>
 public static string[] GeneraLiniesDic(IEnumerable<Entrada> entrades, Marques filtre, 
     Speller speller, Comparison<string> comparador)
 {
     List<ItemDic> llista = Entrada.GeneraItemsDic(entrades, filtre, speller, comparador);
     Entrada entrada0 = null;
     foreach (Entrada ent in entrades)
     {
         entrada0 = ent;
         break;
     }
     Regles regles = entrada0.Identificador.Regles;
     Dictionary<string, List<ItemDic>> dic = new Dictionary<string, List<ItemDic>>();
     List<ItemDic> llistaCompactada = new List<ItemDic>(llista.Count);
     foreach (ItemDic id in llista)
     {
         bool crea = true, afegeix = true;
         if (dic.ContainsKey(id.Arrel))
         {
             crea = false;
             foreach(ItemDic item in dic[id.Arrel])
                 if (item.FlagsCompatibles(id, regles))
                 {
                     item.MesFlags(id);
                     afegeix = false;
                 }
         }
         if (afegeix)
         {
             if (crea)
                 dic[id.Arrel] = new List<ItemDic>();
             dic[id.Arrel].Add(id);
             llistaCompactada.Add(id);
         }
     }
     llistaCompactada.Sort(delegate(ItemDic item1, ItemDic item2)
     {
         int cmp = comparador(item1.Arrel, item2.Arrel);
         if (cmp != 0)
             return cmp;
         else
             return String.Compare(item1.FlagsComLletres, item2.FlagsComLletres);
     });
     string[] linies = new string[llistaCompactada.Count];
     for (int i = 0; i < llistaCompactada.Count; i++)
         linies[i] = llistaCompactada[i].ToString();
     return linies;
 }
Пример #18
0
 /// <summary>
 /// Genera les línies d'un fitxer .dic per a una entrada.
 /// </summary>
 /// <param name="entrada">L'entrada a partir de la qual volem generar.</param>
 /// <param name="identificador">Un identificador per als paradigmes.</param>
 /// <param name="filtre">Les marques que volem incloure al resultat.</param>
 /// <param name="speller">El client per al qual generarem les línies .dic.</param>
 /// <param name="comparador">La funció de comparació.</param>
 /// <returns>Una llista de línies amb el format adequat, ordenada segons el comparador.</returns>
 public static string[] GeneraLiniesDic(Entrada entrada, Marques filtre, 
     Speller speller, Comparison<string> comparador)
 {
     List<Entrada> entrades = new List<Entrada>();
     entrades.Add(entrada);
     return GeneraLiniesDic(entrades, filtre, speller, comparador);
 }
Пример #19
0
 private void tbSpellerBaseUrl_TextChanged(object sender, EventArgs e)
 {
     Speller = new Speller(tbSpellerBaseUrl.Text);
     tbSpellerInput_TextChanged(sender, e);
 }
Пример #20
0
 public static List<ItemDic> GeneraItemsDic(IEnumerable<Entrada> entrades, Marques filtre,
     Speller speller, Comparison<string> comparador)
 {
     List<ItemDic> llista = new List<ItemDic>();
     Marques filtreExc = new Marques(filtre);
     Dictionary<string, string> dades;
     foreach (Entrada ent in entrades)
     {
         if (!filtre.Conte(ent.Marques))
             continue;
         List<ItemDic> ids = new List<ItemDic>();
         Paradigma par = null;
         if (ent.Excepcions == null)
         {
             par = ent.Identificador.IdentificaParadigma(ent.Dades, null);
             ids.AddRange(par.GeneraDic(ent.Dades, null, filtre, speller));
             llista.AddRange(ids);
         }
         else
         {
             for (int g = 1; g <= 2; g++)
             {
                 Marca grup = (g == 1) ? Marca.grup1 : Marca.grup2;
                 if (!ent.Excepcions.Contingut.Conte(grup))
                     continue;
                 filtreExc.Menys(Marca.grups12);
                 filtreExc.Mes(grup);
                 Dictionary<string, string> excepcions = ent.Excepcions.Contingut.Valors(filtreExc);
                 dades = new Dictionary<string, string>(ent.Dades);
                 if (excepcions.ContainsKey("MODEL"))
                 {
                     string[] model = excepcions["MODEL"].Split('/');
                     if (excepcions.Count == 1)
                         AplicaModel(dades, out excepcions, model, ent.Identificador.Excepcio(model[0]).Contingut, filtreExc);
                     else
                     {
                         // A part del model, hi ha més dades
                         Dictionary<string, string> excepcionsOriginals = new Dictionary<string,string>(excepcions);
                         AplicaModel(dades, out excepcions, model, ent.Identificador.Excepcio(model[0]).Contingut, filtreExc);
                         foreach (KeyValuePair<string, string> kv in excepcionsOriginals)
                             excepcions[kv.Key] = kv.Value;
                     }
                 }
                 if (excepcions.ContainsKey("IGNORA")) // sempre deu ser IGNORA=1
                     continue;
                 if (excepcions.ContainsKey("ALT"))
                     dades["arrel"] = excepcions["ALT"];
                 if (excepcions.ContainsKey("NOVACAT"))
                     dades["cat1"] = excepcions["NOVACAT"];
                 par = ent.Identificador.IdentificaParadigma(dades, excepcions);
                 ids.AddRange(par.GeneraDic(dades, excepcions, filtre, speller));
             }
             llista.AddRange(ids);
         }
         foreach (ItemDic id in ids)
         {
             id.Entrada = ent;
             if (id.Paradigma == null)
                 id.Paradigma = par;
         }
     }
     llista.Sort(delegate(ItemDic id1, ItemDic id2)
     {
         return comparador(id1.Arrel, id2.Arrel);
     });
     return llista;
 }
Пример #21
0
        public void TestPause()
        {
            var output = new Speller().Spell("aa");

            Assert.AreEqual("2 2", output);
        }
Пример #22
0
        public void TestInvalidChar()
        {
            var speller = new Speller();

            Assert.ThrowsException <InvalidCharException>(() => speller.Spell("-"));
        }
Пример #23
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;
        }
Пример #24
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;
		}
Пример #25
0
        public void TestEmptyInputs()
        {
            var speller = new Speller();

            Assert.ThrowsException <ArgumentException>(() => speller.Spell(new string[0]));
        }
Пример #26
0
 public ChainedSpeller(Speller innerSpeller)
 {
     InnerSpeller = innerSpeller;
 }
Пример #27
0
 // Constructor.
 internal SpellerHighlightLayer(Speller speller)
 {
     _speller = speller;
 }
 public void Init()
 {
     Speller = new Speller();
 }
Пример #29
0
 public GenericSpeller(Speller childSpeller, GenericSpellerSettings settings)
     : base(childSpeller)
 {
     _settings = settings;
 }
Пример #30
0
		private void tbSpellerBaseUrl_TextChanged(object sender, EventArgs e)
		{
			Speller = new Speller(tbSpellerBaseUrl.Text);
			tbSpellerInput_TextChanged(sender, e);
		}
Пример #31
0
        public void TestInvalidCase()
        {
            var speller = new Speller();

            Assert.ThrowsException <InvalidCaseException>(() => speller.Spell(new [] { "-" }));
        }
Пример #32
0
        public void TestNullInputs()
        {
            var speller = new Speller();

            Assert.ThrowsException <ArgumentException>(() => speller.Spell((string[])null));
        }
Пример #33
0
        public void TestHelloWorld()
        {
            var output = new Speller().Spell("hello world");

            Assert.AreEqual("4433555 555666096667775553", output);
        }
Пример #34
0
 public ZeroSpeller(Speller maxNumberSpeller)
     : base(maxNumberSpeller)
 {
 }
Пример #35
0
		public void Init()
		{
			Speller = new Speller();
		}