Skip to content

Commit

Permalink
Add TREC COVID queries based from udel_fang_run3 (#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukuang committed May 5, 2020
1 parent d9e863e commit 0d4bcd5
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 0 deletions.
126 changes: 126 additions & 0 deletions src/main/python/trec-covid/generate_query_udel.py
@@ -0,0 +1,126 @@
# -*- coding: utf-8 -*-
"""
Anserini: A toolkit for reproducible information retrieval research built on Lucene
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import os
import argparse
import scispacy
import spacy
from lxml import etree


if __name__ == '__main__':
parser = argparse.ArgumentParser()

# general settings
parser.add_argument('--anserini_root', default='', help='Anserini path')
parser.add_argument('--output_file', help='output path for the query')
parser.add_argument(
'--round', default='1', choices=['1', '2'],
help='which round the query file should be generated for'
)
args = parser.parse_args()

# stopwords from
# https://github.com/igorbrigadir/stopwords/edit/master/en/galago_inquery.txt
stopwords = {
'a', 'about', 'above', 'according', 'across', 'after', 'afterwards', 'again',
'against', 'albeit', 'all', 'almost', 'alone', 'along', 'already', 'also',
'although', 'always', 'am', 'among', 'amongst', 'an', 'and', 'another',
'any', 'anybody', 'anyhow', 'anyone', 'anything', 'anyway', 'anywhere',
'apart', 'are', 'around', 'as', 'at', 'av', 'be', 'became', 'because',
'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind',
'being', 'below', 'beside', 'besides', 'between', 'beyond', 'both', 'but',
'by', 'can', 'cannot', 'canst', 'certain', 'cf', 'choose', 'contrariwise',
'cos', 'could', 'cu', 'day', 'do', 'does', 'doesn', 't', 'doing', 'dost',
'doth', 'double', 'down', 'dual', 'during', 'each', 'either', 'else',
'elsewhere', 'enough', 'et', 'etc', 'even', 'ever', 'every', 'everybody',
'everyone', 'everything', 'everywhere', 'except', 'excepted', 'excepting',
'exception', 'exclude', 'excluding', 'exclusive', 'far', 'farther',
'farthest', 'few', 'ff', 'first', 'for', 'formerly', 'forth', 'forward',
'from', 'front', 'further', 'furthermore', 'furthest', 'get', 'go', 'had',
'halves', 'hardly', 'has', 'hast', 'hath', 'have', 'he', 'hence',
'henceforth', 'her', 'here', 'hereabouts', 'hereafter', 'hereby', 'herein',
'hereto', 'hereupon', 'hers', 'herself', 'him', 'himself', 'hindmost', 'his',
'hither', 'hitherto', 'how','however', 'howsoever', 'i', 'ie', 'if', 'in',
'inasmuch', 'inc', 'include', 'included', 'including', 'indeed', 'indoors',
'inside', 'insomuch', 'instead', 'into', 'inward', 'inwards', 'is', 'it',
'its', 'itself', 'just', 'kg', 'kind', 'km', 'last', 'latter', 'latterly',
'less', 'lest', 'let', 'like', 'little', 'ltd', 'many', 'may', 'maybe', 'me',
'meantime', 'meanwhile', 'might', 'more','moreover', 'most', 'mostly', 'mr',
'mrs', 'ms', 'much', 'must', 'my', 'myself', 'namely', 'need', 'neither',
'never', 'nevertheless', 'next', 'no', 'nobody', 'none', 'nonetheless',
'noone', 'nope', 'nor', 'not', 'nothing', 'notwithstanding', 'now',
'nowadays', 'nowhere', 'of', 'off', 'often', 'ok', 'on', 'once', 'one',
'only', 'onto', 'or', 'other', 'others', 'otherwise', 'ought', 'our',
'ours', 'ourselves', 'out', 'outside', 'over', 'own', 'per', 'perhaps',
'plenty', 'provide', 'quite', 'rather', 'really', 'round', 'said', 'sake',
'same', 'sang', 'save', 'saw', 'see', 'seeing', 'seem', 'seemed', 'seeming',
'seems', 'seen', 'seldom', 'selves', 'sent', 'several', 'shalt', 'she',
'should', 'shown', 'sideways', 'since', 'slept', 'slew', 'slung', 'slunk',
'smote', 'so', 'some', 'somebody', 'somehow', 'someone', 'something',
'sometime', 'sometimes', 'somewhat', 'somewhere', 'spake', 'spat', 'spoke',
'spoken', 'sprang', 'sprung', 'stave', 'staves', 'still', 'such', 'supposing',
'than', 'that', 'the', 'thee', 'their', 'them', 'themselves', 'then', 'thence',
'thenceforth', 'there', 'thereabout', 'thereabouts', 'thereafter', 'thereby',
'therefore', 'therein', 'thereof', 'thereon', 'thereto', 'thereupon', 'these',
'they', 'this', 'those', 'thou', 'though', 'thrice', 'through', 'throughout',
'thru', 'thus', 'thy', 'thyself', 'till', 'to', 'together', 'too', 'toward',
'towards', 'ugh', 'unable', 'under', 'underneath', 'unless', 'unlike', 'until',
'up', 'upon', 'upward', 'upwards', 'us', 'use', 'used', 'using', 'very', 'via',
'vs', 'want', 'was', 'we', 'week', 'well', 'were', 'what', 'whatever',
'whatsoever', 'when', 'whence', 'whenever', 'whensoever', 'where', 'whereabouts',
'whereafter', 'whereas', 'whereat', 'whereby', 'wherefore', 'wherefrom',
'wherein', 'whereinto', 'whereof', 'whereon', 'wheresoever', 'whereto', 'whereunto',
'whereupon', 'wherever', 'wherewith', 'whether', 'whew', 'which', 'whichever',
'whichsoever', 'while', 'whilst', 'whither', 'who', 'whoa', 'whoever', 'whole',
'whom', 'whomever', 'whomsoever', 'whose', 'whosoever', 'why', 'will', 'wilt',
'with', 'within', 'without', 'worse', 'worst', 'would', 'wow', 'ye', 'year', 'yet',
'yippee', 'you', 'your', 'yours', 'yourself', 'yourselves'
}

nlp = spacy.load('en_core_sci_lg')
original_query_file_name = f'topics.covid-round{args.round}.xml'
original_query_file = os.path.join(
args.anserini_root,
'src/main/resources/topics-and-qrels',
original_query_file_name
)

root = etree.parse(original_query_file).getroot()
for topic in root:
qid = topic.attrib['number']
for q in topic:
if q.tag == 'query':
query = q.text.strip()
new = [w.text for w in nlp(query) if w.text not in stopwords]
elif q.tag == 'question':
question = q.text.strip()
new += [w.text for w in nlp(question).ents]

tags_to_be_removed = []
for q in topic:
if q.tag == 'query':
q.text = ' '.join(new)
else:
tags_to_be_removed.append(q)

for tag in tags_to_be_removed:
topic.remove(tag)

with open(args.output_file,'wb') as f:
f.write(etree.tostring(root))

92 changes: 92 additions & 0 deletions src/main/resources/topics-and-qrels/topics.covid-round1-udel.xml
@@ -0,0 +1,92 @@
<topics task="COVIDSearch 2020" batch="1">
<topic number="1">
<query>coronavirus origin origin COVID-19</query>
</topic>
<topic number="2">
<query>coronavirus response weather changes coronavirus changes weather</query>
</topic>
<topic number="3">
<query>coronavirus immunity SARS-CoV2 infected people immunity cross protection</query>
</topic>
<topic number="4">
<query>people die coronavirus causes death Covid-19</query>
</topic>
<topic number="5">
<query>animal models COVID-19 drugs SARS-CoV SARS-CoV-2 animal studies</query>
</topic>
<topic number="6">
<query>coronavirus test rapid testing rapid testing Covid-19</query>
</topic>
<topic number="7">
<query>serological tests coronavirus serological tests detect antibodies coronavirus</query>
</topic>
<topic number="8">
<query>coronavirus reporting lack testing availability underreporting true incidence Covid-19</query>
</topic>
<topic number="9">
<query>coronavirus Canada COVID-19 affected Canada</query>
</topic>
<topic number="10">
<query>coronavirus social distancing impact social distancing impact slowing spread COVID-19</query>
</topic>
<topic number="11">
<query>coronavirus hospital rationing guidelines triaging patients infected coronavirus</query>
</topic>
<topic number="12">
<query>coronavirus quarantine practices hospitals home quarantine</query>
</topic>
<topic number="13">
<query>coronavirus spread transmission routes coronavirus</query>
</topic>
<topic number="14">
<query>coronavirus super spreaders evidence COVID-19 super spreaders</query>
</topic>
<topic number="15">
<query>coronavirus body long coronavirus live body</query>
</topic>
<topic number="16">
<query>long coronavirus survive surfaces long coronavirus surfaces</query>
</topic>
<topic number="17">
<query>coronavirus clinical trials clinical trials coronavirus</query>
</topic>
<topic number="18">
<query>masks prevent coronavirus masks preventing infection Covid-19</query>
</topic>
<topic number="19">
<query>alcohol sanitizer kills coronavirus type hand sanitizer Covid-19</query>
</topic>
<topic number="20">
<query>coronavirus ACE inhibitors patients Angiotensin-converting enzyme inhibitors ACE increased risk COVID-19</query>
</topic>
<topic number="21">
<query>coronavirus mortality mortality rates populations</query>
</topic>
<topic number="22">
<query>coronavirus heart impacts cardiac complications patients COVID-19</query>
</topic>
<topic number="23">
<query>coronavirus hypertension complications COVID-19 associated hypertension</query>
</topic>
<topic number="24">
<query>coronavirus diabetes complications COVID-19 associated diabetes</query>
</topic>
<topic number="25">
<query>coronavirus biomarkers biomarkers severe clinical course 2019-nCOV infection</query>
</topic>
<topic number="26">
<query>coronavirus early symptoms initial symptoms Covid-19</query>
</topic>
<topic number="27">
<query>coronavirus asymptomatic infected Covid-19 asymptomatic</query>
</topic>
<topic number="28">
<query>coronavirus hydroxychloroquine evidence hydroxychloroquine treating Covid-19</query>
</topic>
<topic number="29">
<query>coronavirus drug repurposing SARS-CoV-2 proteins-human proteins interactions potential drug targets drugs information</query>
</topic>
<topic number="30">
<query>coronavirus remdesivir remdesivir effective treatment COVID-19</query>
</topic>
</topics>
107 changes: 107 additions & 0 deletions src/main/resources/topics-and-qrels/topics.covid-round2-udel.xml
@@ -0,0 +1,107 @@
<topics task="COVIDSearch 2020" batch="2">
<topic number="1">
<query>coronavirus origin origin COVID-19</query>
</topic>
<topic number="2">
<query>coronavirus response weather changes coronavirus changes weather</query>
</topic>
<topic number="3">
<query>coronavirus immunity SARS-CoV2 infected people immunity cross protection</query>
</topic>
<topic number="4">
<query>people die coronavirus causes death Covid-19</query>
</topic>
<topic number="5">
<query>animal models COVID-19 drugs SARS-CoV SARS-CoV-2 animal studies</query>
</topic>
<topic number="6">
<query>coronavirus test rapid testing rapid testing Covid-19</query>
</topic>
<topic number="7">
<query>serological tests coronavirus serological tests detect antibodies coronavirus</query>
</topic>
<topic number="8">
<query>coronavirus reporting lack testing availability underreporting true incidence Covid-19</query>
</topic>
<topic number="9">
<query>coronavirus Canada COVID-19 affected Canada</query>
</topic>
<topic number="10">
<query>coronavirus social distancing impact social distancing impact slowing spread COVID-19</query>
</topic>
<topic number="11">
<query>coronavirus hospital rationing guidelines triaging patients infected coronavirus</query>
</topic>
<topic number="12">
<query>coronavirus quarantine practices hospitals home quarantine</query>
</topic>
<topic number="13">
<query>coronavirus spread transmission routes coronavirus</query>
</topic>
<topic number="14">
<query>coronavirus super spreaders evidence COVID-19 super spreaders</query>
</topic>
<topic number="15">
<query>coronavirus body long coronavirus live body</query>
</topic>
<topic number="16">
<query>long coronavirus survive surfaces long coronavirus surfaces</query>
</topic>
<topic number="17">
<query>coronavirus clinical trials clinical trials coronavirus</query>
</topic>
<topic number="18">
<query>masks prevent coronavirus masks preventing infection Covid-19</query>
</topic>
<topic number="19">
<query>alcohol sanitizer kills coronavirus type hand sanitizer Covid-19</query>
</topic>
<topic number="20">
<query>coronavirus ACE inhibitors patients Angiotensin-converting enzyme inhibitors ACE increased risk COVID-19</query>
</topic>
<topic number="21">
<query>coronavirus mortality mortality rates populations</query>
</topic>
<topic number="22">
<query>coronavirus heart impacts cardiac complications patients COVID-19</query>
</topic>
<topic number="23">
<query>coronavirus hypertension complications COVID-19 associated hypertension</query>
</topic>
<topic number="24">
<query>coronavirus diabetes complications COVID-19 associated diabetes</query>
</topic>
<topic number="25">
<query>coronavirus biomarkers biomarkers severe clinical course 2019-nCOV infection</query>
</topic>
<topic number="26">
<query>coronavirus early symptoms initial symptoms Covid-19</query>
</topic>
<topic number="27">
<query>coronavirus asymptomatic infected Covid-19 asymptomatic</query>
</topic>
<topic number="28">
<query>coronavirus hydroxychloroquine evidence hydroxychloroquine treating Covid-19</query>
</topic>
<topic number="29">
<query>coronavirus drug repurposing SARS-CoV-2 proteins-human proteins interactions potential drug targets drugs information</query>
</topic>
<topic number="30">
<query>coronavirus remdesivir remdesivir effective treatment COVID-19</query>
</topic>
<topic number="31">
<query>difference coronavirus flu coronavirus seasonal flu</query>
</topic>
<topic number="32">
<query>coronavirus subtypes SARS-CoV-2 subtypes</query>
</topic>
<topic number="33">
<query>coronavirus vaccine candidates vaccine candidates tested Covid-19</query>
</topic>
<topic number="34">
<query>coronavirus recovery longer-term complications recover COVID-19</query>
</topic>
<topic number="35">
<query>coronavirus public datasets public datasets COVID-19</query>
</topic>
</topics>

0 comments on commit 0d4bcd5

Please sign in to comment.