[英]skip to the next word if the function is blocked at the current one or is taking too long
I want for my function to skip to the next word if the execution either doesn't work or take too long.如果执行不起作用或花费太长时间,我希望我的 function 跳到下一个单词。 Here's my function:这是我的 function:
def encode(word):
return bc.encode([[word]],is_tokenized=True)
I tried the try/exepct like this:我尝试了这样的尝试/执行:
def bert(word):
try:
return bc.encode([[word]],is_tokenized=True)
except:
pass
But my code still stop running for some words.但是我的代码仍然停止运行一些单词。 Is there a function that can say to my function to pass to the next word if it takes too long?是否有一个 function 可以对我的 function 说如果需要太长时间才能传递到下一个单词?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.