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

Dataset nih #32

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions config/dataset/nih_multihop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
train:
doc: null
query: null
dev:
doc:
init_args:
_target_: modules.processors.nih_dataset_processor.NIHDatasetMultiHop
is_query: false
split: "train"

query:
init_args:
_target_: modules.processors.nih_dataset_processor.NIHDatasetMultiHop
is_query: true
split: "train"

test:
doc: null
query: null
19 changes: 19 additions & 0 deletions config/dataset/nih_number.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
train:
doc: null
query: null
dev:
doc:
init_args:
_target_: modules.processors.nih_dataset_processor.NIHDatasetNumber
is_query: false
split: "train"

query:
init_args:
_target_: modules.processors.nih_dataset_processor.NIHDatasetNumber
is_query: true
split: "train"

test:
doc: null
query: null
19 changes: 19 additions & 0 deletions config/dataset/nih_simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
train:
doc: null
query: null
dev:
doc:
init_args:
_target_: modules.processors.nih_dataset_processor.NIHDatasetSimple
is_query: false
split: "train"

query:
init_args:
_target_: modules.processors.nih_dataset_processor.NIHDatasetSimple
is_query: true
split: "train"

test:
doc: null
query: null
47 changes: 47 additions & 0 deletions modules/processors/nih_dataset_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import datasets
import os
from ..dataset_processor import *

class NIHDataset(Processor):

def __init__(self, config_name='number',is_query=True,*args, **kwargs):
self.dataset_name='nih_v1_'+config_name
if is_query:
self.dataset_name+='_query'
else:
self.dataset_name+='_doc'
self.conf_name= config_name
self.is_query=is_query
super().__init__(dataset_name=self.dataset_name,*args, **kwargs)

def process(self):
print(self.conf_name)
sclincha marked this conversation as resolved.
Show resolved Hide resolved
d = datasets.load_dataset('naver/bergen_nih_v1',self.conf_name)[self.split]
maxime-louis marked this conversation as resolved.
Show resolved Hide resolved
if self.is_query:
#reprocess single str label into a list of str
dataset = d.rename_column("qid", "id")
dataset = dataset.rename_column("query", "content")
dataset = dataset.remove_columns(['did', 'doc'])
dataset = dataset.map(lambda x: {"label": [str(x["label"])]})
return dataset
else:
#document dataset
dataset = d.rename_column("did", "id")
dataset = dataset.rename_column("doc", "content")
dataset = dataset.remove_columns(['qid', 'query','label'])
print(dataset[:10])
return dataset

maxime-louis marked this conversation as resolved.
Show resolved Hide resolved
class NIHDatasetNumber(NIHDataset):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs,config_name='number')

class NIHDatasetSimple(NIHDataset):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs,config_name='simple')

class NIHDatasetMultiHop(NIHDataset):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs,config_name='multihop')


512 changes: 512 additions & 0 deletions runs/run.oracle.nih_v1_multihop_query.dev.trec

Large diffs are not rendered by default.

512 changes: 512 additions & 0 deletions runs/run.oracle.nih_v1_number_query.dev.trec

Large diffs are not rendered by default.

512 changes: 512 additions & 0 deletions runs/run.oracle.nih_v1_simple_query.dev.trec

Large diffs are not rendered by default.