Пример #1
0
        private LanguageDomainSupport UpdateConfig(string url, string auth)
        {
            var config = new LanguageDomainSupport();

            try
            {
                // try to get Configuration
                // Do not call any blocking service in the user interface thread; it has to use background threads.
                var engineConf = TartuNLPConnector.GetConfig(url, auth);

                if (engineConf == null)
                {
                    //invalid user name or password
                    config.UpdateSuccessful = false;
                }
                else
                {
                    config = loadEngineConf(engineConf);
                }
            }
            catch (Exception ex)
            {
                config.Exception = ex;
            }

            return(config);
        }
 private List <string> SearchInServer(List <string> sourceStrings)
 {
     if (_tartuNLPConnector == null)
     {
         // Use basic connection settings
         var url    = _options.URL;
         var auth   = _options.Auth;
         var domain = _options.SelectedDomainCode;
         _tartuNLPConnector = new TartuNLPConnector(url, auth, domain);
     }
     return(_tartuNLPConnector.GetTranslation(_languageDirection, sourceStrings));
 }
Пример #3
0
        private LanguageDomainSupport updateConfig(string url, string auth)
        {
            var languageDomainSupport = new LanguageDomainSupport()
            {
                URL  = url,
                Auth = auth
            };

            try
            {
                // try to get Configuration
                // Do not call any blocking service in the user interface thread; it has to use background threads.
                languageDomainSupport.JSON = TartuNLPConnector.GetConfig(url, auth);

                if (languageDomainSupport.JSON == null)
                {
                    //invalid user name or password
                    languageDomainSupport.UpdateSuccessful = false;
                }
                else
                {
                    //successful login
                    languageDomainSupport.UpdateSuccessful = true;

                    //try to get the list of the Domain in the background
                    languageDomainSupport.SupportedDomains   = new Dictionary <string, string>();
                    languageDomainSupport.SupportedLanguages = new Dictionary <string, string[]>();
                    foreach (string key in languageDomainSupport.JSON.Keys)
                    {
                        languageDomainSupport.SupportedDomains.Add(languageDomainSupport.JSON[key][0], key);
                        languageDomainSupport.SupportedLanguages.Add(languageDomainSupport.JSON[key][0], languageDomainSupport.JSON[key]);
                    }
                }
            }
            catch (Exception ex)
            {
                languageDomainSupport.Exception = ex;
            }

            return(languageDomainSupport);
        }