Ejemplo n.º 1
0
        private IReadOnlyList <string> suggestByInput(string query, int caret, string language)
        {
            var sw = new Stopwatch();

            sw.Start();

            var suggest = Spellchecker.Suggest(new TextInputState(query, caret, selectionLength: 0), language);

            sw.Stop();
            Log.Debug($"Suggest retrieved in {sw.ElapsedMilliseconds} ms");

            Assert.That(suggest, Is.Not.Null);

            var list = suggest.Values;

            Assert.That(list, Is.Not.Null);

            Log.Debug("Token: " + suggest.Token);
            Log.Debug("Suggest:");

            foreach (string variant in list)
            {
                Log.Debug(variant);
            }

            return(list);
        }
Ejemplo n.º 2
0
        public IntellisenseSuggest Suggest(TextInputState searchState, UiModel ui)
        {
            ensureIndexIsUpToDate(ui);

            lock (_sync)
                return(Spellchecker.Suggest(language: null, input: searchState));
        }
Ejemplo n.º 3
0
        protected override Directory LoadSpellcheckerIndex()
        {
            Directory index;

            if (_version.IsUpToDate)
            {
                index = FSDirectory.Open(_version.Directory);
                Spellchecker.Load(index);
                return(index);
            }

            if (!_repo.IsLocalizationLoadingComplete)
            {
                throw new InvalidOperationException($"{nameof(CardRepository)} must load localizations first");
            }

            _version.CreateDirectory();

            index = base.LoadSpellcheckerIndex();

            index.SaveTo(_version.Directory);
            _version.SetIsUpToDate();

            return(index);
        }
Ejemplo n.º 4
0
        public void Fehler_finden()
        {
            var wörter   = new[] { "Brinen", "Aeppel" };
            var lexikon  = new HashSet <string>(new[] { "Äpfel", "Birnen", "Kirschen", "Aprikosen", "Pflaumen" });
            var ergebnis = Spellchecker.Wörter_auf_Fehler_überprüfen(wörter, lexikon);

            Assert.AreEqual(new[] { "Brinen", "Aeppel" }, ergebnis.ToArray());
        }
Ejemplo n.º 5
0
 public DeckSpellcheckerState(
     Spellchecker spellchecker,
     DeckSearcherState searcherState,
     DeckDocumentAdapter adapter,
     Func <int> maxCount,
     bool loaded) :
     base(spellchecker, searcherState, adapter, maxCount, loaded)
 {
     _models = searcherState.Models;
 }
Ejemplo n.º 6
0
 protected override LuceneSpellcheckerState <long, DeckModel> CreateState(
     LuceneSearcherState <long, DeckModel> searcherState,
     Spellchecker spellchecker,
     bool loaded) =>
 new DeckSpellcheckerState(
     spellchecker,
     (DeckSearcherState)searcherState,
     (DeckDocumentAdapter)Adapter,
     () => MaxCount,
     loaded);
Ejemplo n.º 7
0
        public SpellcheckState(
            Spellchecker spellchecker,
            SpellingData data,
            IEnumerable <Filter>?filters = null)
        {
            Spellchecker = spellchecker;
            Data         = data;
            Filters      = filters?.ToImmutableArray() ?? ImmutableArray <Filter> .Empty;

            OriginalFixes = data.Fixes;
        }
Ejemplo n.º 8
0
 public CardSpellcheckerState(
     CardRepository repo,
     Spellchecker spellchecker,
     CardSearcherState searcherState,
     IDocumentAdapter <int, Card> adapter,
     Func <int> maxCount,
     bool loaded) :
     base(spellchecker, searcherState, adapter, maxCount, loaded)
 {
     _repo = repo;
 }
Ejemplo n.º 9
0
        public bool TryParse(SpellcheckCommandOptions options)
        {
            var baseOptions = (CommonReplaceCommandOptions)options;

            if (!TryParse(baseOptions))
            {
                return(false);
            }

            options = (SpellcheckCommandOptions)baseOptions;

            Regex?wordRegex = null;

            if (!TryEnsureFullPath(Words, out ImmutableArray <string> wordListPaths))
            {
                return(false);
            }
#if DEBUG
            if (Word.Any())
            {
                if (!FilterParser.TryParse(
                        Word,
                        OptionNames.Word,
                        OptionValueProviders.PatternOptions_Word_Provider,
                        out Filter? wordFilter))
                {
                    return(false);
                }

                wordRegex = wordFilter !.Regex;
            }
#endif
            WordListLoaderResult result = WordListLoader.Load(
                wordListPaths,
                minWordLength: MinWordLength,
                (CaseSensitive) ? WordListLoadOptions.None : WordListLoadOptions.IgnoreCase);

            var data = new SpellingData(result.List, result.CaseSensitiveList, result.FixList);

            var spellcheckerOptions = new SpellcheckerOptions(
                SplitMode.CaseAndHyphen,
                MinWordLength);

            var spellchecker = new Spellchecker(data, wordRegex, spellcheckerOptions);

            options.Replacer = new SpellcheckState(spellchecker, data);

            return(true);
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            AsParallelAndSelect ap = new AsParallelAndSelect();
            //ap.Run();

            ForceParallel fpl = new ForceParallel();
            //fpl.Run();

            Spellchecker s = new Spellchecker();
            //s.Run();

            ParallelSpellchecker ps = new ParallelSpellchecker();
            //ps.Run();

            RandomMutiThread rmt = new RandomMutiThread();
            //rmt.Run();

            ParallelSpellcheckerUsingThreadLocal asu = new ParallelSpellcheckerUsingThreadLocal();
            //asu.Run();

            FunctionalPurity fp = new FunctionalPurity();
            //fp.Run();

            MergeOptions mo = new MergeOptions();
            //mo.Run();

            DegreeOfParallelism iof = new DegreeOfParallelism();
            //iof.Run();

            Cancellation cl = new Cancellation();
            //cl.Run();
            //cl.Run2();

            OptimizingPLINQ op = new OptimizingPLINQ();
            //op.Run();
            //op.Run2();

            HandleAggregateException hae = new HandleAggregateException();

            hae.Run();
            hae.Run2();

            MeasurePerformance mp = new MeasurePerformance();
            //mp.Run();

            DoNotUsePLINQ dnup = new DoNotUsePLINQ();
            //dnup.Run();
        }
Ejemplo n.º 11
0
        protected override void OnClick()
        {
            // Check to see if Word is already opened.
            var processes = Process.GetProcessesByName("WINWORD");

            if (processes.Length > 0)
            {
                string message = "The spell check operation needs to use Microsoft Word, which is already opened. Please close Word and try again.";
                MessageBox.Show(message, "Word is already open", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0);
            }
            else
            {
                IMxDocument doc = ArcMap.Application.Document as IMxDocument;
                using (var spellchecker = new Spellchecker())
                {
                    spellchecker.CheckDocument(doc);
                }
            }
        }
Ejemplo n.º 12
0
		private IReadOnlyList<string> suggest(string field, string value, string language)
		{
			var sw = new Stopwatch();
			sw.Start();

			string query = $"{field}:{value}";

			var list = Spellchecker.Suggest(new TextInputState(query, query.Length, selectionLength: 0), language).Values;

			sw.Stop();
			Log.Debug($"Suggest retrieved in {sw.ElapsedMilliseconds} ms");

			Assert.That(list, Is.Not.Null);
			Assert.That(list, Is.Not.Empty);

			foreach (string variant in list)
				Log.Debug(variant);

			return list;
		}
Ejemplo n.º 13
0
 protected override LuceneSpellcheckerState <int, Card> CreateState(LuceneSearcherState <int, Card> searcherState, Spellchecker spellchecker, bool loaded) =>
 new CardSpellcheckerState(
     _repo,
     spellchecker,
     (CardSearcherState)searcherState, (CardDocumentAdapter)Adapter,
     () => MaxCount,
     loaded);
Ejemplo n.º 14
0
        public void Text_splitten()
        {
            var ergebnis = Spellchecker.Text_in_Wörter_zerlegen(@"Das .     ist !? mal " + "\r" + "\n" + " ein Text . zum" + "\t" + " ,,, Testen " + "\b" + " ; " + "\v");

            Assert.AreEqual(new[] { "Das", "ist", "mal", "ein", "Text", "zum", "Testen" }, ergebnis);
        }