Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Syntactic Tools
combo
Commits
e9b1721f
Commit
e9b1721f
authored
Jan 20, 2022
by
martynawiacek
Committed by
Łukasz Pszenny
Feb 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add try/catch clause for sentences with large number of wordpieces.
parent
f39ffe68
Pipeline
#4337
passed with stage
in 6 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
combo/data/token_indexers/pretrained_transformer_mismatched_indexer.py
...ken_indexers/pretrained_transformer_mismatched_indexer.py
+0
-2
combo/predict.py
combo/predict.py
+7
-1
No files found.
combo/data/token_indexers/pretrained_transformer_mismatched_indexer.py
View file @
e9b1721f
...
...
@@ -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
):
...
...
combo/predict.py
View file @
e9b1721f
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment