Stanford Natural Language Inference

Various functions for accessing the SNLI dataset.

dynn.data.snli.download_snli(path='.', force=False)

Downloads the SNLI from “https://nlp.stanford.edu/projects/snli/

Parameters:
  • path (str, optional) – Local folder (defaults to “.”)
  • force (bool, optional) – Force the redownload even if the files are already at path
dynn.data.snli.load_snli(path, terminals_only=True, binary=False)

Loads the SNLI dataset

Returns the train, dev and test sets in a dictionary, each as a tuple of containing the trees and the labels.

Parameters:
  • path (str) – Path to the folder containing the snli_1.0.zip file
  • terminals_only (bool) – Only return the terminals and not the trees
Returns:

Dictionary containing the train, dev and test sets

(tuple of tree/labels tuples)

Return type:

dict

dynn.data.snli.read_snli(split, path, terminals_only=True, binary=False)

Iterates over the SNLI dataset

Example:

for tree, label in read_snli("train", "/path/to/snli"):
    train(tree, label)
Parameters:
  • split (str) – Either "train", "dev" or "test"
  • path (str) – Path to the folder containing the snli_1.0.zip files
  • terminals_only (bool) – Only return the terminals and not the trees
Returns:

tree, label

Return type:

tuple