def get_book_score_for_input_fields(result_record, hypothesis): """ returns Evidences for result_record matching hypothesis as a book. This means matching the pub against result_record's title field. See get_basic_score_for_input_fields for what hypothesis needs to have. :param result_record: :param hypothesis: :return: """ evidences = get_author_year_score_for_input_fields(result_record, hypothesis) if result_record["doctype"] == "book": evidences.add_evidence(1, "doctype") else: evidences.add_evidence(-1, "doctype") input_fields = hypothesis.get_detail("input_fields") add_publication_evidence(evidences, input_fields.get("pub"), input_fields.get("bibstem"), result_record.get("title", ""), result_record.get("bibcode", ""), result_record.get("bibstem", "")) return evidences
def get_basic_score_for_input_fields(result_record, hypothesis): """ returns a score between result_record and hypothesis. This evaluates the basic fields except for pub. hypothesis needs an input_fields detail that maps author, pub, volume, qualifier, page, and title keys to their values, as available. Empty or missing keys are legal. You should pass a normalized_authors detail (in addition to input_fields["author"]) to save the work for re-normalizing. If the author list had an et al (or similar), set an has_etal detail. The function will return a page_qualifier (for letters, pink pages, etc) detail if given, but will otherwise pull it from page numbers as passed in. :param result_record: :param hypothesis: :return: """ evidences = get_author_year_score_for_input_fields(result_record, hypothesis) input_fields = hypothesis.get_detail('input_fields') add_page_evidence(evidences, input_fields.get('page'), result_record.get('page', []), result_record.get('page_range', ''), ref_qualifier=hypothesis.get_detail('page_qualifier')) add_publication_evidence(evidences, input_fields.get('pub'), input_fields.get('bibstem', ''), result_record.get('pub', ''), result_record.get('bibcode', ''), result_record.get('bibstem', '')) add_title_evidence(evidences, input_fields.get('title'), result_record.get('title', '')) return evidences
def get_book_score_for_input_fields(result_record, hypothesis): """ returns Evidences for result_record matching hypothesis as a book. This means matching the pub against result_record's title field. :param result_record: :param hypothesis: :return: """ evidences = get_author_year_score_for_input_fields(result_record, hypothesis) if result_record["doctype"] in ["book", "inbook", "techreport"]: evidences.add_evidence(current_app.config["EVIDENCE_SCORE_RANGE"][1], "doctype") else: evidences.add_evidence(current_app.config["EVIDENCE_SCORE_RANGE"][0], "doctype") input_fields = hypothesis.get_detail("input_fields") # book does not have volume and page number # but if reference has score it so that we would not have false positive add_volume_evidence(evidences, input_fields.get('volume', None), result_record.get('volume', None), result_record.get('issue'), result_record.get('pub_raw')) add_page_evidence(evidences, input_fields.get('page', None), result_record.get('page', None), result_record.get('page_range', ''), result_record.get('eid', None), hypothesis.get_detail('page_qualifier'), input_fields.get('refstr', '')) add_publication_evidence( evidences, hypothesis.get_hint("title") or input_fields.get("pub", ""), input_fields.get("bibstem", ""), input_fields.get("refstr", ""), result_record.get("title", ""), result_record.get("bibcode", ""), result_record.get("bibstem", "")) return evidences
def get_chapter_score_for_input_fields(result_record, hypothesis): """ returns evidences based on author, year, volume and/or page, and publication or title, when solr record is a chapter in a proceeding or in a book it comes here :param result_record: :param hypothesis: :return: """ evidences = get_author_year_score_for_input_fields(result_record, hypothesis) + \ get_volume_page_score_for_input_fields(result_record, hypothesis) input_fields = hypothesis.get_detail("input_fields") # if comparing against inproceedigns record in solr, compare both pub and title # aginst both pub and title in solr # inproceedings reference string, depending on the publications, interchanges the order of title and journal # include the one with the highest score in the final score ref_pubs = [ input_fields.get("pub", ""), input_fields.get("pub", ""), input_fields.get("title", ""), input_fields.get("title", "") ] ads_pubs = [ result_record.get("title", ""), result_record.get("pub_raw", ""), result_record.get("title", ""), result_record.get("pub_raw", "") ] track_evidence = Evidences() for ref_pub, ads_pub in zip(ref_pubs, ads_pubs): tmp_evidence = Evidences() add_publication_evidence(tmp_evidence, ref_pub, input_fields.get("bibstem", ""), input_fields.get("refstr", ""), ads_pub, result_record.get("bibcode", ""), result_record.get("bibstem", "")) if tmp_evidence.get_score() > track_evidence.get_score(): track_evidence = tmp_evidence evidences = evidences + track_evidence return evidences
def get_author_year_pub_score_for_input_fields(result_record, hypothesis): """ returns evidences based on just author, year and publication. :param result_record: :param hypothesis: :return: """ evidences = get_author_year_score_for_input_fields(result_record, hypothesis) input_fields = hypothesis.get_detail("input_fields") add_publication_evidence(evidences, input_fields.get("pub", ""), input_fields.get("bibstem", ""), input_fields.get("refstr", ""), result_record.get("pub", ""), result_record.get("bibcode", ""), result_record.get("bibstem", "")) return evidences