Skip to content

Commit

Permalink
improves rating
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Apr 16, 2021
1 parent 96df908 commit f49cee4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
2 changes: 0 additions & 2 deletions migration/openresearch/eventcorpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class EventCorpus(object):
Towards a gold standard event corpus ...
'''


def __init__(self,debug=False):
'''
Constructor
Expand All @@ -24,7 +23,6 @@ def fromWikiUser(self,wikiUser):
self.eventList.debug=self.debug
self.eventList.fromCache(wikiUser)


self.eventSeriesList=EventSeriesList()
self.eventSeriesList.debug=self.debug
self.eventSeriesList.fromCache(wikiUser)
Expand Down
14 changes: 14 additions & 0 deletions migration/ormigrate/eventSeriesFixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@author: wf
'''
from ormigrate.fixer import PageFixer
from ormigrate.rating import Rating

class EventSeriesProvenanceFixer(PageFixer):
'''
Expand All @@ -15,4 +16,17 @@ def __init__(self):
'''
Constructor
'''

@classmethod
def getRating(cls,eventRecord):
hasDblp=eventRecord.get('dblpSeries') is not None
hasWikidata=eventRecord.get('wikidataId') is not None
if hasDblp and hasWikidata:
return Rating(1,Rating.ok,'Gold Standard series')
if hasDblp:
return Rating(4,Rating.ok,'Wikdata id missing for dblp series')
if hasWikidata:
return Rating(3,Rating.ok,'Wikdata only series')
return Rating(5,Rating.invalid,'Series provenance data missing')


25 changes: 14 additions & 11 deletions migration/tests/testIssue168.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestIssue168(unittest.TestCase):


def setUp(self):
self.debug=False
self.debug=True
pass


Expand All @@ -39,19 +39,22 @@ def testEventsWithSeries(self):
'''
eventCorpus=self.getEventCorpus(debug=self.debug)

def checkRatedLod(self,lod,errors):
def checkRatedLod(self,lod,errors,columns,showPainsAbove=8):
if len(errors)>0:
for error in errors:
print(error)
self.assertEqual(0,len(errors))
counter=Counter()
for record in lod:
rating=record["acronym"]
for column in columns:
counter=Counter()
for record in lod:
rating=record[column]
if self.debug:
if rating.pain>=showPainsAbove:
print (rating)
counter[rating.pain]+=1
if self.debug:
if rating.pain>=5:
print (rating)
counter[rating.pain]+=1
print(counter.most_common(50))
print (f"rating results for {column}:")
print(counter.most_common(50))
pass

def testRatingCallback(self):
Expand All @@ -60,9 +63,9 @@ def testRatingCallback(self):
'''
eventCorpus=self.getEventCorpus(debug=self.debug)
lod,errors=eventCorpus.eventList.getRatedLod(Event.rateMigration)
self.checkRatedLod(lod, errors)
self.checkRatedLod(lod, errors,['acronym','ordinal'])
lod,errors=eventCorpus.eventSeriesList.getRatedLod(EventSeries.rateMigration)
self.checkRatedLod(lod, errors)
self.checkRatedLod(lod, errors,['provenance'])


if __name__ == "__main__":
Expand Down

0 comments on commit f49cee4

Please sign in to comment.