나는 Enron 전자 메일의 모든 본문을 하나의 파일에 추가하려고하므로 Stop 단어를 제거하고 NLTK로 문장으로 분할하여이 전자 메일의 텍스트를 처리 할 수 있습니다. 전달 된 메시지와 회신 한 메시지에 문제가 있습니다. 어떻게 치료할 지 모르겠습니다. Well, with the photographer and the band, I would say we've pretty much outdone our budget! Here's the information on the photographer. I have a feeling for some of the major packages we could negotiate at least a couple of hours at the rehearsal dinner. I have no idea how much this normally costs, but he isn't cheap!---------------------- Forwarded by Elizabeth Lay/HOU/AZURIX on 09/13/99 07:34 PM [email protected] on 09/13/99 05:37:37 PMPlease respond to [email protected] To: Elizabeth Lay/HOU/[email protected]: Subject: Denis Reggie Wedding PhotographyHello Elizabeth:Congratulations on your upcoming marriage! I am Ashley Collins, Mr.Reggie's Coordinator. Linda Kessler forwarded your e.mail address to me sothat I may provide you with information on photography coverage for Mr.Reggie's wedding photography.
그래서 결과는 전혀 순수 텍스트되지 않습니다Enron 전자 메일 본문에서 "전달 된 메시지"제목 및 원하지 않는 내용을 지우는 방법은 무엇입니까?
import os, email, sys, re,nltk, pprint
from email.parser import Parser
rootdir = '/Users/art/Desktop/maildir/lay-k/elizabeth'
#function that appends all the body parts of Emails
def email_analyse(inputfile, email_body):
with open(inputfile, "r") as f:
data = f.read()
email = Parser().parsestr(data)
email_body.append(email.get_payload())
#end of function
#defining a list that will contain bodies
email_body = []
#call the function email_analyse for every function in directory
for directory, subdirectory, filenames in os.walk(rootdir):
for filename in filenames:
email_analyse(os.path.join(directory, filename), email_body)
#the stage where I clean the emails
with open("email_body.txt", "w") as f:
for val in email_body:
if(val):
val = val.replace("\n", "")
val = val.replace("=01", "")
#for some reason I had many of ==20 and =01 in my text
val = val.replace("==20", "")
f.write(val)
f.write("\n")
이 부분의 출력은 다음과 같습니다 이 지금까지 내 코드입니다. 그것을 올바르게하는 방법에 대한 아이디어?