From aedb76c8270ed19a6d008d9fc400d86c996ab651 Mon Sep 17 00:00:00 2001 From: MusaabKh Date: Mon, 26 Apr 2021 05:54:21 +0200 Subject: [PATCH] Adds #195 and its rating --- migration/openresearch/event.py | 5 ++++ migration/ormigrate/issue195.py | 44 ++++++++++++++++++++++++++++++++ migration/tests/testDataFixes.py | 20 +++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 migration/ormigrate/issue195.py diff --git a/migration/openresearch/event.py b/migration/openresearch/event.py index 9801528..5d30396 100644 --- a/migration/openresearch/event.py +++ b/migration/openresearch/event.py @@ -20,6 +20,7 @@ from ormigrate.eventSeriesFixer import EventSeriesProvenanceFixer, EventSeriesTitleFixer from ormigrate.issue152 import AcceptanceRateFixer from ormigrate.issue170_curation import CurationQualityChecker +from ormigrate.issue195 import BiblographicFieldFixer class OREntityList(JSONAbleList): ''' @@ -480,6 +481,10 @@ def rateMigration(cls,event,eventRecord): { "column": "AcceptanceRatePainRating", "fixer": AcceptanceRateFixer + }, + { + "column": "BiblographicFieldFixer", + "fixer": BiblographicFieldFixer } ] return PageFixer.rateWithFixers(pageFixerList, event,eventRecord) diff --git a/migration/ormigrate/issue195.py b/migration/ormigrate/issue195.py new file mode 100644 index 0000000..f06c287 --- /dev/null +++ b/migration/ormigrate/issue195.py @@ -0,0 +1,44 @@ +''' +@author: mk +''' +import re +from ormigrate.rating import Rating +from ormigrate.fixer import PageFixer + + +class BiblographicFieldFixer(PageFixer): + ''' + fixer for Acceptance Rate Not calculated + https://github.com/SmartDataAnalytics/OpenResearch/issues/195 + ''' + + def __init__(self, wikiId="or",baseUrl="https://www.openresearch.org/wiki/",debug=False): + ''' + Constructor + ''' + # call super constructor + super(BiblographicFieldFixer, self).__init__(wikiId, baseUrl) + self.debug = debug + self.nosub = 0 + self.noacc = 0 + self.painrating = None + + @classmethod + def getRating(self, eventRecord): + painrating = None + hasBiblographic = False + hasProceedings = False + for key in eventRecord: + checker = str(key).lower() + if checker.find("bibliography") != -1: + if checker.find('proceedings') != -1: + hasProceedings = True + else: + hasBiblographic= True + if hasProceedings: + painrating = Rating(7, Rating.ok,f'Has Proceedings Bibliography field exists which is not defined as a property in OR') + elif hasBiblographic: + painrating = Rating(5, Rating.ok,f'Has Bibliography field exists which is defined as a property in OR but is not used properly') + else: + painrating = Rating(1, Rating.ok, f'Bibliography field not found in event') + return painrating diff --git a/migration/tests/testDataFixes.py b/migration/tests/testDataFixes.py index 06578f5..e07dac6 100644 --- a/migration/tests/testDataFixes.py +++ b/migration/tests/testDataFixes.py @@ -11,6 +11,8 @@ from ormigrate.issue71 import DateFixer from ormigrate.issue163 import SeriesFixer from ormigrate.issue166 import WikiCFPIDFixer +from ormigrate.issue195 import BiblographicFieldFixer + from ormigrate.toolbox import HelperFunctions as hf from ormigrate.fixer import PageFixer @@ -168,6 +170,24 @@ def testIssue71(self): self.assertTrue(fixed_dic[0]['Start date'] == '2020/09/27') self.assertTrue(fixed_dic[0]['Paper deadline'] == '2020/05/28') + def testIssue195(self): + ''' + test for fixing invalid dates + https://github.com/SmartDataAnalytics/OpenResearch/issues/71 + ''' + eventRecords = [{'has Proceedings Bibliography': 'test', 'has Bibliography': 'test'}, + {'startDate': '20 Feb, 2020', 'endDate': '20 Feb, 2020'}, + {'Ordinal': 2}, + {'has Bibliography':'test'} + ] + painRatings=[] + fixer=BiblographicFieldFixer(debug=self.debug) + for event in eventRecords: + painRating = fixer.getRating(event) + self.assertIsNotNone(painRating) + painRatings.append(painRating.pain) + self.assertEqual(painRatings,[7,1,1,5]) + def testIssue163(self): ''' Series Fixer