提交 81d94c50 编写于 作者: W wuzewu

Test module in travis ci

上级 089fae18
......@@ -11,6 +11,7 @@ env:
script:
- if [[ $TRAVIS_PYTHON_VERSION != 2.7 ]]; then /bin/bash ./scripts/check_code_style.sh; fi
- pip install paddlepaddle; /bin/bash ./scripts/test_cml.sh
- /bin/bash ./scripts/test_all_module.sh
notifications:
email:
......
#!/bin/bash
set -o errexit
base_path=$(cd `dirname $0`/..; pwd)
test_module_path=${base_path}/tests/modules
# install the require package
cd ${base_path}
# run all case list in the {listfile}
cd -
for test_file in `ls $test_module_path | grep test`
do
echo "run module ${test_file}"
python $test_module_path/$test_file
done
#coding:utf-8
import paddlehub as hub
import six
import json
# Load LAC Module
lac = hub.Module(name="lac")
test_text = ["今天是个好日子", "天气预报说今天要下雨", "下一班地铁马上就要到了"]
# Set input dict
inputs = {"text": test_text}
# execute predict and print the result
results = lac.lexical_analysis(data=inputs)
for result in results:
if six.PY2:
print(json.dumps(result['word'], encoding="utf8", ensure_ascii=False))
print(json.dumps(result['tag'], encoding="utf8", ensure_ascii=False))
else:
print(result['word'])
print(result['tag'])
import paddlehub as hub
senta = hub.Module(name="senta_bilstm")
test_text = ["这家餐厅很好吃", "这部电影真的很差劲"]
input_dict = {"text": test_text}
results = senta.sentiment_classify(data=input_dict)
for result in results:
print(result['text'])
print(result['sentiment_label'])
print(result['sentiment_key'])
print(result['positive_probs'])
print(result['negative_probs'])
import paddlehub as hub
simnet_bow = hub.Module(name="simnet_bow")
test_text_1 = ["这道题太难了", "这道题太难了", "这道题太难了"]
test_text_2 = ["这道题是上一年的考题", "这道题不简单", "这道题很有意思"]
inputs = {"text_1": test_text_1, "text_2": test_text_2}
results = simnet_bow.similarity(data=inputs)
max_score = -1
result_text = ""
for result in results:
if result['similarity'] > max_score:
max_score = result['similarity']
result_text = result['text_2']
print("The most matching with the %s is %s" % (test_text_1[0], result_text))
import paddlehub as hub
import os
ssd = hub.Module(name="ssd_mobilenet_v1_pascal")
base_dir = os.path.dirname(__file__)
test_img_path = os.path.join(base_dir, "resources", "test_img_cat.jpg")
# set input dict
input_dict = {"image": [test_img_path]}
# execute predict and print the result
results = ssd.object_detection(data=input_dict)
for result in results:
print(result['path'])
print(result['data'])
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册