INNER CODE UNIT · Python

_convert_examples_to_features

hooshvare/parsbert · scripts/utils.py:73

def _convert_examples_to_features(
        examples: List[InputExample],
        tokenizer: PreTrainedTokenizer,
        max_length: Optional[int] = None,
        task=None,
        label_list=None,
        output_mode=None):
    if max_length is None:
        max_length = tokenizer.max_len

    logger.info("Using label list %s for task %s" % (label_list, task))
    logger.info("Using output mode %s for task %s" % (output_mode, task))

    label_map = {label: i for i, label in enumerate(label_list)}

    def label_from_example(example: InputExample) -> Union[int, float, None]:
        if example.label is None:
            return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…