예제 #1
0
def upload_new_meeting():
    meeting_name = request.form.get("meeting_name")
    meeting_date = request.form.get("date")
    meeting_id = uuid.uuid4()

    # get file
    file = request.files['file']
    filename = secure_filename(file.filename)
    filepath = os.path.join(UPLOAD_DIRECTORY, filename)
    file.save(filepath)
    summary, key_phrases, entity_recog, entity_linking, sentiment_analysis = Analytics(filepath).meeting_analytics()
    resp_dict = {
        "meeting_id": str(meeting_id),
        "date": str(datetime.datetime.now()),
        "attendees": "Alex, Jason, Safeerah, Jennifer",
        "summary": summary,
        "key_phrases": key_phrases,
        "entity_recog": entity_recog,
        "entity_linking": entity_linking,
        "sentiment_analysis": sentiment_analysis
    }
    add_data(str(meeting_id), json.dumps(resp_dict))
    resp = jsonify(resp_dict)
    resp.headers['Access-Control-Allow-Origin'] = '*'
    return resp
def add():
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    e_mail = request.form['e_mail']
    country = request.form['country']
    city = request.form['city']
    friend_relative = request.form['friend_relative']
    google = request.form['google']
    facebook = request.form['facebook']
    twitter = request.form['twitter']
    search_engine = request.form['search_engine']
    other = request.form['other']
    other_text = request.form['other_text']

    # Checks if the e-mail has been entered already
    if db.email_exists(e_mail):
        return render_template("already_registered.html")
    else:
        db.add_data(first_name, last_name, e_mail, country, city,
                    friend_relative, google, facebook, twitter, search_engine,
                    other, other_text)
        # Posts a tweet
        tweet(first_name, last_name)
        return render_template("registry_complete.html",
                               tweet_list=twitter_integration.get_tweet_list())
예제 #3
0
def stored_inferences():
    if request.method == 'POST':
        if not request.is_json:
            return jsonify({"msg": "Missing JSON in request"}), 400

        add_data(request.get_json())
        return 'Inference Added'

    return render_template("stored_inferences.html", data=get_data())
예제 #4
0
파일: Main.py 프로젝트: ap13p/AlbumerWX
 def __on_add(self, evt):
     add_data_frame = AddDataFrame(self)
     if add_data_frame.ShowModal() == wx.ID_OK:
         data = add_data_frame.GetData()
         db.add_data(data[0], data[1], data[2])
         self.list_judul.Insert(str(data[0] + ' - ' + data[1]), 0)
         self.list_judul.Refresh()
         self.list_judul.SetStringSelection(str(data[0] + ' - ' + data[1]), True)
         db.commit()
     add_data_frame.Destroy()
예제 #5
0
def train_char(training_char):
    controller = Leap.Controller()
    for t in range(NUM_SAMPLES):
        time.sleep(SAMPLE_DELAY)
        sample = get_hand_position(controller, True)
        while len(sample) != NUM_FEATURES:
            print "Please place only right hand in view"
            sample = get_hand_position(controller, True)
        print sample
        add_data(sign=training_char, **sample)
    print "Done training"
def train_char(training_char):
    controller = Leap.Controller()
    for t in range(NUM_SAMPLES):
        time.sleep(SAMPLE_DELAY)
        sample = get_hand_position(controller, True)
        while len(sample) != NUM_FEATURES:
            print "Please place only right hand in view"
            sample = get_hand_position(controller, True)
        print sample
        add_data(sign=training_char, **sample)
    print "Done training"
예제 #7
0
def add():
    st.subheader("Add Items")
    #Layout:
    col1, col2 = st.beta_columns(2)
    with col1:
        value1 = st.text_area("Col 1")
    with col2:
        value2 = st.selectbox("Status", ["Verified", "Pending", "False"])
        input_time = st.date_input("Time")
    if st.button("Submit"):
        add_data(value1, value2, input_time)
        st.success("Successfully Sent Data:{}".format(value1))
예제 #8
0
파일: app.py 프로젝트: onddi/Sign-Chat
def train_char(model_name, training_word):
    for t in range(NUM_SAMPLES):
        time.sleep(SAMPLE_DELAY)
        sample = get_hand_position(controller, True)
        while len(sample) != NUM_FEATURES:
            emit(ACTION_TRAINING_ERROR, "Please place only right hand in view")
            # print "Please place only right hand in view"
            sample = get_hand_position(controller, True)
        print sample
        if t % 10 == 0:
            emit(ACTION_TRAINING_INPROGRESS, str(t) + "/" + str(NUM_SAMPLES))
        add_data(model_name=model_name, sign=training_word, **sample)
    emit(ACTION_TRAINING_DONE, "Done training")
예제 #9
0
 def search_data(self, search_name):
     if not self.template_search_url:
         return
     url = self.template_search_url.format(self.host, search_name.lower())
     response = self.get_response(url)
     found_url = self.parse_found_url(response, search_name.lower())
     if not found_url:
         print('[ERROR] Данный товар не найден')
         return
     response_product = self.get_response(found_url)
     data_product = self.parse_data_product(response_product)
     print('[INFO] Продукт сохранён')
     db.add_data(data_product)
예제 #10
0
파일: app.py 프로젝트: rahul07rai/Chatter
def signup():
    error = None
    if request.method == 'POST':
        if request.form['username'] == '' or request.form[
                'password'] == '' or request.form['contact'] == '':
            error = 'Invalid Credentials. Please try again.'
        else:
            name = request.form['username']
            passwd = hash(request.form['password'])
            contact = request.form['contact']
            sign = request.form['username'] + request.form['contact']
            timestamp = datetime.now()
            add_data(name, passwd, contact, sign, timestamp)
            return redirect(url_for('login'))
    return render_template('signup.html', error=error)
예제 #11
0
def write_fresh_data():
    """
    Getting a new data from parser and record to DB
    """
    db.get_connection()
    for currency in db.currencies:
        logging.info(f"Parse {currency} rates and write into db")
        # collect a new data
        fresh = parser.parse(currency)

        # write to db
        i = 0
        while i < len(fresh[0]):
            db.add_data(currency, fresh[0][i], fresh[1][i], fresh[2][i],
                        fresh[3])
            i = i + 1

        logging.info(f"Finish {currency} parse/record task")
예제 #12
0
def inference():
    if request.method == 'POST':

        req = [int(x) for x in request.form.values()]
        final_features = [np.array(req)]
        data = request.form.to_dict()

        if not req:
            flash('Missing values')
        else:
            price_prediction = model_api.predict(final_features).tolist()[0]
            result = dict()
            result["input"] = req
            result["output"] = price_prediction
            data.update({'price_prediction': result['output']})
            add_data(data)
            app.logger.info("model_output: " + str(result))
            return render_template('inference.html',
                                   price_prediction=price_prediction)
    return render_template("inference.html")
예제 #13
0
async def add_item_data(message: types.Message, state: FSMContext):
    """Добавляет новый товар в базу данных"""
    global item_data
    item_data = message.text
    await state.update_data(answer2=item_data)
    try:
        init_db()
        add_data(item_name, item_description, item_price, item_data, photo_id)
        logger.info('Product data added successfully')
        await message.answer_photo(photo=photo_id,
                                   caption='Товар успешно добавлен!\n\n'
                                   'Название - {name}\n'
                                   'Цена - {price}\n'
                                   'Описание - {description}\n'
                                   'Данные - {data}'.format(
                                       name=item_name,
                                       price=item_price,
                                       description=item_description,
                                       data=item_data))
    except Exception as e:
        logger.info('Product data added successfully' + str(e))
        await message.answer('Возникла ошибка при добавлении товара')
    await state.finish()
예제 #14
0
 def save_data(self):
     logger.info(f"current row {self.get_current_data(self.date)}")
     logger.info(f"date {self.date}")
     logger.info(f"local date {self.date_local_tz}")
     datetime_object = datetime.strptime(self.date, '%Y-%m-%dT%H:%M:%SZ')
     datetime_object_local = datetime.strptime(self.date_local_tz,
                                               '%Y-%m-%dT%H:%M:%S%z')
     logger.info(f"datetime object {datetime_object}")
     logger.info(f"datetime local {datetime_object_local}")
     if not self.get_current_data(self.date):
         send_new_alert = self.alert_send_check()
         if send_new_alert[0]:
             messages.send_message(send_new_alert[1], CFG.TO_NUMBERS)
         saved_row = db.add_data(
             datetime_object, self.hour_num, self.min_num,
             self.settlement_point, self.price_type, self.price_ckwh,
             self.value_score, self.mean_price_ckwh, self.diff_mean_ckwh,
             self.high_ckwh, self.low_ckwh, self.std_dev_ckwh,
             self.price_display, self.price_display_sign,
             datetime_object_local)
         logger.info(f"saved data {saved_row}")
     else:
         logger.info(f"row exists")
예제 #15
0
파일: app.py 프로젝트: diivi/shortenr
def add():
    result = db.add_data(request.form['long'], request.form['short'])
    return render_template('index.html',
                           long=request.form['long'],
                           short=request.form['short'],
                           result=result)
예제 #16
0
def bar_edit(bar_path):
    current_user = session.get('current_user')
    user = db.db_session.query(
        db.User).filter(db.User.u_name == current_user).first()
    if request.method == 'GET':
        if bar_path == '0':
            bar = []
            bar_id = 0
            bar_path = 0
            bar_head_img = 'img/bar_head_img.png'
            bar_banner_img = 'img/bar_banner_img.jpg'
        else:
            bar = db.db_session.query(
                db.Bar).filter(db.Bar.b_path == bar_path).first()
            bar_id = bar.b_id
            bar_path = bar.b_path
            bar_head_img = bar.b_head_img
            bar_banner_img = bar.b_banner_img
        return render_template("bar_edit.html",
                               user=user,
                               bar=bar,
                               bar_id=bar_id,
                               bar_path=bar_path,
                               bar_head_img=bar_head_img,
                               bar_banner_img=bar_banner_img)
    else:
        bar = db.db_session.query(
            db.Bar).filter(db.Bar.b_path == bar_path).first()
        b_id = request.form.get('b_id')
        b_name = request.form.get('b_name')
        b_path = request.form.get('b_path')
        b_topic = request.form.get('b_topic')
        b_statement = request.form.get('b_statement')
        if bar:
            b_head_img = bar.b_head_img
            b_banner_img = bar.b_banner_img
        else:
            bar_head_img = 'img/bar_head_img.png'
            bar_banner_img = 'img/bar_banner_img.jpg'

        head = request.files.get('b_head_img')
        if head:
            b_head_img_data = head.read()
            head_uuid = str(uuid.uuid1())
            b_head_img = 'bar_head/' + head_uuid + '.jpg'
            with open('static/' + b_head_img, 'wb+') as f:
                f.write(b_head_img_data)
            im_head = tools.change_img_dbi('static/' + b_head_img, 100, 100)
            im_head.save('static/' + b_head_img)

        banner = request.files.get('b_banner_img')
        if banner:
            b_banner_img_data = banner.read()
            banner_uuid = str(uuid.uuid1())
            b_banner_img = 'bar_banner/' + banner_uuid + '.jpg'
            with open('static/' + b_banner_img, 'wb+') as f:
                f.write(b_banner_img_data)
            im_banner = tools.change_img_dbi('static/' + b_banner_img, 1024,
                                             188)
            im_banner.save('static/' + b_banner_img)

        if b_id == '0':
            new_bar = db.Bar(b_name=b_name,
                             b_path=b_path,
                             b_topic=b_topic,
                             b_head_img=b_head_img,
                             b_banner_img=b_banner_img,
                             b_statement=b_statement)
            db.add_data(new_bar)
            db.add_data(
                db.Bar_relation(u_id=user.u_id, b_id=new_bar.b_id, relation=0))
        else:
            db.db_session.query(db.Bar).filter(db.Bar.b_id == b_id).update({
                db.Bar.b_name:
                b_name,
                db.Bar.b_path:
                b_path,
                db.Bar.b_topic:
                b_topic,
                db.Bar.b_head_img:
                b_head_img,
                db.Bar.b_banner_img:
                b_banner_img,
                db.Bar.b_statement:
                b_statement
            })
            db.db_session.commit()
        return redirect('/bar/' + b_path + '/')
예제 #17
0
def process_data(model, emb_name, md, model_name, folds):
    cv = KFold(len(X), n_folds=folds, shuffle=True)
    results = []
    y_pred_list = []

    count = 1

    for traincv, testcv in cv:
        print("\n--------Fold {}--------\n".format(count))
        X_test, X_train, y_test, y_train = X.iloc[testcv], X.iloc[
            traincv], y.iloc[testcv], y.iloc[traincv]

        train_essays = X_train['essay']
        test_essays = X_test['essay']

        sentences = []

        for essay in train_essays:
            # Obtaining all sentences from the training essays.
            sentences += utl.essay_to_sentences(essay, remove_stopwords=True)

        print("Training Word2Vec Model...")

        clean_train_essays = []

        # Generate training and testing data word vectors.
        for essay_v in train_essays:
            clean_train_essays.append(
                utl.essay_to_wordlist(essay_v, remove_stopwords=True))
        trainDataVecs = utl.getAvgFeatureVecs(clean_train_essays, model,
                                              num_features)

        clean_test_essays = []
        for essay_v in test_essays:
            clean_test_essays.append(
                utl.essay_to_wordlist(essay_v, remove_stopwords=True))
        testDataVecs = utl.getAvgFeatureVecs(clean_test_essays, model,
                                             num_features)

        trainDataVecs = np.array(trainDataVecs)
        testDataVecs = np.array(testDataVecs)

        # Reshaping train and test vectors to 3 dimensions. (1 represents one timestep)
        trainDataVecs = np.reshape(
            trainDataVecs, (trainDataVecs.shape[0], 1, trainDataVecs.shape[1]))
        testDataVecs = np.reshape(
            testDataVecs, (testDataVecs.shape[0], 1, testDataVecs.shape[1]))

        rnn_model = md(num_features)

        plot_model(rnn_model,
                   to_file=output_dir + '/{}.eps'.format(model_name))
        rnn_model.fit(trainDataVecs,
                      y_train,
                      batch_size=batch_size,
                      epochs=epochs)

        y_pred = rnn_model.predict(testDataVecs)

        # Round y_pred to the nearest integer.
        y_pred = np.around(y_pred)

        # Evaluate the model on the evaluation metric. "Quadratic mean averaged Kappa"
        result = cohen_kappa_score(y_test.values, y_pred, weights='quadratic')
        print("Kappa Score: {}".format(result))
        results.append(result)

        # Save weights
        weight_name = emb_name + "_" + model_name + "_" + str(
            folds) + "_" + str(count) + ".h5"
        rnn_model.save('./model_weights/{}'.format(weight_name))

        # add data to db
        db.add_data(emb_name, model_name, folds, count, result, weight_name)

        count += 1

    print("Average Kappa score after a 5-fold cross validation: ",
          np.around(np.array(results).mean(), decimals=4))
예제 #18
0
파일: debug.py 프로젝트: romanovna/baseline
def repeat():
    type_repeat = input('Do you wanna add some more? Y or N \n')
    if type_repeat in ['y', 'Y', 'YES', 'yes']:
        db.add_data()
    else:
        db.entry_point()
 def putData(self):
     add_data(self.username, self.password, self.cont_num, self.sig,
              self.time)