コード例 #1
0
def test_etype_annotation(input):
    algorithm = GraphDiffSyncAlgorithm()
    ops = algorithm.do_algorithm(input[0], input[1])
    # check that original operations have default annotations
    for op in ops:
        for element in op._triple_info:
            if element.is_uri:
                assert element.etype == 'item'

    synchronizer = OntologySynchronizer(algorithm)
    synchronizer._annotate_triples(ops, input[0], input[1])
    # check that now the subjects of this ontology are classified as properties
    for op in ops:
        triple_info = op._triple_info
        assert triple_info.subject.etype == 'property'
コード例 #2
0
def _perform_sync(gitfile, mocked_adapter):
    algorithm = GraphDiffSyncAlgorithm()
    synchronizer = OntologySynchronizer(algorithm)
    ops = synchronizer.synchronize(gitfile.source_content,
                                   gitfile.target_content)
    for op in ops:
        res = op.execute(mocked_adapter)
    return ops
コード例 #3
0
def test_prop_range_annotation(input_range):
    algorithm = GraphDiffSyncAlgorithm()
    ops = algorithm.do_algorithm("", input_range[1])
    synchronizer = OntologySynchronizer(algorithm)
    synchronizer._annotate_triples(ops, "", input_range[1])
    expected = {
        f"{EX_PREFIX}authors": 'wikibase-item',
        f"{EX_PREFIX}fund": 'wikibase-item',
        f"{EX_PREFIX}isbn": 'string',
        f"{EX_PREFIX}projectEndDate": 'time',
        f"{EX_PREFIX}projectKeyword": 'string',
        f"{EX_PREFIX}projectFund": 'quantity',
        f"{OWL_BASE}subPropertyOf":
        None  # no range and datatype is not inferred
    }
    for op in ops:
        for el in op._triple_info:
            if el.uri in expected:
                assert el.wdi_proptype == expected[el.uri]
コード例 #4
0
ファイル: listener.py プロジェクト: mistermboy/hercules-sync
def _synchronize_files(files: List[GitFile]):
    LOGGER.info("Synchronizing files...")
    algorithm = GraphDiffSyncAlgorithm()
    adapter = WikibaseAdapter(app.config['WBAPI'], app.config['WBSPARQL'],
                              app.config['WBUSER'], app.config['WBPASS'])
    for file in files:
        synchronizer = OntologySynchronizer(algorithm)
        ops = synchronizer.synchronize(file.source_content, file.target_content)
        for op in ops:
            res = op.execute(adapter)
            if not res.successful:
                LOGGER.warning("Error synchronizing triple: %s", res.message)
    LOGGER.info("Synchronization finished.")
コード例 #5
0
 def algorithm(self):
     return GraphDiffSyncAlgorithm()
コード例 #6
0
def test_init():
    synchronizer = OntologySynchronizer(None)
    assert isinstance(synchronizer._algorithm, NaiveSyncAlgorithm)

    synchronizer = OntologySynchronizer(GraphDiffSyncAlgorithm())
    assert isinstance(synchronizer._algorithm, GraphDiffSyncAlgorithm)
コード例 #7
0
def operations_fixture(input):
    algorithm = GraphDiffSyncAlgorithm()
    return algorithm.do_algorithm(input[0], input[1])