Markus28 commited on
Commit
ee75274
1 Parent(s): c46d40e

don't use CSV file

Browse files
Files changed (1) hide show
  1. spanish_passage_retrieval.py +7 -11
spanish_passage_retrieval.py CHANGED
@@ -91,9 +91,6 @@ class PRES(datasets.GeneratorBasedBuilder):
91
  with open(os.path.join(extracted_path, 'relevance_passages.json')) as f:
92
  rel_passages = json.load(f)
93
 
94
- with open(os.path.join(extracted_path, 'relevance_documents.tsv')) as f:
95
- rel_docs = [(item, item[2]) for item in list(csv.reader(f, dialect='excel-tab'))[1:]]
96
-
97
  corpus_sentences = []
98
  corpus_documents = []
99
  queries = dict()
@@ -112,18 +109,17 @@ class PRES(datasets.GeneratorBasedBuilder):
112
  for annotated_topic in rel_passages['topics']:
113
  topic = annotated_topic['number']
114
  for annotation in annotated_topic['annotations']:
115
- did = f'doc_{annotation["docNo"]}_{annotation["start"]}_{annotation["end"]}'
116
- corpus_sentences.append({'_id': did, 'text': annotation['text']})
 
117
  for qid in topic_to_queries[topic]:
118
- qrels_s2s[qid].append(did)
 
119
 
120
  for doc in docs['documents']:
121
- did = f'doc_{doc["docNo"]}'
122
- corpus_documents.append({'_id': did, 'text': doc['text']})
123
 
124
- for topic_id, doc_id in rel_docs:
125
- for q_num in topic_to_queries[topic_id]:
126
- qrels_s2p[f'PR_ES_{q_num}'].append(f'doc_{doc_id}')
127
 
128
  self._data = {
129
  'corpus.sentences': corpus_sentences,
 
91
  with open(os.path.join(extracted_path, 'relevance_passages.json')) as f:
92
  rel_passages = json.load(f)
93
 
 
 
 
94
  corpus_sentences = []
95
  corpus_documents = []
96
  queries = dict()
 
109
  for annotated_topic in rel_passages['topics']:
110
  topic = annotated_topic['number']
111
  for annotation in annotated_topic['annotations']:
112
+ passage_id = f'doc_{annotation["docNo"]}_{annotation["start"]}_{annotation["end"]}'
113
+ doc_id = f'doc_{annotation["docNo"]}
114
+ corpus_sentences.append({'_id': passage_id, 'text': annotation['text']})
115
  for qid in topic_to_queries[topic]:
116
+ qrels_s2s[qid].append(passage_id)
117
+ qrels_s2p[qid].append(doc_id)
118
 
119
  for doc in docs['documents']:
120
+ doc_id = f'doc_{doc["docNo"]}'
121
+ corpus_documents.append({'_id': doc_id, 'text': doc['text']})
122
 
 
 
 
123
 
124
  self._data = {
125
  'corpus.sentences': corpus_sentences,