baidu / Senta

Baidu's open-source Sentiment Analysis System.
Apache License 2.0
1.91k stars 371 forks source link

Senta cannot find model when using `.py` scripts #39

Closed cloudy-sfu closed 1 year ago

cloudy-sfu commented 4 years ago

Environment: Ubuntu 18.04 & PaddlePaddle 1.8.3.post107 & CUDA: 10.2

Initially, I install Senta and try it in the terminal.

It only works when the current folder is Senta (must run cd .../Senta), so if my python script is not in the folder Senta, the function model.init_model() will download model again. In addition, if the model has been downloaded when I tried it in the terminal, the Senta will fail to find the proper location of the model, and return a FileNotFoundError.

As a result, I rewrite the Senta/senta/train.py to fix this problem. Since GitHub doesn't support .py file type, I change the extension to .txt.

train.py.txt

Usage:

from package_fixed.train import Senta
model = Senta(installed_path="/home/cld/stockemo/Senta/senta")
model.init_model(model_class="ernie_1.0_skep_large_ch", task="sentiment_classify", use_cuda=True)