rewrite classifier

This commit is contained in:
Andreas Stephanides
2017-08-07 10:20:28 +02:00
parent ff0bdc6d3b
commit 94d8d26187
11 changed files with 411 additions and 98 deletions

View File

@@ -35,3 +35,22 @@ def flatten_threads(thrds, array=[], level=0):
for t in thrds:
array.append(flatten_threads(t,[],1))
return array
def store_threads(thrds):
for t in thrds:
if type(t[0]) is int:
th=db_session.query(MailThread).filter(MailThread.firstmail==t[0]).first()
# Wenn nicht gefunden neuen anlegen
if th == None:
th=MailThread()
th.firstmail=t[0]
elif not th.body == yaml.dump(t): # Ansonsten body vergleichen
th.body=yaml.dump(t) # body zb (27422,27506), (27450,)
th.islabeled=False
th.opened=True
else:
th.body=yaml.dump(t)
db_session.add(th)
db_session.commit()

View File

@@ -32,6 +32,7 @@ class MailThread(Base):
__jsonattrs__=None
answered=False
maintopic="information"
lang=""
def bdy(self):
return yaml.load(self.body)
@@ -50,7 +51,7 @@ class MailThread(Base):
def tstr(self):
fr=yaml.load(self.mails()[0].from_)
return "(" + str(self.answered)+ ", "+ str(self.maintopic) + ") " + str(self.firstmail)+": "+str(fr[0]["mail"])+"@"+str(fr[0]["host"]) + " | ".join(yaml.load(self.mails()[0].subject))
return "(" + str(self.answered)+ ", "+ str(self.maintopic)+ ", "+ str(self.lang) + ") " + str(self.firstmail)+": "+str(fr[0]["mail"])+"@"+str(fr[0]["host"]) + " | ".join(yaml.load(self.mails()[0].subject))
def mails(self):
a=[]
@@ -111,7 +112,7 @@ class MailThread(Base):
elif filter=="first":
a=mail_txt(m[0])
a=re.sub(r'\n\s*\n',r'\n',a)
a=re.sub(r'<!--.*-->',r'',a,flags=re.MULTILINE|re.DOTALL)
# a=re.sub(r'<!--.*-->',r'',a,flags=re.MULTILINE|re.DOTALL)
a=re.sub(r'\s*>+ .*\n',r'',a)