Example #1
0
def aspectExtractor(sentence):
    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    model.restore_session(config.dir_model)

    # create dataset
    test  = CoNLLDataset(config.filename_test, config.processing_word,
                         config.processing_tag, config.max_iter)

    # evaluate and interact
    model.evaluate(test)
    preds=interactive_shell(model , sentence)
    return preds
Example #2
0
def init():
    """
    This function is to load the trained Keras model.
    :return - None
    """
    # load the pre-trained tensorflow model
    global model, graph

    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    model.restore_session(config.dir_model)
    graph = tf.get_default_graph()
Example #3
0
def main():
    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    model.restore_session(config.dir_model)

    # create dataset
    test  = GloveDataset(config.filename_test, config.processing_word,
                         config.processing_tag, config.max_iter)

    # evaluate and interact
    model.evaluate(test)

    # saver = tf.train.Saver()

    # save_path = saver.save(sess, "/export/model.ckpt")

    # print("Model saved")

    interactive_shell(model)
Example #4
0
def main():
    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    # model.restore_session("results/crf/model.weights/") # optional, restore weights
    # model.reinitialize_weights("proj")

    # create datasets
    dev = CoNLLDataset(config.filename_dev, config.processing_word,
                       config.processing_tag, config.max_iter)
    train = CoNLLDataset(config.filename_train, config.processing_word,
                         config.processing_tag, config.max_iter)

    # train model
    model.train(train, dev)