예제 #1
0
파일: Gator.cs 프로젝트: easably/easy2learn
 public ProviderInfoForThread(string word, string codeForm, string codeTo, IDictionaryProvider provider)
 {
     m_word     = word;
     m_codeForm = codeForm;
     m_codeTo   = codeTo;
     m_Provider = provider;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DictionaryLoader"/> class.
 /// </summary>
 /// <param name="wordListService">Used to construct the wordlist contained in
 /// the <see cref="IDictionaryProvider.Dictionaries"/>.</param>
 /// <param name="dictionaryConfiguration">The dictionary configuration.</param>
 public DictionaryLoader(
     IWordListCreator wordListService,
     IDictionaryProvider dictionaryConfiguration)
 {
     this.wordListService         = wordListService;
     this.dictionaryConfiguration = dictionaryConfiguration;
     isFullyInitialized           = false;
 }
 public SiteMapModifyService(
     ISiteMapProvider siteMapProvider, IDictionaryProvider dictionaryProvider,
     IQpDataProvider qpDataProvider, ISettingsProvider settingsProvider, IMapper mapper)
 {
     _siteMapProvider    = siteMapProvider;
     _dictionaryProvider = dictionaryProvider;
     _qpDataProvider     = qpDataProvider;
     _settingsProvider   = settingsProvider;
     _mapper             = mapper;
 }
예제 #4
0
 public FormMain(IDictionaryProvider provider)
 {
     if (provider == null)
     {
         throw new ArgumentNullException(nameof(provider));
     }
     m_Provider = provider;
     m_Words    = provider.Load();
     InitializeComponent();
     RefreshCounts();
 }
 public SiteMapService(
     ISiteMapProvider siteMapProvider, IWidgetProvider widgetProvider,
     IDictionaryProvider dictionaryProvider, ISettingsProvider settingsProvider,
     IItemExtensionProvider itemExtensionProvider, IMapper mapper, ILogger <SiteMapService> logger)
 {
     _siteMapProvider       = siteMapProvider;
     _widgetProvider        = widgetProvider;
     _dictionaryProvider    = dictionaryProvider;
     _settingsProvider      = settingsProvider;
     _itemExtensionProvider = itemExtensionProvider;
     _mapper = mapper;
     _logger = logger;
 }
예제 #6
0
        public static string TransformToWords(this double number, IDictionaryProvider provider)
        {
            bool flag = provider.SpecialKeys.TryGetValue(number, out string result);

            if (flag)
            {
                return(result);
            }
            string        value   = number.ToString(System.Globalization.CultureInfo.InvariantCulture);
            StringBuilder builder = new StringBuilder();

            foreach (var t in value)
            {
                builder.Append($"{provider.Keys[t]} ");
            }
            result = builder.ToString();
            return(result);
        }
        /// <summary >
        /// Algorith for converting double in its "verbal format".
        /// </summary >
        /// <param  name = " number " > number for convirting. </param >
        /// <param  name = " provider " > interface for working with dictionaries. </param >
        /// <returns>Verbal format of number.  </returns>
        public static string TransformToWords(this double number, IDictionaryProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider), "must not be null");
            }

            bool flag = provider.SpecialKeys.TryGetValue(number, out string result);

            if (flag)
            {
                return(result);
            }

            char[]        array   = number.ToString().ToCharArray();
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < array.Length - 1; i++)
            {
                builder.Append($"{provider.Keys[array[i]]} ");
            }

            builder.Append($"{provider.Keys[array[^1]]}");
예제 #8
0
 public static Task <List <FileInfo> > CollectVocabTagFilesAsync(this IDictionaryProvider dictionaryProvider) =>
 dictionaryProvider.CollectFilesAsync(DictionaryConstants.Names.Vocab, "tag_bank_");
예제 #9
0
 public PathFinder(IDictionaryProvider dictionaryProvider, IOutputProvider outputProvider)
 {
     _dictionaryProvider = dictionaryProvider;
     _outputProvider = outputProvider;
 }
예제 #10
0
 public static Task <List <FileInfo> > CollectKanjiFilesAsync(this IDictionaryProvider dictionaryProvider) =>
 dictionaryProvider.CollectFilesAsync(DictionaryConstants.Names.Kanji, "kanji_bank_");
예제 #11
0
 public CultureService(IDictionaryProvider dictionaryProvider, IMapper mapper)
 {
     _dictionaryProvider = dictionaryProvider;
     _mapper             = mapper;
 }
예제 #12
0
 public VocabDictionaryService(
     IDictionaryProvider dictionaryProvider)
 {
     _dictionaryProvider = dictionaryProvider;
 }
예제 #13
0
 public static Task <FileInfo> GetSimilarNotoFileAsync(this IDictionaryProvider dictionaryProvider) =>
 dictionaryProvider.GetFileAsync("noto.json");
예제 #14
0
 public SimilarNotoDictionaryService(
     IDictionaryProvider dictionaryProvider)
 {
     _dictionaryProvider = dictionaryProvider;
 }
 public ItemDifinitionService(IDictionaryProvider dictionaryProvider, IMapper mapper)
 {
     _dictionaryProvider = dictionaryProvider;
     _mapper             = mapper;
 }
예제 #16
0
 public AnagramProvider(IDictionaryProvider dictionaryProvider)
 {
     if (dictionaryProvider == null) throw new ArgumentNullException("dictionaryProvider");
     _dictionaryProvider = dictionaryProvider;
 }
예제 #17
0
 //            ViewForDictionary(IDictionaryProvider dictionaryProvider)
 public DictionaryProviderViewForList(Type dictionaryProvider)
 {
     this.dictionaryProvider = (IDictionaryProvider)Activator.CreateInstance(dictionaryProvider);
 }
예제 #18
0
 public FixedLengthDictionaryProvider(IDictionaryProvider dictionaryProvider, int length)
 {
     _dictionaryProvider = dictionaryProvider;
     _length             = length;
 }
 public RegionService(IDictionaryProvider dictionaryProvider, ISettingsProvider settingsProvider, IMapper mapper)
 {
     _dictionaryProvider = dictionaryProvider;
     _settingsProvider   = settingsProvider;
     _mapper             = mapper;
 }
예제 #20
0
파일: Gator.cs 프로젝트: easably/easy2learn
        public String GetContents(string word, string codeForm, string codeTo)
        {
            List <IDictionaryProvider> dictionaries = new List <IDictionaryProvider>();

            foreach (Type type in GlobalOptions.WorkedDictionaries)
            {
                IDictionaryProvider provider = (IDictionaryProvider)Activator.CreateInstance(type);
                //TODO: здесь бы вставить и проверку поддержки языка
                if (!provider.OnlyAsUrlProvider)
                {
                    dictionaries.Add(provider);
                }
            }

            if (string.IsNullOrEmpty(word))
            {
                return("");
            }
            string fileName = GetFileName(word, codeForm, codeTo);

            // if (File.Exists(fileName)) return fileName;
//            if (!WWW.IsOnline()) return "";

            threads.Clear();
            string body = "";

            foreach (DictionaryProvider provider in dictionaries)
            {
                ProviderInfoForThread ex = new ProviderInfoForThread(word, codeForm, codeTo, provider);
                Thread th = new Thread(ex.Execute)
                {
                };
                th.Name = string.Format("{0} provider for word '{1}'", provider.Title, word);
                threads.Add(th);
                th.Start();
            }
            WaitUntilFinished();
            foreach (DictionaryProvider provider in dictionaries)
            {
                string content = provider.GetContent(word, codeForm, codeTo);
                if (string.IsNullOrEmpty(content))
                {
                    continue;
                }
                DictionaryProvider.ResultFromResponse res = provider.LastResultFromResponse;
                if (res != null)
                {
                    body += string.Format(ArticleReferenceTemplate,
                                          res.LastURL, provider.Title, res.Content, res.AcceptedLanguageCode);
                }
            }
            if (string.IsNullOrEmpty(body))
            {
                if (File.Exists(fileName))
                {
                    return(fileName);
                }
                return("");
            }
            string s = HtmlFileTemplate.Replace("{0}", word);

            s = s.Replace("{1}", body);
            FileManager.CreateFile(fileName, s);
            return(fileName);
        }
 public SimilarKeiseiDictionaryService(
     IDictionaryProvider dictionaryProvider)
 {
     _dictionaryProvider = dictionaryProvider;
 }
예제 #22
0
 public KradFileProvider(
     IDictionaryProvider dictionaryProvider)
 {
     _dictionaryProvider = dictionaryProvider;
 }
예제 #23
0
 public static Task <FileInfo> GetRadkFile2Async(this IDictionaryProvider dictionaryProvider) =>
 dictionaryProvider.GetFileAsync("kradzip/radkfile2");
예제 #24
0
 public static Task <FileInfo> GetNiaiSimilarRadicalsAsync(this IDictionaryProvider dictionaryProvider) =>
 dictionaryProvider.GetFileAsync("niai/similar-radicals.txt");
예제 #25
0
		public static Task<FileInfo> GetSimilarKeiseiFileAsync(this IDictionaryProvider dictionaryProvider) =>
			dictionaryProvider.GetFileAsync("from_keisei.json");
예제 #26
0
 public KanjiDictionaryService(
     IDictionaryProvider dictionaryProvider)
 {
     _dictionaryProvider = dictionaryProvider;
 }
예제 #27
0
 public static Task <List <FileInfo> > CollectVocabFrequencyFilesAsync(this IDictionaryProvider dictionaryProvider) =>
 dictionaryProvider.CollectFilesAsync(DictionaryConstants.Names.Frequency, "term_meta_bank_");
예제 #28
0
 public NiaiFileProvider(
     IDictionaryProvider dictionaryProvider)
 {
     _dictionaryProvider = dictionaryProvider;
 }
예제 #29
0
 public ProcessRunner(IDictionaryProvider dictionaryProvider, IShortestPathCalculator shortestPathCalculator, IResultProcessor resultProcessor)
 {
     _dictionaryProvider     = dictionaryProvider;
     _shortestPathCalculator = shortestPathCalculator;
     _resultProcessor        = resultProcessor;
 }
예제 #30
0
 public FrequencyDictionaryService(
     IDictionaryProvider dictionaryProvider)
 {
     _dictionaryProvider = dictionaryProvider;
 }
예제 #31
0
 public static Task <FileInfo> GetKradFileAsync(this IDictionaryProvider dictionaryProvider) =>
 dictionaryProvider.GetFileAsync("kradzip/kradfile");