def init(_): parser = argparse.ArgumentParser(description='Conversation Analyzer') parser.add_argument('-p', metavar='conversationfilePath', dest='filepath') parser.add_argument('-n', metavar='numberOfMessages', type=int, dest='numMsgs', default=0) parser.add_argument('-l', metavar='wordsCountLimit', type=int, dest='wCountLimit', default=20) args = parser.parse_args() filepath = args.filepath numMsgs = args.numMsgs wCountLimit = args.wCountLimit initLogger() #conv = ConversationDataframe(mio.getResourcesPath() + "\\unittest\\test_plotting.txt") conv = ConversationDataframe(filepath) conv.loadMessages(numMsgs) return res = conv.messages.rename(columns={'text': 'numMsgs'}) res['lenMsgs'] = res['numMsgs'].apply(lambda x: len(x)) x = pd.to_numeric(res['hour']) testCorrelation(x, res['lenMsgs'])
def main(_): parser = argparse.ArgumentParser(description='Conversation Analyzer') parser.add_argument('-p', metavar='conversationFilepath', dest='filepath', required=True) parser.add_argument('-n', metavar='numberOfMessages', type=int, dest='numMsgs', default=0, help='number of conversation messages to be analyzed') baseFolderPath = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) parser.add_argument('--conf', metavar='configFilepath', dest='configFilepath', default= baseFolderPath+'\\config.ini') args = parser.parse_args() filepath = args.filepath numMsgs = args.numMsgs CONFIG_FILEPATH = args.configFilepath STATS_SECTION = "Stats" config = configparser.ConfigParser() config.read(CONFIG_FILEPATH) P_BASIC_LENGTH_STATS = config.getboolean(STATS_SECTION, "P_BASIC_LENGTH_STATS") P_INTERVAL_STATS = config.getboolean(STATS_SECTION, "P_INTERVAL_STATS") P_WORDS_COUNT = config.getboolean(STATS_SECTION, "P_WORDS_COUNT") WORDS_COUNT_LIMIT = config.getint(STATS_SECTION, "WORDS_COUNT_LIMIT") P_WORDS_USEDJUSTBY = config.getboolean(STATS_SECTION, "P_WORDS_USEDJUSTBY") P_DELAY_STATS = config.getboolean(STATS_SECTION, "P_DELAY_STATS") P_EMOTICONS_STATS = config.getboolean(STATS_SECTION, "P_EMOTICONS_STATS") P_LEXICAL_STATS = config.getboolean(STATS_SECTION, "P_LEXICAL_STATS") #conv = Conversation(filepath) conv = ConversationDataframe(filepath) conv.loadMessages(numMsgs) if P_BASIC_LENGTH_STATS: stats = conv.stats.generateStats(IConvStats.STATS_NAME_BASICLENGTH) mio.printBasicLengthStats(stats) if P_INTERVAL_STATS: start, end, interval = conv.stats.getIntervalStats() days = conv.stats.getDaysWithoutMessages() mio.printIntervalStatsFor(start, end, interval, days) if P_LEXICAL_STATS: stats = conv.stats.generateStats(IConvStats.STATS_NAME_LEXICAL) mio.printLexicalStats(stats) if P_WORDS_COUNT: filepath = conv.statsFolder + '\\' + 'wordCount.txt' stats = conv.stats.generateStats(IConvStats.STATS_NAME_WORDCOUNT) mio.printDataFrameToFile(stats, filepath) #Works just with two senders if P_WORDS_USEDJUSTBY: mio.printWordsUsedJustByToFile(conv) if P_EMOTICONS_STATS: stats = conv.stats.generateStats(IConvStats.STATS_NAME_EMOTICONS) mio.printEmoticonsStats(stats)
def getConversation(filepath): conv = ConversationDataframe(filepath) conv.loadMessages(0) #anonymise conversation if PlottingTestCase.anonymise: sendersAliases = ['Donnie', 'Frank'] if len(sendersAliases) == len(conv.senders): aliasesMap = {key:sendersAliases[i] for i, key in enumerate(conv.senders)} conv.messages.replace({'sender':aliasesMap}, inplace=True) conv.senders = sendersAliases return conv
def init(_): parser = argparse.ArgumentParser(description='Conversation Analyzer') parser.add_argument('-p', metavar='conversationfilePath', dest='filepath') parser.add_argument('-n', metavar='numberOfMessages', type=int, dest='numMsgs', default=0) parser.add_argument('-l', metavar='wordsCountLimit', type=int, dest='wCountLimit', default=20) args = parser.parse_args() filepath = args.filepath numMsgs = args.numMsgs wCountLimit = args.wCountLimit initLogger() #conv = ConversationDataframe(mio.getResourcesPath() + "\\unittest\\test_plotting.txt") conv = ConversationDataframe(filepath) conv.loadMessages(numMsgs) return res = conv.messages.rename(columns={'text':'numMsgs'}) res['lenMsgs'] = res['numMsgs'].apply(lambda x: len(x)) x = pd.to_numeric(res['hour']) testCorrelation(x, res['lenMsgs'])
def getConversation(self, filepath): #conv = Conversation(filepath) conv = ConversationDataframe(filepath) conv.loadMessages(0) return conv