Example #1
0
        public string Task4(string data, string replaceby, int valuenumstring, int valuelenghtword)
        {
            string answer = data;

            if (valuelenghtword != 0)
            {
                answer = string.Empty;
                List <string> sentences = new List <string>();
                sentences = Senteces.GetSentences(data);

                string        sentence = sentences.ElementAt(valuenumstring);
                List <string> words    = new List <string>();
                words = Words.GetWords(sentence);
                foreach (var word in words)
                {
                    if (word.Length == valuelenghtword)
                    {
                        sentence = Regex.Replace(sentence, word, replaceby);
                        sentences[valuenumstring] = sentences.ElementAt(valuenumstring).Replace(sentences.ElementAt(valuenumstring), sentence);
                    }
                }
                foreach (var sent in sentences)
                {
                    answer += sent;
                }
            }

            return(answer);
        }
Example #2
0
        public string Task3(string data, int value)
        {
            List <string> sentences = new List <string>();
            List <string> words     = new List <string>();
            List <string> delwords  = new List <string>();

            sentences = Senteces.GetSentences(data);
            foreach (var sentence in sentences)
            {
                words = Words.GetWords(sentence);
                foreach (var word in words)
                {
                    if (Words.IsConsonant(word) && word.Length == value)
                    {
                        delwords.Add(word);
                    }
                }
            }
            string answer = string.Empty;

            foreach (var sentence in sentences)
            {
                string s = sentence;
                foreach (var delword in delwords)
                {
                    if (sentence.Contains(delword))
                    {
                        s = Regex.Replace(sentence, delword, "");
                    }
                }
                answer += s;
            }
            return(answer);
        }
Example #3
0
        public static List <int> GetWordsCount(string data)
        {
            List <string> sentences = new List <string>();

            sentences = Senteces.GetSentences(data);

            List <int> wordsCount = new List <int>();

            foreach (var s in sentences)
            {
                wordsCount.Add(GetWords(s).Count);
            }

            return(wordsCount);
        }
Example #4
0
        public List <string> GetQustionSentence(string data)
        {
            List <string> questionsentence = new List <string>();
            List <string> sentences        = new List <string>();

            sentences = Senteces.GetSentences(data);
            foreach (var sentence in sentences)
            {
                if (Senteces.IsQpestion(sentence))
                {
                    questionsentence.Add(sentence);
                }
            }

            return(questionsentence);
        }
Example #5
0
        public Sentence[] GetSentences(string data)//заполняем массив вордс каунт
        {
            List <string> sentences = new List <string>();

            sentences = Senteces.GetSentences(data);

            List <int> wordsCount = new List <int>();

            wordsCount = Words.GetWordsCount(data);

            Sentence[] sentence = new Sentence[sentences.Count];

            for (int i = 0; i < sentences.Count; i++)
            {
                sentence[i].Text       = sentences[i];
                sentence[i].WordsCount = wordsCount[i];
            }
            return(sentence);
        }
Example #6
0
        public static List <string> OneWords(string data)
        {
            List <string> sentence = new List <string>();

            sentence = Senteces.GetSentences(data);
            List <string> words    = new List <string>();
            List <string> onewords = new List <string>();

            foreach (var sentenc in sentence)
            {
                words = Words.GetWords(sentenc);
                foreach (var word in words)
                {
                    if (!onewords.Contains(word) && word != "" && !char.IsDigit(word[0]))
                    {
                        onewords.Add(word);
                    }
                }
            }

            return(onewords);
        }
Example #7
0
        public static Word[] GetWordsAZ(string data)
        {
            List <string> wordsOne = new List <string>();

            wordsOne = Words.OneWords(data);
            List <string> sentence = new List <string>();

            sentence = Senteces.GetSentences(data);
            List <string> words = new List <string>();
            bool          flag  = false;

            Word[] wordvalue = new Word[wordsOne.Count];
            for (int i = 0; i < wordsOne.Count; i++)
            {
                wordvalue[i].Text += wordsOne[i];
                for (int j = 0; j < sentence.Count; j++)
                {
                    words = Words.GetWords(sentence[j]);
                    for (int k = 0; k < words.Count; k++)
                    {
                        if (wordsOne[i] == words[k])
                        {
                            flag = true;
                            wordvalue[i].CountString++;
                        }
                    }
                    if (flag == true)
                    {
                        wordvalue[i].NumberOfSentence += j.ToString();
                        wordvalue[i].NumberOfSentence += " ";
                        flag = false;
                    }
                }
            }
            return(wordvalue);
        }