The efficiency of computing backoff
huangruizhe opened this issue · 0 comments
huangruizhe commented
python-arpa/arpa/models/base.py
Lines 34 to 45 in 2284b81
This try...catch mechanism to implement the backoff may not be efficient enough.
According to the python documentation:
A try/except block is extremely efficient if no exceptions are raised. Actually catching an exception is expensive.
However, it is common in a language model to have unseen ngrams and to backoff to lower orders. Thus, I guess it may be more appropriate to implement this using if...else (as also suggested in the documentation) instead of try...catch.