Skip to content

Commit

Permalink
type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
DianLiI committed Apr 6, 2021
1 parent a1e7c74 commit 35bd1dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions forte_wrapper/allennlp/allennlp_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ def _process(self, input_pack: DataPack):

batch_size = self.configs['infer_batch_size']
if batch_size <= 0:
batches = [input_pack.get(Sentence)]
batches = iter([input_pack.get(Sentence)])
else:
batches = more_itertools.chunked(input_pack.get(Sentence),
batch_size, strict=False)
batches = more_itertools.ichunked(input_pack.get(Sentence),
batch_size)
for sentences in batches:
inputs = [{"sentence": s.text} for s in sentences]
results = {k: p.predict_batch_json(inputs)
for k, p in self.predictor.items()}
for i, sentence in enumerate(sentences):
result = {}
result: Dict[str, List[str]] = {}
for key in self.predictor.keys():
if key == 'srl':
result.update(parse_allennlp_srl_results(
Expand Down

0 comments on commit 35bd1dc

Please sign in to comment.