Ejemplo n.º 1
0
        public Concordance(StreamReader reader)
        {
            var c           = new ConcordanceWord();
            var wordOfText  = "";
            var numOfString = 0;

            while ((!reader.EndOfStream))
            {
                var ch = Convert.ToChar(reader.Read());
                wordOfText = wordOfText + ch;
                if ((ch == '.') || (ch == '!') || (ch == '?'))
                {
                    numOfString++;
                }
                if (
                    ((((char.IsPunctuation(ch)) || (ch == ' ')) && (ch != '#')) && (ch != '-')) &&
                    (wordOfText != " ") &&
                    (wordOfText != "\n"))
                {
                    wordOfText = wordOfText.Substring(0, wordOfText.Length - 1);
                    wordOfText = wordOfText.ToLower();
                    if (Add(wordOfText, numOfString))
                    {
                        _words[wordOfText].Intialization(); _words[wordOfText].Add(numOfString);
                    }
                    wordOfText = "";
                }
                if ((wordOfText == " ") || (ch == '\n'))
                {
                    wordOfText = "";
                }
            }
        }
Ejemplo n.º 2
0
        private bool Add(string key, int numOfString)
        {
            var c = new ConcordanceWord();

            if (!_words.ContainsKey(key))
            {
                _words.Add(key, new ConcordanceWord());
                return(true);
            }
            else
            {
                _words[key].IncrCount();
                _words[key].Add(numOfString);
                return(false);
            }
        }