Skip to content

Commit

Permalink
WIP #10
Browse files Browse the repository at this point in the history
  • Loading branch information
Adafede committed Jan 4, 2024
1 parent c4e5939 commit 11d4d55
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions tests/fixtures/taxa_names_com.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
taxon,taxon_name,lang
1,Taxon Un, fr
1,Taxon One, en
2,Taxon Deux, fr
2 changes: 2 additions & 0 deletions tests/test_datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class TestDataModel:
def test_make_coverage_happy(self, tmp_path):
setup_from_fixture(tmp_path)

# Eventually TODO add taxa_names_com

def test_get_taxon_name_from_tid(self, data_model):
assert data_model.get_taxon_name_from_tid(1) == "Taxon 1"
assert data_model.get_taxon_name_from_tid(666) is None
Expand Down
21 changes: 15 additions & 6 deletions update/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

TASKS = [
Task(
name="references",
name="ranks_names",
f=download_query_as_csv.run,
group=DownloadGroup,
params={
"query_file": "update/queries/references.rq",
"output_file": "references.csv",
"query_file": "update/queries/ranks_names.rq",
"output_file": "ranks_names.csv",
},
),
Task(
name="ranks_names",
name="references",
f=download_query_as_csv.run,
group=DownloadGroup,
params={
"query_file": "update/queries/ranks_names.rq",
"output_file": "ranks_names.csv",
"query_file": "update/queries/references.rq",
"output_file": "references.csv",
},
),
Task(
Expand All @@ -47,6 +47,15 @@
"output_file": "taxa_names.csv",
},
),
Task(
name="taxa_names_com",
f=download_query_as_csv.run,
group=DownloadGroup,
params={
"query_file": "update/queries/taxa_names_com.rq",
"output_file": "taxa_names_com.csv",
},
),
Task(
name="taxa_parents",
f=download_query_as_csv.run,
Expand Down
3 changes: 3 additions & 0 deletions update/generate_database_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def run(path: Path) -> None:
taxo_names_dict = {int(row[taxon_index]): row[name_index] for row in reader}

logging.info(" Processed taxa names")

# Eventually TODO add taxa_names_com

taxon_ranks_dict = {}

with open(path / "ranks_names.csv", "r") as f:
Expand Down
5 changes: 5 additions & 0 deletions update/queries/taxa_names_com.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

SELECT ?taxon ?taxon_name_com (LANG(?taxon_name_com) AS ?lang) WHERE {
?taxon wdt:P1843 ?taxon_name_com.
}

0 comments on commit 11d4d55

Please sign in to comment.