Skip to content

Commit

Permalink
Adds #195 and its rating
Browse files Browse the repository at this point in the history
  • Loading branch information
MusaabKh committed Apr 26, 2021
1 parent 2075669 commit aedb76c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions migration/openresearch/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
'''
Expand Down Expand Up @@ -480,6 +481,10 @@ def rateMigration(cls,event,eventRecord):
{
"column": "AcceptanceRatePainRating",
"fixer": AcceptanceRateFixer
},
{
"column": "BiblographicFieldFixer",
"fixer": BiblographicFieldFixer
}
]
return PageFixer.rateWithFixers(pageFixerList, event,eventRecord)
Expand Down
44 changes: 44 additions & 0 deletions migration/ormigrate/issue195.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions migration/tests/testDataFixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aedb76c

Please sign in to comment.