Exemplo n.º 1
0
        private static void TryToGetSentencesOnThisSite(IQuest quest, List <string> sens, string url)
        {
            var raw_Text      = FileHtmlControls.GetTextFromSite(url);
            var raw_sentences = GetRawSentencesFromSource(raw_Text);

            foreach (var sen in raw_sentences)
            {
                if (DoesSenContainsVoc(quest, sen) && !sens.Contains(sen))
                {
                    sens.Add(sen);
                }
            }
        }
        private void LoadPronunQuest()
        {
            actualQuest = QuestControl.GetRandomAvailableQuestion(Model.Pron, passedQuestIds);

            while (cb_justTH.IsChecked.Value &&
                   (!(actualQuest as PronVM).Phonemes.Contains("θ") && !(actualQuest as PronVM).Phonemes.Contains("ð")))
            {
                actualQuest = QuestControl.GetRandomAvailableQuestion(Model.Pron, passedQuestIds);
            }

            lblWord.Content     = actualQuest.Text;
            lblPhonemes.Content = (actualQuest as PronVM).Phonemes;

            FileHtmlControls.PlayPronunciation(actualQuest.Text);
            passedQuestIds.Add(actualQuest.Id);
        }
Exemplo n.º 3
0
        public static ComboChallenge BuildSynonyms(string word, List <string> invalid_synonyms, ComboChallenge reference, StackPanel parent, bool isFirstUp, Microsoft.Office.Interop.Word.Application wordApp)
        {
            reference.VerticalContentAlignment = VerticalAlignment.Center;
            reference.Margin = new Thickness(1, 0, 1, 0);
            parent.Children.Add(reference);

            var synonyms = FileHtmlControls.GetSynonyms(word, invalid_synonyms, wordApp).ToList();

            if (isFirstUp)
            {
                synonyms.ForEach(x => x.First().ToString().ToUpper());
                word = word.UpperFirst();
            }

            if (!synonyms.Any())
            {
                synonyms = FileHtmlControls.GetSynonymsOnWeb(word, invalid_synonyms, isFirstUp);
            }

            if (!synonyms.Any())
            {
                Errors.ThrowErrorMsg(ErrorType.SynonymsNotFound, word);
            }

            var service = PluralizationService.CreateService(System.Globalization.CultureInfo.CurrentCulture);

            if (service.IsPlural(word))
            {
                for (int i = 0; i < synonyms.Count; i++)
                {
                    synonyms[i] = service.Pluralize(synonyms[i]);
                }
            }

            synonyms.Add(word);

            var shuffled = synonyms.OrderBy(x => Guid.NewGuid()).ToList();

            reference.ItemsSource   = shuffled;
            reference.SelectedIndex = 0;
            reference.CorrectIndex  = reference.Items.IndexOf(word);

            return(reference);
        }
 private void BtnListenAgain_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     FileHtmlControls.PlayPronunciation(actualQuest.Text);
 }
        private static Control CreateSentence(ChalLine line, StackPanel parent, Microsoft.Office.Interop.Word.Application wordApp)
        {
            var ctrl = new Control();

            string sentence = Sentences.GetSentenceToQuestion(line.Quest);

            var invalid_synonyms = GetInvalidSynonyms(line.Quest);

            //Console.WriteLine(sentence);

            var found = false;

            foreach (var word in sentence.SplitSentence())
            {
                if (found)
                {
                    CreateDefaultLabel(line, parent, word);
                    continue;
                }

                if (line.Quest.Type == Model.Voc)
                {
                    string answer = (line.Quest as VocVM).Answer;
                    var    answers_compatibility = Sentences.GetCompatibleWord(answer, word);

                    if (answers_compatibility.Length > 0)
                    {
                        ctrl = new ComboChallenge();
                        MyCbBxs.BuildSynonyms(answers_compatibility, invalid_synonyms, ctrl as ComboChallenge,
                                              parent, char.IsUpper(word[1]), wordApp);
                        found = true;
                    }
                    else
                    {
                        CreateDefaultLabel(line, parent, word);
                    }
                }
                else if (line.Quest.Type == Model.Spell)
                {
                    string text = (line.Quest as SpellVM).Text;


                    if (word.ContainsInsensitive(text))
                    {
                        ctrl = new TextBox();
                        ctrl.VerticalContentAlignment = VerticalAlignment.Center;
                        ctrl.Margin = new Thickness(1, 0, 1, 0);
                        ctrl.Width  = text.Length * 5 + 26;

                        ctrl.GotFocus += (source, e) => FileHtmlControls.PlayPronunciation(text, ctrl);
                        ctrl.KeyDown  += (source, e) =>
                        {
                            if (e.Key == System.Windows.Input.Key.Enter && line.Quest.Type == Model.Spell)
                            {
                                FileHtmlControls.PlayPronunciation(text, ctrl);
                            }
                        };

                        if (!text.EqualsNoCase(word))
                        {
                            //Console.WriteLine("answer was " + text);
                            var dif = word.ReplaceIgnoreCase(text, "");
                            (ctrl as TextBox).Text = dif;
                        }

                        parent.Children.Add(ctrl);
                        found = true;
                    }
                    else
                    {
                        CreateDefaultLabel(line, parent, word);
                    }
                }
            }

            return(ctrl);
        }