small rewrites
This commit is contained in:
@@ -5,7 +5,6 @@ from storage import Mail, MailThread, db_session
|
||||
from classifier import print_answers
|
||||
|
||||
|
||||
|
||||
def train_fit_pipe():
|
||||
tt= get_training_threads(b"answered")
|
||||
pipe1.fit(tt[0],tt[1])
|
||||
@@ -33,18 +32,21 @@ def predict_thread(mth,p,le,key):
|
||||
|
||||
def train_single_thread(tid,p,le,key="answered"):
|
||||
if (not type(tid) is int): raise TypeError("ID must be of type int")
|
||||
#-------------------------------------------------------
|
||||
if not type(p) is Pipeline: raise TypeError("Second Argument needs to be type Pipeline")
|
||||
if not type(le) is LabelEncoder: raise TypeError("Second Argument needs to be type LabelEncoder")
|
||||
|
||||
# Load a single Mailthread by firstmail id
|
||||
mth=db_session.query(MailThread).filter(MailThread.firstmail==tid).first()
|
||||
if mth is None: raise ValueError("Thread with firstmail %d not in Database" %tid)
|
||||
if mth is None: raise StandardError("Thread with firstmail %d not in Database" %tid)
|
||||
|
||||
# Output the mail thread
|
||||
print mth.firstmail
|
||||
print mth.subject()
|
||||
print mth.text()
|
||||
|
||||
if not p is None and not le is None:
|
||||
answ=predict_thread(mth,p,le,key)
|
||||
else: answ=None
|
||||
if not le is None:
|
||||
print_answers(le)
|
||||
answ=predict_thread(mth,p,le,key)
|
||||
print_answers(le)
|
||||
|
||||
ca=raw_input("Correct answer..")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user