def test_regression_3(self): cluster.objects.create(id=1, name="lorem ipsum dolor") result = [ obj.name for obj in search_title( "lorem ipsum dolores", threshold=0.5, limit=5) ] self.assertEqual(len(result), 1)
def test_regression_2(self): cluster.objects.create( id=1, name= "high temperature bonding solutions enabling thin wafer process and handling on 3dic manufacturing" ) result = search_title("TSV process solution for 3D-IC.") print(result)
def test_match2_no_results(self): cluster.objects.create(id=1, name="lorem ipsum dolor title") cluster.objects.create(id=2, name="lorem hababhu maklu title") cluster.objects.create(id=3, name="dolor maraku rtrua title") cluster.objects.create(id=4, name="dolor maraku rtrua title lorem") cluster.objects.create(id=5, name="lorem ipsum dor") cluster.objects.create(id=6, name="lorem ipsum dolor") result = [obj.name for obj in search_title("funny bunny")] self.assertEqual(result, [])
def test_regression_4(self): title = normalize_title( "Beneficial effects of quercetin on sperm parameters in streptozotocin induced diabetic male rats" ) cluster.objects.create(id=1, name=title) result = search_title( "Beneficial effects of quercetin on sperm parameters in streptozotocin‐induced diabetic male rats" ) # test fails so far self.assertEqual(len(result), 1)
def test_regression_3(self): title = normalize_title( "Physical activity 153 and incidence of coronary heart disease in middle-aged women Relative weight gain and obesity as a child predict metabolic and men" ) cluster.objects.create(id=1, name=title) result = search_title( "Physical activity and incidence of coronary heart disease in middle-aged women and men." ) # test fails so far self.assertEqual(len(result), 1)
def test_match_limit(self): cluster.objects.create(id=1, name="lorem ipsum dolor title") cluster.objects.create(id=2, name="lorem ipsum title") cluster.objects.create(id=3, name="dolor lorem") cluster.objects.create(id=4, name="dolor lorem") cluster.objects.create(id=5, name="lorem ipsum dor") cluster.objects.create(id=6, name="lorem ipsum dolor") result = [ obj.name for obj in search_title("lorem", threshold=0, limit=5) ] self.assertEqual(len(result), 5)
def test_regression(self): cluster.objects.create( id=1, name="shrec10 track nonrigid 3d shape retrieval") cluster.objects.create( id=2, name= "shrec 11 track shape retrieval on nonrigid 3d watertight meshes") cluster.objects.create( id=3, name= "retrieval of nonrigid textured shapes using low quality 3d models" ) cluster.objects.create( id=4, name="canonical forms for nonrigid 3d shape retrieval") result = [ obj.name for obj in search_title("Non-rigid 3D Shape Retrieval.") if obj is not None ] self.assertEqual(len(result), 2)
def run(self, test_mode=False): today = date.today() compare_date = date.today( ) if test_mode is False else date.today() + datetime.timedelta(days=1) reference_list = [] # fetch all single_references of an open_ref # fetch open_references to gather all ingester url_objects openreference_list = OpenReferences.objects.filter( last_updated__lt=compare_date).select_related('ingester_key').only( 'ingester_key')[:self.limit] for open_ref in openreference_list: open_ref.last_updated = today open_ref.save() single_ref_list = SingleReference.objects.filter( source=open_ref).filter(Q(status='OP') | Q(status='INC')).only( 'tries', 'title', 'status').all() for single_ref in single_ref_list: title_matches = search_title(single_ref.title, threshold=0.8) if len(title_matches) == 1: # single match: create reference for only match PubReference.objects.get_or_create( reference=title_matches[0], source=open_ref.ingester_key, defaults={ 'original_title': single_ref.title, 'original_key': single_ref.id }) #reference_list.append(PubReference(reference=title_matches[0], source=open_ref.ingester_key, original_title=single_ref.title)) single_ref.status = 'FIN' elif len(title_matches) == 0: # no match: increment tries and set as incomplete single_ref.tries += 1 single_ref.status = 'INC' if single_ref.tries < LIMBO_LIMIT else 'LIM' else: # multi match: normal_title = normalize_title(single_ref.title) single_ref.status = 'LIM' for title in title_matches: if title.name == normal_title: single_ref.status = 'FIN' PubReference.objects.get_or_create( reference=title, source=open_ref.ingester_key, defaults={ 'original_title': single_ref.title, 'original_key': single_ref.id }) #reference_list.append(PubReference(reference=title, source=open_ref.ingester_key, original_title=single_ref.title)) single_ref.save() try: PubReference.objects.bulk_create(reference_list) except IntegrityError: # duplicate key on insert, insert everything manually for element in reference_list: print("Rollback") PubReference.objects.get_or_create( reference=element.reference, source=element.source, original_title=single_ref.title, original_key=single_ref.id)