def getData(lastfile): weatherfile = requests.get( "http://opendata.cwb.gov.tw/opendataapi?dataid=O-A0001-001&authorizationkey=CWB-A7A69CF2-28D1-4E1E-B5C4-32548E120BAC" ) filename = time.strftime("%F %H-%M-%S") + '.txt' data = open(filename, 'w', encoding='UTF8') data.write(weatherfile.text) data.close() if compare(lastfile, filename): classify.classified(filename) os.remove(lastfile) return filename else: os.remove(filename) return lastfile
def tell(): handle = request.form['twitterHandle'] print(handle) py_obj = classified(handle) gender = py_obj[2] if gender == 'female': return render_template('female.html', py_obj=py_obj) else: return render_template('male.html', py_obj=py_obj)
# This tests the classifier without front end from classify import classified import nltk handle = "Adele" py_obj = classified(handle) print(py_obj)