Exemplo n.º 1
0
        /// <summary>
        /// 计算聊天连续度并输出至给定路径的文件
        /// 聊天连续度定义为:在前一条聊天记录为用户1(男方)所发情况下,后面第一条用户2(女方)回复的聊天记录出现的平均间隔时间
        ///
        /// 文件格式:聊天起始时间\t聊天条数时间比
        /// </summary>
        /// <param name="filePath">输出文件路径</param>
        static void ContinuityStatistic(string filePath)
        {
            StreamWriter fWriter = new StreamWriter(filePath);

            DateTime lastTimeStamp = DateTime.Today;
            ChatWord lastChatWord  = new ChatWord();

            foreach (var logsOneDay in chatLogs)
            {
                double timeSpan   = 0;
                int    crossCount = 0;
                foreach (var log in logsOneDay.Value)
                {
                    if (!lastTimeStamp.Equals(DateTime.Today) && lastChatWord.user.Equals(User1) && log.user.Equals(User2) && !SleepingTime(ref lastChatWord.timeStamp, ref log.timeStamp))
                    {
                        timeSpan += (log.timeStamp - lastChatWord.timeStamp).TotalMinutes;
                        crossCount++;
                    }
                    lastChatWord  = log;
                    lastTimeStamp = log.timeStamp;
                }
                timeSpan /= crossCount;
                fWriter.WriteLine(logsOneDay.Key.ToShortDateString() + "\t" + timeSpan);
            }
            fWriter.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 计算聊天连续度并输出至给定路径的文件
        /// 聊天连续度定义为:在前一条聊天记录为用户1(男方)所发情况下,后面第一条用户2(女方)回复的聊天记录出现的平均间隔时间
        /// 
        /// 文件格式:聊天起始时间\t聊天条数时间比
        /// </summary>
        /// <param name="filePath">输出文件路径</param>
        static void ContinuityStatistic(string filePath)
        {
            StreamWriter fWriter = new StreamWriter(filePath);

            DateTime lastTimeStamp = DateTime.Today;
            ChatWord lastChatWord = new ChatWord();
            foreach (var logsOneDay in chatLogs)
            {
                double timeSpan = 0;
                int crossCount = 0;
                foreach (var log in logsOneDay.Value)
                {
                    if (!lastTimeStamp.Equals(DateTime.Today) && lastChatWord.user.Equals(User1) && log.user.Equals(User2) && !SleepingTime(ref lastChatWord.timeStamp, ref log.timeStamp))
                    {
                        timeSpan += (log.timeStamp - lastChatWord.timeStamp).TotalMinutes;
                        crossCount++;
                    }
                    lastChatWord = log;
                    lastTimeStamp = log.timeStamp;
                }
                timeSpan /= crossCount;
                fWriter.WriteLine(logsOneDay.Key.ToShortDateString() + "\t" + timeSpan);
            }
            fWriter.Close();
        }