示例#1
0
        public override bool Equals(object obj)
        {
            if (!(obj is UnmappedQuestionAnswerModel))
            {
                return(false);
            }

            UnmappedQuestionAnswerModel model = obj as UnmappedQuestionAnswerModel;

            return(model.Answer.Equals(this.Answer) && model.Question.Equals(this.Question));
        }
示例#2
0
        public static HashSet <UnmappedQuestionAnswerModel> GetQuestionAnswerMap(List <string> paths)
        {
            if (paths == null)
            {
                throw new System.ArgumentNullException(nameof(paths));
            }

            HashSet <UnmappedQuestionAnswerModel> FAQS = new HashSet <UnmappedQuestionAnswerModel>();
            HashSet <string> questionInserted          = new HashSet <string>();

            foreach (string path in paths)
            {
                string   rawData   = File.ReadAllText(path);
                string[] eachLines = rawData.Split('\n');
                for (int line = 1; line < eachLines.Length; line++)
                {
                    string[] lineSplit = eachLines[line].Split('\t');
                    if (lineSplit.Length >= 2 && !questionInserted.Contains(lineSplit[0]))
                    {
                        questionInserted.Add(lineSplit[0]);
                        UnmappedQuestionAnswerModel model = new UnmappedQuestionAnswerModel()
                        {
                            Question = lineSplit[0],
                            Answer   = lineSplit[1],
                        };

                        if (lineSplit.Length >= 3)
                        {
                            model.Source = string.IsNullOrEmpty(lineSplit[2]) ? null : lineSplit[2];
                            if (lineSplit.Length >= 4)
                            {
                                model.MetaInfo = string.IsNullOrEmpty(lineSplit[3]) ? null : lineSplit[3];
                            }
                        }

                        FAQS.Add(model);
                    }
                }
            }

            return(FAQS);
        }