Beispiel #1
0
        private List <ChattingElement> ExtractElement(string filename)
        {
            List <ChattingElement> res = new List <ChattingElement>();

            StreamReader sr = new StreamReader(filename);

            while (!sr.EndOfStream)
            {
                string line = sr.ReadLine();
                if (line == "")
                {
                    continue;
                }

                string role = ExtractRole(line);
                if (role == "")
                {
                    continue;
                }

                //Only if the current line has a role, the next line is the sentence the role says.
                ChattingElement element = new ChattingElement();
                element.Role     = role;
                element.Sentence = sr.ReadLine();

                res.Add(element);
            }

            return(res);
        }
Beispiel #2
0
        private bool ShouldFiltered(ChattingElement element)
        {
            //Picture and expression contains brackets like "[表情]", "[图片]".
            const char leftBra  = '[';
            const char rightBra = ']';

            if (element.Sentence.Contains(leftBra) && element.Sentence.Contains(rightBra))
            {
                return(true);
            }

            //Filter web site.
            if (element.Sentence.Contains("http") || element.Sentence.Contains("www"))
            {
                return(true);
            }

            if (element.Sentence.Trim() == "")
            {
                return(true);
            }

            return(false);
        }