本文整理汇总了Python中classifier.Classifier.classify_text方法的典型用法代码示例。如果您正苦于以下问题:Python Classifier.classify_text方法的具体用法?Python Classifier.classify_text怎么用?Python Classifier.classify_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classifier.Classifier
的用法示例。
在下文中一共展示了Classifier.classify_text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: askfunc
# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import classify_text [as 别名]
def askfunc():
options=\
{
"login": False,
"username": "",
"status": 0
}
error = None
if session.has_key('username'):
options["login"]=True
options["username"]=session["username"]
else:
return render_template('errorpage.html', error = error)
if request.method=='POST':
op=request.form['op']
print ("enter the post")
if op == "submit":
newpic = request.files['photo']
picAdded = True;
cur=mysql.connection.cursor()
cur.execute("select userid from user where username = " + "'" + session["username"] + "'")
useridresult = [];
useridresult=cur.fetchall()
userid = useridresult[0][0]
userid = str(userid)
currentuserid = userid;
currentuserid = str(currentuserid)
pic_location = "static/pictures/" + currentuserid + "/" +newpic.filename
newpic.save(pic_location)
title = request.form['title']
ori = request.form['ori']
ori = str(ori)
print ori
if ori == "I dont know": #TODO: update with proper default value
print ("classifier entered")
cc = Classifier(pic_location)
ori = cc.classify_text()
ori = ori.title()
tar = request.form['tar']
#if tar == 'NA'
des = request.form['des']
cur=mysql.connection.cursor()
cur.execute("insert into post (title, description, origin, target, pathtophoto, userid) values ('" + title + "', '" + des + "', '" + ori + "', '" + tar + "', '" + newpic.filename +"', "+ currentuserid +");")
print ("insert into post (title, description, origin, target, pathtophoto, userid) values ('" + title + "', '" + des + "', '" + ori + "', '" + tar + "', '" + newpic.filename +"', "+ currentuserid +");")
cur.execute("commit")
return render_template('redirect.html', error=error)
return render_template('ask.html', error=error, **options)