Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit c1dcd0f

Browse files
apmoore1matt-gardner
authored andcommitted
Reflects the updated code (#1873)
The changes reflect the changes that have been made to the test case code.
1 parent 371fd80 commit c1dcd0f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tutorials/getting_started/predicting_paper_venues/predicting_paper_venues_pt1.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ The basic API of the `DatasetReader` is just that we need to instantiate the obj
7878

7979
```python
8080
from allennlp.common.testing import AllenNlpTestCase
81+
from allennlp.common.util import ensure_list
82+
8183
from my_library.dataset_readers import SemanticScholarDatasetReader
8284

8385
class TestSemanticScholarDatasetReader(AllenNlpTestCase):
8486
def test_read_from_file(self):
8587
reader = SemanticScholarDatasetReader()
86-
dataset = reader.read('tests/fixtures/s2_papers.jsonl')
88+
instances = ensure_list(reader.read('tests/fixtures/s2_papers.jsonl'))
8789
```
8890

8991
Then we just want to make sure that the resulting dataset looks like we expect. We'll refer you to
@@ -112,16 +114,16 @@ are given as `Lists` here, but other than that, this just mimics the relevant fi
112114
blobs in the data file. We'll have our test make sure that what we read matches this:
113115

114116
```python
115-
assert len(dataset.instances) == 10
116-
fields = dataset.instances[0].fields
117+
assert len(instances) == 10
118+
fields = instances[0].fields
117119
assert [t.text for t in fields["title"].tokens] == instance1["title"]
118120
assert [t.text for t in fields["abstract"].tokens[:5]] == instance1["abstract"]
119121
assert fields["label"].label == instance1["venue"]
120-
fields = dataset.instances[1].fields
122+
fields = instances[1].fields
121123
assert [t.text for t in fields["title"].tokens] == instance2["title"]
122124
assert [t.text for t in fields["abstract"].tokens[:5]] == instance2["abstract"]
123125
assert fields["label"].label == instance2["venue"]
124-
fields = dataset.instances[2].fields
126+
fields = instances[2].fields
125127
assert [t.text for t in fields["title"].tokens] == instance3["title"]
126128
assert [t.text for t in fields["abstract"].tokens[:5]] == instance3["abstract"]
127129
assert fields["label"].label == instance3["venue"]

0 commit comments

Comments
 (0)