diff --git a/.ipynb_checkpoints/main-checkpoint.py b/.ipynb_checkpoints/main-checkpoint.py index e946d1d..aef5888 100644 --- a/.ipynb_checkpoints/main-checkpoint.py +++ b/.ipynb_checkpoints/main-checkpoint.py @@ -1,16 +1,11 @@ -# coding = utf-8 -# 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/# - +# coding: utf-8 import os import sys - +# sys.path.append('../') # Import necessary packages -from modules import json_parser +# from modules import json_parser from modules import Client - from write_poem import start_model # Initialise Client object @@ -43,5 +38,6 @@ # if __name__ == '__main__': -# conf = {} -# handle(conf) +# conf = {"style": ['藏头诗'], "Chinese_word": '杨赛赛'} +# aa = handle(conf) +# print(aa) diff --git a/main.ipynb b/main.ipynb index 95068fa..9b906ed 100644 --- a/main.ipynb +++ b/main.ipynb @@ -4,7 +4,19 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ImportError", + "evalue": "No module named 'modules'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;31m# Import necessary packages\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mjson_parser\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 14\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mClient\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mImportError\u001b[0m: No module named 'modules'" + ] + } + ], "source": [ "# coding = utf8\n", "# You can use other public modules via our Client object with module's identifier\n", @@ -35,6 +47,13 @@ "controller = client.controller\n", "\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] }, { "cell_type": "code", @@ -83,6 +102,69 @@ }, { "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "ename": "ImportError", + "evalue": "No module named 'modules'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# Import necessary packages\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;31m# from modules import json_parser\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mClient\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mwrite_poem\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mstart_model\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mImportError\u001b[0m: No module named 'modules'" + ] + } + ], + "source": [ + "# coding: utf-8\n", + "import os\n", + "import sys\n", + "\n", + "# Import necessary packages\n", + "# from modules import json_parser\n", + "from modules import Client\n", + "\n", + "from write_poem import start_model\n", + "\n", + "# Initialise Client object\n", + "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n", + " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n", + " project_type='app', source_file_path='main.py', \n", + " silent=True)\n", + "\n", + "# Make run/train/predict command alias for further use\n", + "run = client.run\n", + "train = client.train\n", + "predict = client.predict\n", + "\n", + "# Make controller alias for further use\n", + "controller = client.controller\n", + "writer = start_model()\n", + "\n", + "\n", + "def handle(conf):\n", + " # paste your code here\n", + " # path = os.getcwd() # 获取当前工作目录\n", + " # print(path)\n", + " if conf['style'] == ['藏头诗']:\n", + " poetry = writer.cangtou(conf['Chinese_word'])\n", + " elif conf['style'] == ['藏字诗']:\n", + " poetry = writer.hide_words(conf['Chinese_word'])\n", + " else:\n", + " poetry = writer.rhyme_verse()\n", + " return {\"Poetry\": poetry}\n", + "\n", + "\n", + "# if __name__ == '__main__':\n", + "# conf = {\"style\": ['藏头诗'], \"Chinese_word\": '杨赛赛'}\n", + "# aa = handle(conf)\n", + "# print(aa)\n" + ] + }, + { + "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], diff --git a/main.py b/main.py index e946d1d..aef5888 100644 --- a/main.py +++ b/main.py @@ -1,16 +1,11 @@ -# coding = utf-8 -# 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/# - +# coding: utf-8 import os import sys - +# sys.path.append('../') # Import necessary packages -from modules import json_parser +# from modules import json_parser from modules import Client - from write_poem import start_model # Initialise Client object @@ -43,5 +38,6 @@ # if __name__ == '__main__': -# conf = {} -# handle(conf) +# conf = {"style": ['藏头诗'], "Chinese_word": '杨赛赛'} +# aa = handle(conf) +# print(aa)