{"record":{"id":"a60198a3b41bd00b","repo":"hankcs/HanLP","slug":"iob1-to-bioul-has-been-replaced-with-to-bioul-to","errorCode":null,"errorMessage":"iob1_to_bioul has been replaced with 'to_bioul' to allow more encoding options.","messagePattern":"iob1_to_bioul has been replaced with 'to_bioul' to allow more encoding options\\.","errorType":"console","errorClass":"FutureWarning","httpStatus":null,"severity":"info","filePath":"hanlp/utils/span_util.py","lineNumber":560,"sourceCode":"        elif label[0] == \"B\":\n            start = index\n            while label[0] != \"E\":\n                index += 1\n                if index >= len(tag_sequence):\n                    raise InvalidTagSequence(tag_sequence)\n                label = tag_sequence[index]\n                if not (label[0] == \"I\" or label[0] == \"E\"):\n                    raise InvalidTagSequence(tag_sequence)\n            spans.append((label.partition(\"-\")[2], (start, index)))\n        else:\n            if label != \"O\":\n                raise InvalidTagSequence(tag_sequence)\n        index += 1\n    return [span for span in spans if span[0] not in classes_to_ignore]\n\n\ndef iob1_to_bioul(tag_sequence: List[str]) -> List[str]:\n    warnings.warn(\n        \"iob1_to_bioul has been replaced with 'to_bioul' to allow more encoding options.\",\n        FutureWarning,\n    )\n    return to_bioul(tag_sequence)\n\n\ndef to_bioul(tag_sequence: List[str], encoding: str = \"IOB1\") -> List[str]:\n    \"\"\"\n    Given a tag sequence encoded with IOB1 labels, recode to BIOUL.\n\n    In the IOB1 scheme, I is a token inside a span, O is a token outside\n    a span and B is the beginning of span immediately following another\n    span of the same type.\n\n    In the BIO scheme, I is a token inside a span, O is a token outside\n    a span and B is the beginning of a span.\n\n    # Parameters","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/utils/span_util.py#L542-L578","documentation":"This is a FutureWarning emitted by hanlp's deprecated helper iob1_to_bioul in hanlp/utils/span_util.py. The function still works but has been renamed to to_bioul, which supports more tagging encodings (IOB1, IOB2, BIOUL, etc.). The warning is a migration signal, not a runtime failure.","triggerScenarios":"Calling hanlp.utils.span_util.iob1_to_bioul(tag_sequence) directly, or using older user code/scripts that imported and invoked this helper after upgrading hanlp to a version where to_bioul was introduced.","commonSituations":"Upgrading hanlp to a newer release while pipelines or notebooks still call iob1_to_bioul; copying old hanlp examples or tutorials that used the previous API name; downstream NLP tooling that hardcodes the old function name.","solutions":["Replace calls iob1_to_bioul(tags) with to_bioul(tags, encoding='iob1') (or the encoding matching your input scheme) from hanlp.utils.span_util.","If you must keep old code temporarily, suppress with warnings.filterwarnings('ignore', category=FutureWarning, module='hanlp.utils.span_util'), then migrate before the function is removed.","Pin/upgrade code against hanlp's current docs and run a project-wide grep for iob1_to_bioul to catch every call site."],"exampleFix":"// before\nfrom hanlp.utils.span_util import iob1_to_bioul\nbioul = iob1_to_bioul(tags)\n\n// after\nfrom hanlp.utils.span_util import to_bioul\nbioul = to_bioul(tags, encoding='iob1')","handlingStrategy":"validation","validationCode":"import warnings, hanlp.utils.span_util as su\nif not hasattr(su, 'to_bioul'):\n    raise RuntimeError('hanlp too old: to_bioul unavailable; upgrade hanlp')","typeGuard":"def has_to_bioul(mod) -> bool:\n    return hasattr(mod, 'to_bioul') and callable(mod.to_bioul)","tryCatchPattern":null,"preventionTips":["Check hanlp's changelog before upgrading and grep your code for removed/renamed utils.","Target the new API (to_bioul with an explicit encoding) in new code.","Treat FutureWarning as a hard failure in CI (warnings.simplefilter('error', FutureWarning)) to catch deprecations early."],"tags":["python","hanlp","deprecation","future-warning","ner-tagging"],"backgroundTag":"deprecated-api-renamed","analyzedSha":"ddb1299bddff079e447af52ec12549c50636bfa8","analyzedAt":"2026-08-27T03:36:54.287Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}