Created
May 16, 2021 20:04
-
-
Save MLWhiz/3ec648fd270d724cfaa819dfa8b22476 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datasets = load_dataset("squad") | |
def visualize(datasets, datatype = 'train', n_questions=10): | |
n = len(datasets[datatype]) | |
random_questions=random.choices(list(range(n)),k=n_questions) | |
for i in random_questions: | |
print(f"Context:{datasets[datatype][i]['context']}") | |
print(f"Question:{datasets[datatype][i]['question']}") | |
print(f"Answer:{datasets[datatype][i]['answers']['text']}") | |
print(f"Answer Start in Text:{datasets[datatype][i]['answers']['answer_start']}") | |
print("-"*100) | |
visualize(datasets) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment