52ba3c53fdeb5806b3626b873eefabf8c065d9d4,tensorflow_datasets/text/squad.py,Squad,_generate_examples,#Squad#Any#,164

Before Change


      squad = json.load(f)
      for article in squad["data"]:
        if "title" in article:
          title = article["title"].strip()
        else:
          title = ""
        for paragraph in article["paragraphs"]:
          context = paragraph["context"].strip()
          for qa in paragraph["qas"]:
            question = qa["question"].strip()
            id_ = qa["id"]

            answer_starts = [answer["answer_start"] for answer in qa["answers"]]
            answers = [answer["text"].strip() for answer in qa["answers"]]

            // Features currently used are "context", "question", and "answers".
            // Others are extracted here for the ease of future expansions.
            example = {
                "title": title,
                "context": context,
                "question": question,
                "id": id_,
                "answer_starts": answer_starts,
                "answers": answers,
            }
            yield {
                "question": example["question"],
                // TODO(b/121176753): return all the answers.
                "first_answer": example["answers"][0],
                "context": example["context"]
            }

After Change


    with tf.io.gfile.GFile(filepath) as f:
      squad = json.load(f)
      for article in squad["data"]:
        title = article.get("title", "").strip()
        for paragraph in article["paragraphs"]:
          context = paragraph["context"].strip()
          for qa in paragraph["qas"]:
            question = qa["question"].strip()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: tensorflow/datasets
Commit Name: 52ba3c53fdeb5806b3626b873eefabf8c065d9d4
Time: 2019-05-21
Author: adarob@google.com
File Name: tensorflow_datasets/text/squad.py
Class Name: Squad
Method Name: _generate_examples


Project Name: chakki-works/doccano
Commit Name: 49d41416e440926f0a9a8243b4d77f6f5468efe9
Time: 2019-03-12
Author: light.tree.1.13@gmail.com
File Name: app/server/utils.py
Class Name: CoNLLHandler
Method Name: parse


Project Name: tensorflow/datasets
Commit Name: dfabadfb1f0360627c3290e75b48a8283a05da82
Time: 2020-11-11
Author: epot@google.com
File Name: tensorflow_datasets/scripts/cli/build.py
Class Name:
Method Name: _make_builders