class_docstr: Natural Questions: A Benchmark for Question Answering Research.
class_docstr_tok: ["Natural","Questions",":","A","Benchmark","for","Question","Answering","Research","."]
docstr: Parse a single json line and emit an example dict.
docstr_tok: ["Parse","a","single","json","line","and","emit","an","example","dict","."]
code: def _parse_example_default(line):
      """Parse a single json line and emit an example dict."""
  
      def _parse_short_answer_default(html_bytes, short_ans):
          """Extract text of short answer."""
          ans_bytes = html_bytes[
              short_ans["start_byte"] : short_ans["end_byte"]
          ]
          # Remove non-breaking spaces.
          ans_bytes = ans_bytes.replace(b"\xc2\xa0", b" ")
          text = ans_bytes.decode("utf-8")
          # Remove HTML markup.
          text = re.sub("<([^>]*)>", "", html.unescape(text))
          # Replace \xa0 characters with spaces.
          return {
              "start_token": short_ans["start_token"],
              "end_token": short_ans["end_token"],
              "start_byte": short_ans["start_byte"],
              "end_byte": short_ans["end_byte"],
              "text": text,
          }
  
      def _parse_annotation_default(html_bytes, an_json):
          return {
              # Convert to str since some IDs cannot be represented by np.int64.
              "id": str(an_json["annotation_id"]),
              "long_answer": {
                  "start_token": an_json["long_answer"]["start_token"],
                  "end_token": an_json["long_answer"]["end_token"],
                  "start_byte": an_json["long_answer"]["start_byte"],
                  "end_byte": an_json["long_answer"]["end_byte"],
              },
              "short_answers": [
                  _parse_short_answer_default(html_bytes, ans)
                  for ans in an_json["short_answers"]
              ],
              "yes_no_answer": (
                  -1
                  if an_json["yes_no_answer"] == "NONE"
                  else an_json["yes_no_answer"]
              ),
          }
  
      ex_json = json.loads(line)
      html_bytes = ex_json["document_html"].encode("utf-8")
  
      # Convert to str since some IDs cannot be represented by np.int64.
      id_ = str(ex_json["example_id"])
      return id_, {
          "id": id_,
          "document": {
              "title": ex_json["document_title"],
              "url": ex_json["document_url"],
              "html": html_bytes,
              "tokens": [
                  {  # pylint: disable=g-complex-comprehension
                      "token": t["token"],
                      "is_html": t["html_token"],
                  }
                  for t in ex_json["document_tokens"]
              ],
          },
          "question": {
              "text": ex_json["question_text"],
              "tokens": ex_json["question_tokens"],
          },
          "annotations": [
              _parse_annotation_default(html_bytes, an_json)
              for an_json in ex_json["annotations"]
          ],
      }
  
file_path: datasets/tensorflow_datasets/datasets/natural_questions/natural_questions_dataset_builder.py
imports: import html
  import json
  import os
  import re
  from typing import Optional
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling the Builder obj's underlying member method code with example usage: obj._parse_example_default(line) and returns: id_,  dict, dict, dict