Skip to content

Commit

Permalink
Parse raw sentences for custom tags, fix: #1903
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Aug 18, 2024
1 parent b32d4b9 commit 022d0fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion hanlp/components/taggers/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ def build_samples(self, data: List[str], **kwargs):
def prediction_to_human(self, pred_ids, vocab: List[str], batch):
if isinstance(pred_ids, torch.Tensor):
pred_ids = pred_ids.tolist()
sents = batch[self.config.token_key]
sents = batch.get(f'{self.config.token_key}_')
if not sents:
sents = batch[self.config.token_key]
dict_tags: DictInterface = self.dict_tags
for each, sent in zip(pred_ids, sents):
tags = [vocab[id] for id in each[:len(sent)]]
Expand Down
2 changes: 1 addition & 1 deletion hanlp/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Author: hankcs
# Date: 2019-12-28 19:26

__version__ = '2.1.0-beta.58'
__version__ = '2.1.0-beta.59'
"""HanLP version"""


Expand Down

0 comments on commit 022d0fb

Please sign in to comment.