allenai / ir_datasets

Provides a common interface to many IR ranking datasets.
https://ir-datasets.com/
Apache License 2.0
309 stars 42 forks source link

handling .z files as gzip #191

Open seanmacavaney opened 2 years ago

seanmacavaney commented 2 years ago

regarding #189

Took the opportunity to improve the tests here for the variety of formats, etc. that TrecDocs may encounter.

@ArthurCamara -- mind running python -m tests.integration.disks45 when using your .z files when you have a chance?

ArthurCamara commented 2 years ago

That did not work, actually. 🤔 seems like Python's Gzip implementation does not recognize it as a gzip file (however, gunzip can decompress it no problem) Digging deeper, .z is a REALLY old file format, created by using Pack: https://en.wikipedia.org/wiki/Pack_(compression) and Gzip's documentation says that it cannot handle it:

Note that additional file formats which can be decompressed by the gzip and gunzip programs, such as those produced by compress and pack, are not supported by this module.

I've searched for a bit, but couldn't find any Python library that can deal with it properly, it seems.

seanmacavaney commented 2 years ago

Hmmm, okay, I see.

Even though the format is relatively simple, I'm not so keen on writing my own parser for the format.

So the only other reasonable option for supporting it in the software itself would be to invoke gunzip (or similar) when it encounters these files. This comes with overhead and isn't good for cross-platform compatibility, but I think I could live with it to handle this (presumably) uncommon format.

ArthurCamara commented 2 years ago

I agree. I don't see a reason to worry too much about it. We can either 1. Pip everything into gunzip using subprocess.Popen even only os.system if we don't care about the return value or 2. Throw an error message asking the user to do that by themselves.