- .ipynb_checkpoints
- data
- datasets
- job_logs
- results
- .gitignore
- _overview.md
- app_spec.yml
- char_rnn_model.py
- config_poem.py
- data_loader.py
- file.zip
- handler.py
- intro.ipynb
- main.ipynb
- project_requirements.txt
- rhyme_helper.py
- test.ipynb
- train.py
- Untitled.ipynb
- untitled.md
- Untitled1.ipynb
- word2vec_helper.py
- work.zip
- write_poem.py
main.ipynb @401591c — view markup · raw · history · blame
In [1]:
# coding: utf-8
import os
import sys
# Define root path
sys.path.append('../')
# 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.ipynb',
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):
"""
该方法是部署之后,其他人调用你的服务时候的处理方法。
请按规范填写参数结构,这样我们就能替你自动生成配置文件,方便其他人的调用。
范例:
params['key'] = value # value_type: str # description: some description
参数请放到params字典中,我们会自动解析该变量。
"""
style = conf['诗词形式'] # value_type: str # description: some description
Chinese_word = conf['四字短语'] # value_type: str # description: some description
ticai = conf['体裁']
# add your code
if ticai == '七言':
char_len = 32
else:
char_len = 24
# add your code
if style == '藏头诗':
poetry_test = writer.cangtou(Chinese_word)
while len(poetry_test) != char_len:
poetry_test = writer.cangtou(Chinese_word)
poetry = poetry_test
elif conf['style'] == '藏字诗':
poetry_test = writer.hide_words(Chinese_word)
while len(poetry_test) != char_len:
poetry_test = writer.cangtou(Chinese_word)
poetry = poetry_test
else:
poetry_test = writer.rhyme_verse()
while len(poetry_test) != char_len:
poetry_test = writer.cangtou(Chinese_word)
poetry = poetry_test
return {'Poetry': poetry}
In [5]:
if __name__ == '__main__':
conf = {"诗词形式": '藏头诗', "四字短语": '我是小墨', '体裁':'五言'}
aa = handle(conf)
print(aa)
# print(len(aa['Poetry']))
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
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)
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)