-
Notifications
You must be signed in to change notification settings - Fork 6
Better ir_datasets integration.
#37
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,7 +90,8 @@ def _extract_fields(cls, fields_str): | |
| try: | ||
| return [cls.FIELD_MAP[f.lower()] for f in fields] | ||
| except KeyError as e: | ||
| raise ConfigError(f"Unrecognized topic field: {e}") | ||
| LOGGER.warning(f"Using unrecognized topic fields {e}, may cause unexpected results.") | ||
| return fields | ||
|
|
||
|
|
||
| class SgmlTopicReader(InputIterator): | ||
|
|
@@ -257,16 +258,24 @@ def __init__(self, path, encoding, lang, **kwargs): | |
| self.path = path | ||
| self.lang = lang | ||
| self.dataset = ir_datasets.load(self.path) | ||
| dataset_lang = LangStandardizer.iso_639_3(self.dataset.queries.lang) | ||
| assert dataset_lang == self.lang, f"Query language code from {path} is not {lang} but {dataset_lang}." | ||
|
Comment on lines
-260
to
-261
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A user must list the language in the topics config, but it is not checked against the language of the downloaded dataset. Is the language code of the dataset not consistent? I'd probably put a comment in there to indicate we're not checking the language because xyz. |
||
| self.queries = iter(self.dataset.queries) | ||
|
|
||
| def __iter__(self): | ||
| return self | ||
|
|
||
| def __next__(self): | ||
| q = next(self.queries) | ||
| return Topic(q.query_id, self.lang, q.text, getattr(q, 'description', None), None) | ||
| topic = Topic(q.query_id, self.lang, None, None, None) | ||
|
|
||
| for field in self.dataset.queries_cls()._fields: | ||
| if field in ['query_id']: | ||
| continue | ||
| elif field == 'description': | ||
| topic.desc = q.description | ||
| else: | ||
| setattr(topic, field, getattr(q, field)) | ||
|
|
||
| return topic | ||
|
|
||
| def __len__(self): | ||
| return len(self.dataset.queries) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| run: | ||
| name: ir_datasets testing using hc4_zho_test | ||
|
|
||
| documents: | ||
| input: | ||
| format: irds | ||
| lang: zho | ||
| path: hc4/zh/test | ||
| fields: title+text | ||
| process: | ||
| normalize: | ||
| lowercase: true | ||
| report: false | ||
| stem: false | ||
| stopwords: lucene | ||
| strict_check: true | ||
| tokenize: spacy | ||
| output: true | ||
|
|
||
| database: | ||
| name: sqlite | ||
| output: true | ||
|
|
||
| index: | ||
| name: lucene | ||
| output: true | ||
|
|
||
| topics: | ||
| input: | ||
| format: irds | ||
| lang: eng | ||
| source: original | ||
| encoding: utf8 | ||
| path: hc4/zh/test | ||
| fields: title | ||
|
|
||
| queries: | ||
| output: true | ||
| parse: false | ||
| process: | ||
| normalize: | ||
| lowercase: true | ||
| report: false | ||
| stem: false | ||
| stopwords: lucene | ||
| strict_check: false | ||
| tokenize: spacy | ||
| psq: | ||
| lang: eng | ||
| normalize: | ||
| lowercase: true | ||
| report: false | ||
| path: ./samples/data/eng_zho_transtable_small.dict | ||
| stem: false | ||
| stopwords: lucene | ||
| threshold: 0.97 | ||
|
|
||
| retrieve: | ||
| b: 0.4 | ||
| fb_docs: 10 | ||
| fb_terms: 10 | ||
| k1: 0.9 | ||
| log_explanations: false | ||
| log_explanations_cutoff: 10 | ||
| mu: 1000 | ||
| name: bm25 | ||
| number: 1000 | ||
| original_query_weight: 0.5 | ||
| output: retrieve | ||
| parse: false | ||
| psq: true | ||
| rm3: false | ||
| rm3_logging: false | ||
|
|
||
| score: | ||
| input: | ||
| format: irds | ||
| path: hc4/zh/test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| run: | ||
| name: ir_datasets testing using hc4_zho_test ht queries | ||
|
|
||
| topics: | ||
| input: | ||
| format: irds | ||
| lang: zho | ||
| source: original | ||
| encoding: utf8 | ||
| path: hc4/zh/test | ||
| fields: ht_title | ||
|
|
||
| queries: | ||
| output: true | ||
| parse: false | ||
| process: | ||
| normalize: | ||
| lowercase: true | ||
| report: false | ||
| stem: false | ||
| stopwords: lucene | ||
| strict_check: false | ||
| tokenize: spacy | ||
|
|
||
| retrieve: | ||
| input: | ||
| index: | ||
| path: ./runs/ir_datasets-testing-using-hc4_zho_test/index | ||
| b: 0.4 | ||
| fb_docs: 10 | ||
| fb_terms: 10 | ||
| k1: 0.9 | ||
| log_explanations: false | ||
| log_explanations_cutoff: 10 | ||
| mu: 1000 | ||
| name: bm25 | ||
| number: 1000 | ||
| original_query_weight: 0.5 | ||
| output: retrieve | ||
| parse: false | ||
| psq: false | ||
| rm3: false | ||
| rm3_logging: false | ||
|
|
||
| score: | ||
| input: | ||
| format: irds | ||
| path: hc4/zh/test |
This file was deleted.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wouldn't we want this to throw an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this is because of item 2:
I'll have to look more into this as I prefer to keep the checking in to catch typos or other problems with data.