Page MenuHomeDevCentral

Query Wikidata to enrich FANTOIR file
ClosedPublic

Authored by dereckson on Jan 10 2023, 19:53.
Tags
None
Referenced Files
F2825000: D2731.id6947.diff
Thu, Apr 18, 13:16
F2824069: D2731.id6947.diff
Thu, Apr 18, 03:38
F2822903: D2731.diff
Thu, Apr 18, 00:21
Unknown Object (File)
Tue, Apr 16, 23:35
Unknown Object (File)
Mon, Apr 15, 02:23
Unknown Object (File)
Mon, Apr 15, 01:32
Unknown Object (File)
Mon, Apr 15, 01:31
Unknown Object (File)
Mon, Apr 15, 01:30
Subscribers
None

Details

Summary

Create a fantoir_wikidata table with label and P31 information
to offer rich typography and determine what kind of pseudo-voie
an entry is.

Query Wikidata through the SPARQL end-point and map results.
Select most relevant P31 information.

As some Wikidata entries imports code RIVOLI from BAN, we've two
concurrent formats for DOM/TOM. To allow a foreign key, but also
to identify such Wikidata entries for further improvement, we store
in a separate column the FANTOIR code used by Wikidata.

Ref T1751.

Test Plan

Run it and get a full fantoir_wikidata table

Diff Detail

Repository
rDS Nasqueron Datasources
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dereckson created this revision.

A lot of code to handle exceptions, mainly because there are
several formats used to represent the FANTOIR code.

Two strategies will be used to find the full code:

  1. Compute it when cle RIVOLI is missing or code direction can be determined.
  2. Query it for departments like 13/59/75/92/94 (*)

(*) Blocked by a search service to query the fantoir_... table to find information.
I'll work on that on another branch, as table can't exist or name can be unknown.

Also, sometimes a code FANTOIR will be missing. For example, I've found one
in a collectivity file not included in the national file on a Wikidata article.

We need code to skip them for now, and add a Wikidata health maintenance report later.

Don't hardcore wikidata table name twice

Clean comment and debug code

This version is ready and can correctly update Wikidata. If we can solve the 403 issue when connecting to SPARQL endpoint, it's ready to commit. Meanwhile, to test this code, you can run the query and save the result (in XML format) at tmp/wikidata-query-result.xml

Fix SPARQL client, refactor

Refactor to a cleaner implementation, move sparql mod to services

dereckson retitled this revision from WIP: Query Wikidata to enrich FANTOIR file to Query Wikidata to enrich FANTOIR file.Jan 15 2023, 01:24
dereckson edited the summary of this revision. (Show Details)
dereckson added inline comments.
src/services/sparql.rs
2

See T1752 for future projects to release this into a standalone crate.

This revision is now accepted and ready to land.Jan 15 2023, 01:29
This revision was automatically updated to reflect the committed changes.