Esempio n. 1
0
    def _match_with_invenio_matcher(obj, eng):
        from invenio_matcher.api import match as _match

        if queries is None:
            queries_ = [{"type": "exact", "match": "dois.value"}, {"type": "exact", "match": "arxiv_eprints.value"}]
        else:
            queries_ = queries

        record_matches = {
            "recids": [],
            "records": [],
            "base_url": os.path.join(current_app.config["SERVER_NAME"], "record"),
        }

        record = {}
        record["dois.value"] = get_value(obj.data, "dois.value")
        record["arxiv_eprints.value"] = get_value(obj.data, "arxiv_eprints.value")
        for matched_record in _match(record, queries=queries_, index=index, doc_type=doc_type):
            matched_recid = matched_record.record.get("id")
            record_matches["recids"].append(matched_recid)
            record_matches["records"].append({"source": matched_record.record.dumps(), "score": matched_record.score})

        if len(record_matches["recids"]) > 0:
            obj.extra_data["record_matches"] = record_matches
            return True
        return False
Esempio n. 2
0
    def _match_with_invenio_matcher(obj, eng):
        model = eng.workflow_definition.model(obj)
        record = get_record_from_model(model)

        if queries is None:
            queries_ = [
                {'type': 'exact', 'match': 'dois.value'},
                {'type': 'exact', 'match': 'arxiv_eprints.value'}
            ]
        else:
            queries_ = queries

        record_matches = {
            "recids": [],
            "records": [],
            "base_url": os.path.join(
                cfg["CFG_SITE_URL"],
                'record'
            )
        }

        for matched_record in _match(record, queries=queries_, index=index, doc_type='record'):
            matched_recid = matched_record.record.get('control_number')
            record_matches['recids'].append(matched_recid)
            record_matches['records'].append({
                "source": matched_record.record.dumps(),
                "score": matched_record.score
            })

        obj.extra_data["record_matches"] = record_matches

        return bool(record_matches['recids'])
Esempio n. 3
0
    def _match_with_invenio_matcher(obj, eng):
        from invenio_matcher.api import match as _match

        if queries is None:
            queries_ = [{
                'type': 'exact',
                'match': 'dois.value'
            }, {
                'type': 'exact',
                'match': 'arxiv_eprints.value'
            }]
        else:
            queries_ = queries

        record_matches = {
            "recids": [],
            "records": [],
            "base_url": os.path.join(current_app.config["SERVER_NAME"],
                                     'record')
        }

        record = {}
        record['dois.value'] = get_value(obj.data, 'dois.value')
        record['arxiv_eprints.value'] = get_value(obj.data,
                                                  'arxiv_eprints.value')
        for matched_record in _match(record,
                                     queries=queries_,
                                     index=index,
                                     doc_type=doc_type):
            matched_recid = matched_record.record.get('id')
            record_matches['recids'].append(matched_recid)
            record_matches['records'].append({
                "source":
                matched_record.record.dumps(),
                "score":
                matched_record.score
            })

        if len(record_matches['recids']) > 0:
            obj.extra_data["record_matches"] = record_matches
            return True
        return False
Esempio n. 4
0
    def _match_with_invenio_matcher(obj, eng):
        from invenio_matcher.api import match as _match

        if queries is None:
            queries_ = [
                {'type': 'exact', 'match': 'dois.value'},
                {'type': 'exact', 'match': 'arxiv_eprints.value'}
            ]
        else:
            queries_ = queries

        record_matches = {
            "recids": [],
            "records": [],
            "base_url": os.path.join(
                current_app.config["SERVER_NAME"],
                'record'
            )
        }

        record = {}
        record['dois.value'] = get_value(obj.data, 'dois.value')
        record['arxiv_eprints.value'] = get_value(
            obj.data, 'arxiv_eprints.value'
        )
        for matched_record in _match(
            record,
            queries=queries_,
            index=index,
            doc_type=doc_type
        ):
            matched_recid = matched_record.record.get('id')
            record_matches['recids'].append(matched_recid)
            record_matches['records'].append({
                "source": matched_record.record.dumps(),
                "score": matched_record.score
            })

        if len(record_matches['recids']) > 0:
            obj.extra_data["record_matches"] = record_matches
            return True
        return False