Commit e9b1721f authored by martynawiacek's avatar martynawiacek Committed by Łukasz Pszenny

Add try/catch clause for sentences with large number of wordpieces.

parent f39ffe68
Pipeline #4337 passed with stage
in 6 minutes and 29 seconds
......@@ -4,8 +4,6 @@ from allennlp import data
from allennlp.data import token_indexers, tokenizers, IndexedTokenList, vocabulary
from overrides import overrides
from typing import List
@data.TokenIndexer.register("pretrained_transformer_mismatched_fixed")
class PretrainedTransformerMismatchedIndexer(token_indexers.PretrainedTransformerMismatchedIndexer):
......
import logging
import os
import sys
from typing import List, Union, Dict, Any
import numpy as np
......@@ -48,7 +49,12 @@ class COMBO(predictor.Predictor):
:param sentence: sentence(s) representation
:return: Sentence or List[Sentence] depending on the input
"""
return self.predict(sentence)
try:
return self.predict(sentence)
except Exception as e:
logger.error(e)
logger.error('Exiting.')
sys.exit(1)
def predict(self, sentence: Union[str, List[str], List[List[str]], List[data.Sentence]]):
if isinstance(sentence, str):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment