示例#1
0
        public void SaveDictionary(IWordsDictionary dict)
        {
            var dic = db.Languages.FirstOrDefault(x => x.Language == dict.Language);

            if (dic == null)
            {
                db.Languages.Add(new LanguageString()
                {
                    Language = dict.Language
                });
                foreach (var w in dict.Words)
                {
                    db.Words.Add((Word)w);
                }
            }
            else
            {
                foreach (var w in dict.Words)
                {
                    var word = db.Words.FirstOrDefault(x => x.Text == w.Text);
                    if (word == null)
                    {
                        db.Words.Add((Word)w);
                    }
                    else
                    {
                        word.Picture = w.Picture;
                    }
                }
            }
            db.SaveChanges();
        }
        public AnalysisResultsForm(IWordsDictionary wordsDictionary)
        {
            this.wordsDictionary = wordsDictionary;

            InitializeComponent();

            FoundWordsListBox.SelectedValueChanged += FoundWordsListBox_SelectedValueChanged;
        }
示例#3
0
        private void AddNewDictionary()
        {
            NewDictionaryName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(NewDictionaryName.ToLower());
            IWordsDictionary dict = _dao.CreateNewDictionary();

            dict.Language = NewDictionaryName;
            dict.Words    = new List <IWord>();
            _dictionaries.Add(dict);
            SelectedDictionary = dict;
            SelectedWord       = null;
        }
        public SentenceRepair(IWordsDictionary dictionary, string lightMask, string mask, string replaceMask)
        {
            if (string.IsNullOrEmpty(mask))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(mask));
            }

            this.mask        = mask;
            this.replaceMask = replaceMask ?? throw new ArgumentNullException(nameof(replaceMask));
            this.dictionary  = dictionary ?? throw new ArgumentNullException(nameof(dictionary));
            this.lightMask   = lightMask;
        }
示例#5
0
文件: DAO.cs 项目: Andrzej07/studia
        public void SaveDictionary(IWordsDictionary dict)
        {
            var dic = _dicts.FirstOrDefault(x => x.Language == dict.Language);

            if (dic == null)
            {
                _dicts.Add(dict);
            }
            else
            {
                dic = dict;
            }
        }
        public SentenceRepairHandler(ILexiconConfiguration path, IWordsDictionary dictionary)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            cleanup = new EmojyCleanup();
            cleanup.NormalizeText = false;
            resourcesPath         = Path.Combine(path.LexiconPath, "Repair");
            this.dictionary       = dictionary ?? throw new ArgumentNullException(nameof(dictionary));
            Load();
        }
示例#7
0
        private void DoFilter(IWordsDictionary dict, string filter)
        {
            if (dict == null)
            {
                return;
            }
            if (dict.Words == null)
            {
                return;
            }
            var view = CollectionViewSource.GetDefaultView(dict.Words);

            if (filter.Length > 0)
            {
                view.Filter = (w) => ((IWord)w).Text.Contains(filter, StringComparison.OrdinalIgnoreCase);
            }
            else
            {
                view.Filter = null;
            }
        }
示例#8
0
 public WordsBuilder(IWordsDictionary dictionary)
 {
     this.Dictionary = dictionary;
 }
 public DefaultDocumentProcessor(IWordProcessor wordProcessor, IWordsDictionary wordsDictionary, Func<IWordLexer> lexerFactory)
 {
     this.wordProcessor = wordProcessor;
     this.wordsDictionary = wordsDictionary;
     this.lexerFactory = lexerFactory;
 }
示例#10
0
 public RawWordExtractor(IWordsDictionary dictionary, IMemoryCache cache)
 {
     Dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary));
     this.cache = cache ?? throw new ArgumentNullException(nameof(cache));
     service    = new PluralizationServiceInstance();
 }
示例#11
0
 public WordsBuilder(IWordsDictionary dictionary)
 {
     this.Dictionary = dictionary;
 }
 public AddDiacriticsesProcess(IDocument document, IWordsDictionary wordsDictionary, Func<IWordLexer> lexerFactory)
 {
     this.document = document;
     this.wordsDictionary = wordsDictionary;
     this.lexerFactory = lexerFactory;
 }