Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: JSON document format #603

Merged
merged 2 commits into from
Mar 12, 2025
Merged

Feature: JSON document format #603

merged 2 commits into from
Mar 12, 2025

Conversation

elshize
Copy link
Member

@elshize elshize commented Mar 8, 2025

Support JSONL collection format. This should make it easy to prepare a script that transforms any format into JSON and streams it to the parsing tool.

@elshize elshize self-assigned this Mar 8, 2025
Copy link

codecov bot commented Mar 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.92%. Comparing base (403342e) to head (d7cb511).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #603   +/-   ##
=======================================
  Coverage   93.91%   93.92%           
=======================================
  Files          82       82           
  Lines        3929     3931    +2     
=======================================
+ Hits         3690     3692    +2     
  Misses        239      239           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@elshize elshize requested review from JMMackenzie and amallia March 8, 2025 21:33
elshize added 2 commits March 9, 2025 16:23
Support JSONL collection format. This should make it easy to prepare a
script that transforms any format into JSON and streams it to the
parsing tool.

Signed-off-by: Michal Siedlaczek <[email protected]>
The script utilizes `ir-datasets` to download a dataset and prints it
out in a format that can be understood by `parse_collection`.

Signed-off-by: Michal Siedlaczek <[email protected]>
Copy link
Member

@JMMackenzie JMMackenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, nice work!

@elshize elshize merged commit 6616ce3 into main Mar 12, 2025
8 checks passed
@elshize elshize deleted the json-parser branch March 12, 2025 16:47
@@ -262,6 +262,8 @@ <h2 id="supported-formats"><a class="header" href="#supported-formats">Supported
<li><code>plaintext</code>: every line contains the document's title first, then any
number of whitespaces, followed by the content delimited by a new line
character.</li>
<li><code>jsonl</code>: every line is a JSON document with three fields: <code>title</code>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make title optional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we clarify how we treat title and content? Do we concatenate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"title" what in PISA we call a string document ID. We must have one. This has nothing to do with a title that could be part of content.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to clarify

@@ -420,6 +420,8 @@ <h2 id="supported-formats"><a class="header" href="#supported-formats">Supported
<li><code>plaintext</code>: every line contains the document's title first, then any
number of whitespaces, followed by the content delimited by a new line
character.</li>
<li><code>jsonl</code>: every line is a JSON document with three fields: <code>title</code>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

def parse_dataset(dataset_name):
dataset = ir.load(dataset_name)
for doc in dataset.docs_iter():
print(json.dumps({"title": doc.doc_id, "content": doc.text}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why doc_id as title?
For example

import ir_datasets
dataset = ir_datasets.load("beir/climate-fever")
for doc in dataset.docs_iter():
    doc # namedtuple<doc_id, text, title>
import ir_datasets
dataset = ir_datasets.load("msmarco-passage")
for doc in dataset.docs_iter():
    doc # namedtuple<doc_id, text>

Two examples: one has title and the other one does not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants