예제 #1
0
        public translateVM()
        {
            StatusReset.Interval = new TimeSpan(0, 0, 5);
            StatusReset.Tick += StatusReset_Tick;

            bgWorker = new BackgroundWorker();
            bgWorker.DoWork += new DoWorkEventHandler(ExecuteGetTranslatedWrdFromVocabulary);
            bgWorker.RunWorkerCompleted += GetTranslation_RunWorkerCompleted;

            this.client = new TranslateServiceClient();
            this.TranslationMode = Mode.EngToRus;
            this.Translations = new ObservableCollection<string>();
            this.GetTranslatedWordFromVocabulary = new DelegateCommand(GetTranslatedWrdFromVocabulary,
                (x)=>this.TranslatedWord!="" );
            this.Exit = new DelegateCommand(closeApp);
            this.MinimizeWindow = new DelegateCommand(minimize);
            this.ShowEditForm = new DelegateCommand(ShowClientViewEdit);
            this.Status = "";
        }
예제 #2
0
        public editVM()
        {
            StatusReset.Interval = new TimeSpan(0, 0, 5);
            StatusReset.Tick += StatusReset_Tick;

            bgWorker = new BackgroundWorker();
            bgWorker.DoWork += new DoWorkEventHandler(ExecuteGetTranslatedWrdFromVocabulary);
            bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(GetTranslatedWrdFromVocabulary_Completed);

            bgWorkerForAdd = new BackgroundWorker();
            bgWorkerForAdd.DoWork += new DoWorkEventHandler(ExecuteAddWordToVocabulary);
            bgWorkerForAdd.RunWorkerCompleted += new RunWorkerCompletedEventHandler(AddWordToVocabulary_Completed);

            bgWorkerForUpdate = new BackgroundWorker();
            bgWorkerForUpdate.DoWork += new DoWorkEventHandler(ExecuteUpdateWrdToVocabulary);
            bgWorkerForUpdate.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UpdateWrdToVocabulary_Completed);

            bgWorkerForRemove = new BackgroundWorker();
            bgWorkerForRemove.DoWork += new DoWorkEventHandler(ExecuteRemoveWrdFromVocabulary);
            bgWorkerForRemove.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RemoveWordFromVocabulary_Completed);

            this.client = new TranslateServiceClient();
            this.TranslationMode = Mode.EngToRus;
            this.Translations = new ObservableCollection<string>();
            this.AddToTranslations = new DelegateCommand(AddWordToTbTranslations, (y)=>TranslationCurrent.Length>0);
            this.AddWordToVocabulary = new DelegateCommand(AddWrdToVocabulary, (x)=>TranslatedWord.Length>0 && Translations.Count>0);
            this.RemoveWordFromVocabulary = new DelegateCommand(RemoveWrdFromVocabulary, (x) => TranslatedWord.Length > 0);
            this.UpdateWordToVocabulary = new DelegateCommand(UpdateWrdToVocabulary, (x)=>TranslatedWord.Length>0 && Translations.Count>0);
            this.GetTranslatedWordFromVocabulary = new DelegateCommand(GetTranslatedWrdFromVocabulary, (x) => TranslatedWord != "");
            this.RemoveLastAddedTranslation = new DelegateCommand(RemoveLastAddedItemFromTranslations,
                (x) => this.SelectedTranslation != "" && this.SelectedTranslation!=null);
            this.RemoveAllTranslations = new DelegateCommand(deleteAllTranslations,
                (x) => this.Translations.Count > 0);
            this.Exit = new DelegateCommand(closeApp);
            this.MinimizeWindow = new DelegateCommand(minimize);
        }
 public TranslateServiceClientTests()
 {
     _instance = new TranslateServiceClient();
 }
예제 #4
0
 public Demo2Controller(NewsArticleProviderFactory newsArticleProviderFactory, TranslateServiceClient translateServiceClient)
 {
     _newsArticleProvider    = newsArticleProviderFactory.Create();
     _translateServiceClient = translateServiceClient;
 }
예제 #5
0
        // Porównanie efektywności algorytmów 1 i 2 dla wszystkich języków
        public void CreateComparisonOfAlgorithmEffectivenessForAllLanguages()
        {
            Dictionary <Language, int> alg1SuccessfulDetection   = new Dictionary <Language, int>();
            Dictionary <Language, int> alg2SuccessfulDetection   = new Dictionary <Language, int>();
            Dictionary <Language, int> googleSuccessfulDetection = new Dictionary <Language, int>();
            Alg1Analizer           alg1 = new Alg1Analizer(languageDictionaries);
            Alg2Analizer           alg2 = new Alg2Analizer(languageDictionaries);
            TranslateServiceClient translateServiceClient = new TranslateServiceClient();

            foreach (Language language in pathsToArticles.Keys)
            {
                int alg1SuccessfulDetectionCount   = 0;
                int alg2SuccessfulDetectionCount   = 0;
                int googleSuccessfulDetectionCount = 0;
                int numberOfArticlesToAnalyze      = 10;

                string   path  = pathsToArticles[language];
                string[] lines = System.IO.File.ReadAllLines(path);
                foreach (string url in lines)
                {
                    string content = urlsToArticles[url].Content;
                    content = content.Substring(0, content.Length / 10);

                    // Algorytm 1
                    Analysis analysis = alg1.Analize(content);
                    if (analysis.GetDiscoveredLanguage().Equals(language))
                    {
                        alg1SuccessfulDetectionCount++;
                    }

                    // Algorytm 2
                    Analysis analysis2 = alg2.Analize(content);
                    if (analysis2.GetDiscoveredLanguage().Equals(language))
                    {
                        alg2SuccessfulDetectionCount++;
                    }

                    Console.WriteLine("Google: {0}", url);

                    Language googleLanguage = translateServiceClient.DetectLanguage(content);
                    if (googleLanguage.Equals(language))
                    {
                        googleSuccessfulDetectionCount++;
                    }
                }
                alg1SuccessfulDetection.Add(language, alg1SuccessfulDetectionCount);
                alg2SuccessfulDetection.Add(language, alg2SuccessfulDetectionCount);
                googleSuccessfulDetection.Add(language, googleSuccessfulDetectionCount);
            }

            string csvPath = "../../comparisons/alg_comparison_all_lang.csv";

            if (!File.Exists(csvPath))
            {
                File.Create(csvPath).Close();
            }
            using (TextWriter writer = new StreamWriter(csvPath, false, Encoding.UTF8)) {
                writer.WriteLine("Porównanie algorytmów 1 i 2 - wszystkie języki;;;;;;;");
                writer.WriteLine(";EN;DE;FR;ES;PT;IT");
                writer.WriteLine("Alg. 1;" + alg1SuccessfulDetection[Language.English] + ";"
                                 + alg1SuccessfulDetection[Language.German] + ";"
                                 // + alg1SuccessfulDetection[Language.Polish] + ";"
                                 + alg1SuccessfulDetection[Language.French] + ";"
                                 + alg1SuccessfulDetection[Language.Spanish] + ";"
                                 + alg1SuccessfulDetection[Language.Portuguese] + ";"
                                 + alg1SuccessfulDetection[Language.Italian]);

                writer.WriteLine("Alg. 2;" + alg2SuccessfulDetection[Language.English] + ";"
                                 + alg2SuccessfulDetection[Language.German] + ";"
                                 // + alg2SuccessfulDetection[Language.Polish] + ";"
                                 + alg2SuccessfulDetection[Language.French] + ";"
                                 + alg2SuccessfulDetection[Language.Spanish] + ";"
                                 + alg2SuccessfulDetection[Language.Portuguese] + ";"
                                 + alg2SuccessfulDetection[Language.Italian]);

                writer.WriteLine("Google API;" + googleSuccessfulDetection[Language.English] + ";"
                                 + googleSuccessfulDetection[Language.German] + ";"
                                 // + alg2SuccessfulDetection[Language.Polish] + ";"
                                 + googleSuccessfulDetection[Language.French] + ";"
                                 + googleSuccessfulDetection[Language.Spanish] + ";"
                                 + googleSuccessfulDetection[Language.Portuguese] + ";"
                                 + googleSuccessfulDetection[Language.Italian]);
            }
        }