Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big Bug: program error and exit #665

Open
yoyoo333 opened this issue Sep 14, 2023 · 0 comments
Open

Big Bug: program error and exit #665

yoyoo333 opened this issue Sep 14, 2023 · 0 comments

Comments

@yoyoo333
Copy link

yoyoo333 commented Sep 14, 2023

When using the LTP/legacy model, if the input text is empty, it will cause rust to report an error and exit.

During batch data processing, empty or abnormal content will appear in the middle, causing the program to crash, and the exception cannot be handled using python's try catch.

Below is the usage code:

from ltp import LTP

ltp = LTP("LTP/legacy")

sentence = ""
result = ltp.pipeline(sentence, tasks=["cws", "pos"])
print(result)

The error message is as follows:

oading weights from local directory
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/runner/work/ltp/ltp/rust/ltp/src/perceptron/model.rs:130:30
stack backtrace:
   0: rust_begin_unwind
             at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/panicking.rs:67:14
   2: core::panicking::panic_bounds_check
             at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/panicking.rs:162:5
   3: ltp::perceptron::model::Perceptron<ltp::perceptron::definition::cws::CWSDefinition,Feature,ParamStorage,Param>::predict
   4: ltp_extension::perceptron::specialization::cws::PyCWSModel::predict
   5: ltp_extension::perceptron::specialization::cws::_::<impl ltp_extension::perceptron::specialization::cws::PyCWSModel>::__pymethod___call____
   6: pyo3::impl_::trampoline::trampoline_inner
   7: ltp_extension::perceptron::specialization::cws::_::<impl pyo3::impl_::pyclass::PyMethods<ltp_extension::perceptron::specialization::cws::PyCWSModel> for pyo3::impl_::pyclass::PyClassImplCollector<ltp_extension::perceptron::specialization::cws::PyCWSModel>>::py_methods::ITEMS::trampoline
   8: PyObject_Call
             at /usr/local/src/conda/python-3.7.16/Objects/call.c:245:19
   9: do_call_core
             at /usr/local/src/conda/python-3.7.16/Python/ceval.c:4645:16
  10: _PyEval_EvalFrameDefault
@yoyoo333 yoyoo333 changed the title When using the LTP/legacy model, if the input text is empty, it will cause rust to report an error and exit. Big Bug: program error and exit Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant