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

Commit

Permalink
Make snli dataset reader work with unlabeled instances (#234)
Browse files Browse the repository at this point in the history
* Make snli dataset reader work with unlabeled instances

* Add entry to changelog
  • Loading branch information
nelson-liu committed Mar 29, 2021
1 parent eb72cdc commit a8e0b00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated `QaNet` and `NumericallyAugmentedQaNet` models to remove bias for layers that are followed by normalization layers.
- Updated the model cards for `rc-naqanet`, `vqa-vilbert` and `ve-vilbert`.
- Predictors now work for the vilbert-multitask model.
- Support unlabeled instances in `SnliDatasetReader`.


## [v2.1.0](https://github.com/allenai/allennlp-models/releases/tag/v2.1.0) - 2021-02-24
Expand Down
4 changes: 2 additions & 2 deletions allennlp_models/pair_classification/dataset_readers/snli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def _read(self, file_path: str):
with open(file_path, "r") as snli_file:
example_iter = (json.loads(line) for line in snli_file)
filtered_example_iter = (
example for example in example_iter if example["gold_label"] != "-"
example for example in example_iter if example.get("gold_label") != "-"
)
for example in self.shard_iterable(filtered_example_iter):
label = example["gold_label"]
label = example.get("gold_label")
premise = example["sentence1"]
hypothesis = example["sentence2"]
yield self.text_to_instance(premise, hypothesis, label)
Expand Down

0 comments on commit a8e0b00

Please sign in to comment.