def analyser_picker(self, reviews): if self.ui.watsonRadioButton.isChecked(): self.ui.listWidget.addItem("IBM Watson") # Анализ отзывов с помощью IBM Watson watson_analyser = watson.Watson(reviews) sentiment = watson_analyser.get_s_res() self.ui.listWidget.addItem(sentiment) watson_res = watson_analyser.get_res() self.add_chart(watson_res) elif self.ui.monkeyRadioButton.isChecked(): self.ui.listWidget.addItem("MonkeyLearn") # Анализ отзывов с помощью MonkeyLearn review_list = [reviews] monkey_analyser = monkey.Monkey(review_list) monkey_res = monkey_analyser.get_res() self.ui.listWidget.addItem(monkey_res) else: self.ui.listWidget.addItem("MonkeyLearn") # Анализ отзывов с помощью MonkeyLearn и IBM Watson review_list = [reviews] monkey_analyser = monkey.Monkey(review_list) monkey_res = monkey_analyser.get_res() self.ui.listWidget.addItem(monkey_res) self.ui.listWidget.addItem("IBM Watson") watson_analyser = watson.Watson(reviews) sentiment = watson_analyser.get_s_res() self.ui.listWidget.addItem(sentiment) watson_res = watson_analyser.get_res() # Отрисовка графика для эмоций отзывов, определённых IBM Watson self.add_chart(watson_res)
def create_watson(): return _watson.Watson(config_dir=os.environ.get('WATSON_DIR'))
#!/usr/bin/python import watson conn = watson.Watson() if conn.current: curr_proj = conn.current['project'].strip() start_time = conn.current['start'].humanize() print(f"\uf4a0 {curr_proj} \uf6d8 {start_time}") else: print("")
from api import * import json import watson import watsonImgRec from watson_developer_cloud import ConversationV1 import urllib3 urllib3.disable_warnings() template_dir = os.path.dirname(os.path.abspath(__file__)) app = Flask(__name__, template_folder=template_dir, static_url_path='', static_folder=template_dir) watsonBot = watson.Watson() @app.route("/") def index(): print 'INDEX' return render_template("index.html", images=watsonImgRec.WatsonImgRec.imagesSet(), task=watsonImgRec.WatsonImgRec.task()) @app.route("/<name>") def hello(name): return render_template("index.html",name=name.title()) @app.route("/signup", methods=['POST']) def sign_up(): form_data = request.form name = form_data['name'] print name