master
/ main.ipynb

main.ipynb @e89f9ffview markup · raw · history · blame

Notebook
In [ ]:
# coding = utf8
# You can use other public modules via our Client object with module's identifier
# and parameters.
# For more detailes, please see our online document - https://momodel.github.io/docs/#

import os
import sys

# Define root path
sys.path.append('../')

# Import necessary packages
from modules import json_parser
from modules import Client

# Initialise Client object
client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',
                project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',
                project_type='app', source_file_path='Untitled.ipynb')

# Make run/train/predict command alias for further use
run = client.run
train = client.train
predict = client.predict

# Make controller alias for further use
controller = client.controller
In [ ]:
from write_poem import start_model

path = os.getcwd()  # 获取当前工作目录
print(path)
writer = start_model()


def write_poem():
    start_with = '大是大非开始了'
    poem_style = 4
    if start_with:
        if poem_style == 3:
            return writer.cangtou(start_with)
        elif poem_style == 4:
            return writer.hide_words(start_with)

    if poem_style == 1:
        return writer.free_verse()
    elif poem_style == 2:
        return writer.rhyme_verse()

if __name__ == "__main__":
    result = write_poem()
    print('result:')
    print(result)
In [ ]:
# coding: utf-8
import os
import sys

# Import necessary packages
# from modules import json_parser
from modules import Client

from write_poem import start_model

# Initialise Client object
client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',
                project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',
                project_type='app', source_file_path='main.py', 
                silent=True)

# Make run/train/predict command alias for further use
run = client.run
train = client.train
predict = client.predict

# Make controller alias for further use
controller = client.controller
writer = start_model()


def handle(conf):
    # paste your code here
    # path = os.getcwd()  # 获取当前工作目录
    # print(path)
    if conf['style'] == ['藏头诗']:
        poetry = writer.cangtou(conf['Chinese_word'])
    elif conf['style'] == ['藏字诗']:
        poetry = writer.hide_words(conf['Chinese_word'])
    else:
        poetry = writer.rhyme_verse()
    return {"Poetry": poetry}


# if __name__ == '__main__':
#     conf = {"style": ['藏头诗'], "Chinese_word": '杨赛赛'}
#     aa = handle(conf)
#     print(aa)
In [ ]: