【发布时间】:2010-09-18 10:35:24
【问题描述】:
我需要解析实时聊天对话的记录。我看到文件的第一个想法是在问题上抛出正则表达式,但我想知道人们使用了哪些其他方法。
我在标题中加上了优雅,因为我之前发现这种类型的任务存在仅依靠正则表达式难以维护的危险。
成绩单由 www.providesupport.com 生成并通过电子邮件发送到一个帐户,然后我从电子邮件中提取纯文本成绩单附件。
解析文件的原因是为了提取对话文本以供以后使用,同时也是为了识别访问者和操作员的姓名,以便可以通过 CRM 提供信息。
这是一个脚本文件的示例:
Chat Transcript
Visitor: Random Website Visitor
Operator: Milton
Company: Initech
Started: 16 Oct 2008 9:13:58
Finished: 16 Oct 2008 9:45:44
Random Website Visitor: Where do i get the cover sheet for the TPS report?
* There are no operators available at the moment. If you would like to leave a message, please type it in the input field below and click "Send" button
* Call accepted by operator Milton. Currently in room: Milton, Random Website Visitor.
Milton: Y-- Excuse me. You-- I believe you have my stapler?
Random Website Visitor: I really just need the cover sheet, okay?
Milton: it's not okay because if they take my stapler then I'll, I'll, I'll set the building on fire...
Random Website Visitor: oh i found it, thanks anyway.
* Random Website Visitor is now off-line and may not reply. Currently in room: Milton.
Milton: Well, Ok. But… that's the last straw.
* Milton has left the conversation. Currently in room: room is empty.
Visitor Details
---------------
Your Name: Random Website Visitor
Your Question: Where do i get the cover sheet for the TPS report?
IP Address: 255.255.255.255
Host Name: 255.255.255.255
Referrer: Unknown
Browser/OS: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)
【问题讨论】:
-
格式会有多少变化?页眉/页脚行的顺序是否始终相同?是否有可选的页眉/页脚?
标签: python ruby perl text-parsing