Skip to content

Commit

Permalink
added test case for virtual event extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
tholzheim committed Nov 9, 2022
1 parent 043ee96 commit c0ba52e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 0 additions & 2 deletions ceurws/ceur_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ def extractAndSetLocation(self, locationStr:str) -> (str, str):
cityWikidataId = bestMatch.wikidataid
country = bestMatch.country.name
countryWikidataId = bestMatch.country.wikidataid
print(self.getVolumeNumber(), locationStr, "→", bestMatch.name, bestMatch.country.name)
elif isinstance(bestMatch, Country):
country = bestMatch.wikidataid
print(self.getVolumeNumber(), locationStr, "→", bestMatch.name)
virtualEventKeywords = ["virtual", "online"]
for keyword in virtualEventKeywords:
if keyword in locationStr.lower():
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ xmltodict
pyFlaskBootstrap4>=0.5.1
flask-dropzone
# https://github.com/SmartDataAnalytics/OpenResearch
ConferenceCorpus>=0.0.37
ConferenceCorpus>=0.0.38
# https://pypi.org/project/pylodstorage/
pylodstorage>=0.4.7
# http://pydispatcher.sourceforge.net/
Expand Down
23 changes: 17 additions & 6 deletions tests/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_resolveLoctime(self):
("Annecy, France, July 6–9, 2016", "2016-07-06", "2016-07-09", "Q50189", "Q142"),
("Lisbon, Portugal, October 11, 2010", "2010-10-11", "2010-10-11", "Q597", "Q45"),
("Rende, Italy, November 19‐20, 2019", "2019-11-19", "2019-11-20", "Q53946", "Q38"),
("Online, September, 14 & 15, 2020", "2020-09-14", "2020-09-15", "Q7935096", None),
("Online, September, 14 & 15, 2020", "2020-09-14", "2020-09-15", None, None),
("Düsseldorf, Germany, September 28-29, 2009", "2009-09-28", "2009-09-29", "Q1718", "Q183"),
("Chicago, USA, October 23th and 26th, 2011", "2011-10-23", "2011-10-26", "Q1297", "Q30"),
("Oum El Bouaghi, Algeria, May 25 and 26, 2021", "2021-05-25", "2021-05-26", "Q5478122", "Q262"),
Expand All @@ -128,21 +128,32 @@ def test_resolveLoctime(self):
self.assertEqual(expectedCity, getattr(vol, "cityWikidataId", None))
self.assertEqual(expectedCountry, getattr(vol, "countryWikidataId",None))

def test_resolveLoctime_virtual_events(self):
"""
test extraction of virtual event information
"""
test_params = [

]
for param in test_params:
with self.subTest("Tests resolveLoctime on", param=param):
loctime, expectedDateFrom, expectedDateTo, expectedCity, expectedCountry = param

def test_locationExtraction(self):
"""
tests locationExtraction
"""
test_params=[
("Waterloo, Ontario, Canada, 4-7 2010", "Q639408", "Q16"), # not to be confused with Waterloo Sierra Leone
("Waterloo, Sierra Leone", "Q623241", "Q1044")
("Online, September, 14 & 15, 2020", True),
("Waterloo, Sierra Leone", False),
("Virtual Event, Pescara, Italy, September 12, 2022", True)
]
for param in test_params:
with self.subTest("Tests resolveLoctime on", param=param):
locStr, expectedCity, expectedCountry = param
locStr, is_virtual_event = param
vol = Volume()
vol.extractAndSetLocation(locationStr=locStr)
self.assertEqual(expectedCity, getattr(vol, "cityWikidataId"))
self.assertEqual(expectedCountry, getattr(vol, "countryWikidataId"))
self.assertEqual(is_virtual_event, vol.isVirtualEvent())

def test_removePartsMatching(self):
"""
Expand Down

0 comments on commit c0ba52e

Please sign in to comment.