Example #1
0
 def get_additional(cls, obj, **kwargs):
     """Return the value to put in the additional column of HoldingPen."""
     from inspirehep.modules.predicter.utils import get_classification_from_task_results
     keywords = get_classification_from_task_results(obj)
     results = obj.get_tasks_results()
     prediction_results = results.get("arxiv_guessing", {})
     if prediction_results:
         prediction_results = prediction_results[0].get("result")
     return render_template(
         'workflows/styles/harvesting_record_additional.html',
         object=obj,
         keywords=keywords,
         score=prediction_results.get("max_score"),
         decision=prediction_results.get("decision")
     )
Example #2
0
    def _filter_core_keywords(obj, eng):
        from inspirehep.utils.knowledge import check_keys
        from inspirehep.modules.predicter.utils import (
            get_classification_from_task_results,
            update_classification_in_task_results,
        )

        result = get_classification_from_task_results(obj)
        if result is None:
            return
        filtered_core_keywords = {}
        for core_keyword, times_counted in result.get("Core keywords").items():
            if not check_keys(filter_kb, [core_keyword]):
                filtered_core_keywords[core_keyword] = times_counted
        result["Filtered Core keywords"] = filtered_core_keywords
        update_classification_in_task_results(obj, result)
Example #3
0
def is_record_relevant(obj, *args, **kwargs):
    """Shall we halt this workflow for potential acceptance or just reject?"""
    from inspirehep.modules.predicter.utils import (
        get_classification_from_task_results,
    )
    results = obj.get_tasks_results()
    prediction_results = results.get("arxiv_guessing", {})
    classification_results = get_classification_from_task_results(obj)

    if prediction_results and classification_results:
        prediction_results = prediction_results[0].get("result")
        score = prediction_results.get("max_score")
        decision = prediction_results.get("decision")
        core_keywords = classification_results.get("Core keywords")
        if decision.lower() == "rejected" and score > 0 and \
                len(core_keywords) == 0:
            return False
    return True