ReadingComprehensionDataset
The ReadingComprehensionDataset
class represents a reading comprehension dataset.
- Loads a reading comprehension data.
- The data consists of three datasets:
train
dev
test
- Each dataset contains a list of paragraphs in the
paragraphs
field. - Each paragraph is a dictionary containing the following:
context
: textqas
: list of questions and answers, each a dictionary with:question
: text of the questionanswers
: a list of answers, each answer a dictionary containing:text
: answer test as string, exactly as appearing in the contextstart
: character offset of the answer text in the context
npfl138.datasets.reading_comprehension_dataset.ReadingComprehensionDataset
Source code in npfl138/datasets/reading_comprehension_dataset.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
Paragraph
class-attribute
instance-attribute
Paragraph = TypedDict(
"Paragraph",
{
"context": str,
"qas": list[
TypedDict(
"QA",
{
"question": str,
"answers": list[
TypedDict("Answer", {"text": str, "start": int})
],
},
)
],
},
)
The type of a single Paragraph containing possibly several questions and corresponding answers.
Dataset
Source code in npfl138/datasets/reading_comprehension_dataset.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
__init__
__init__(name: str = 'reading_comprehension') -> None
Load the dataset, downloading it if necessary.
Source code in npfl138/datasets/reading_comprehension_dataset.py
62 63 64 65 66 67 68 69 70 71 72 73 |
|
evaluate
staticmethod
Evaluate the predictions
against the gold dataset.
Returns:
-
accuracy
(float
) –The accuracy of the predictions in percentages.
Source code in npfl138/datasets/reading_comprehension_dataset.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
evaluate_file
staticmethod
Evaluate the file with predictions against the gold dataset.
Returns:
-
accuracy
(float
) –The accuracy of the predictions in percentages.
Source code in npfl138/datasets/reading_comprehension_dataset.py
102 103 104 105 106 107 108 109 110 |
|