master
/ main.ipynb

main.ipynb @2ee792eview markup · raw · history · blame

Notebook
In [1]:
# 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
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-b6ce2ceab38e> in <module>
     11 
     12 # Import necessary packages
---> 13 from modules import json_parser
     14 from modules import Client
     15 

ImportError: No module named 'modules'
In [ ]:
 
In [2]:
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)
/home/jovyan/work
07:26:17 INFO:best_model: /home/jovyan/work/results/output_poem/best_model/model-20390

result:
大妃非是列,志事满黄枢。始喜封阳礼,开摩舞罢歌。
In [2]:
# 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)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-3bc0b5b2f564> in <module>
      5 # Import necessary packages
      6 # from modules import json_parser
----> 7 from modules import Client
      8 
      9 from write_poem import start_model

ImportError: No module named 'modules'
In [ ]: