pyannotators-entityfishing 1.6.134__tar.gz → 1.6.136__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/PKG-INFO +1 -1
  2. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/src/pyannotators_entityfishing/__init__.py +1 -1
  3. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/build_poi_lexicons.py +26 -0
  4. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/.claude/skills/ef-mapping/SKILL.md +0 -0
  5. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/.gitignore +0 -0
  6. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/.gitmodules +0 -0
  7. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/.python-version +0 -0
  8. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/LICENSE +0 -0
  9. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/README.md +0 -0
  10. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/Taskfile.yml +0 -0
  11. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/pyproject.toml +0 -0
  12. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/src/pyannotators_entityfishing/candidates.py +0 -0
  13. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/src/pyannotators_entityfishing/ef_client.py +0 -0
  14. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/src/pyannotators_entityfishing/entityfishing.py +0 -0
  15. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/.claude-plugin/marketplace.json +0 -0
  16. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/.claude-plugin/plugin.json +0 -0
  17. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/HOWTO.md +0 -0
  18. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/README.md +0 -0
  19. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/resources/Stages.yml +0 -0
  20. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/resources/Taskfile.yml +0 -0
  21. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/resources/help/help_examples.py +0 -0
  22. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/resources/help/plugin-help.py +0 -0
  23. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/resources/help/template.en.md +0 -0
  24. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/resources/help/template.fr.md +0 -0
  25. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/SKILL.md +0 -0
  26. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/references/annotator.md +0 -0
  27. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/references/converter.md +0 -0
  28. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/references/formatter.md +0 -0
  29. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/references/importer.md +0 -0
  30. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/references/processor.md +0 -0
  31. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/references/segmenter.md +0 -0
  32. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/new-plugin/references/types.md +0 -0
  33. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/skills/plugin-help/SKILL.md +0 -0
  34. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/tools/check-marketplace.py +0 -0
  35. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/submodules/python-archetype/vars/pythonPipeline.groovy +0 -0
  36. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/build_poi.py +0 -0
  37. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/build_rerank_data.py +0 -0
  38. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/check_rerank_endpoint.py +0 -0
  39. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/el_jev.py +0 -0
  40. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/eval_linking.py +0 -0
  41. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/eval_mappings.py +0 -0
  42. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/eval_rerank.py +0 -0
  43. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/finetune_rerank.py +0 -0
  44. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/merge_rerank.py +0 -0
  45. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/poi_common_words.json +0 -0
  46. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/recalibrate_linking.py +0 -0
  47. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/review_linking.html +0 -0
  48. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/review_linking.py +0 -0
  49. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/sherpa_plan_project.py +0 -0
  50. {pyannotators_entityfishing-1.6.134 → pyannotators_entityfishing-1.6.136}/tools/wdfilter.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pyannotators-entityfishing
3
- Version: 1.6.134
3
+ Version: 1.6.136
4
4
  Summary: Annotator based on entity-fishing
5
5
  Project-URL: Homepage, https://github.com/oterrier/pyannotators_entityfishing/
6
6
  Author-email: Olivier Terrier <olivier.terrier@kairntech.com>
@@ -1,3 +1,3 @@
1
1
  """Annotator based on entity-fishing"""
2
2
 
3
- __version__ = "1.6.134"
3
+ __version__ = "1.6.136"
@@ -35,6 +35,10 @@ tools/poi_common_words.json overrides the rule, per language: the forms to keep
35
35
  --clean-only applies it to the OUTDIR/poi_<lang>.json already written, without Wikidata
36
36
  (the sitelink counts come from OUTDIR/_entities.jsonl).
37
37
 
38
+ Both modes end by writing OUTDIR/poi_cities.json from the six lexicons: QID -> cityId, countryId and cityName, the
39
+ city name per language. The REM formatter (pyformatters_json_rem) embeds a copy, to give its city to a
40
+ POI the gazetteer did not match but entity-fishing linked: "Portimão" for its racing circuit.
41
+
38
42
  Step 1 lists the items with SPARQL (OUTDIR/_items.json); step 2 fetches them with
39
43
  wbgetentities (OUTDIR/_entities.jsonl). Both are kept, so a rerun resumes; a rerun with a
40
44
  lower --min-sitelinks needs _items.json deleted.
@@ -239,6 +243,26 @@ def clean(path: Path, lang: str, dictionaries: Path, famous: set[str], generic:
239
243
  print(f"{path}: {len(lexicon)} concepts, {entries} named by a common word and {forms} aliases (common words, codes) dropped", file=sys.stderr)
240
244
 
241
245
 
246
+ def city_table(lexicons: dict[str, list[dict]]) -> dict[str, dict]:
247
+ """QID -> GeoNames IDs of the city and the country, and the city name per language, of every POI of the lexicons."""
248
+ table: dict[str, dict] = {}
249
+ for lang, lexicon in lexicons.items():
250
+ for e in lexicon:
251
+ props = e["properties"]
252
+ poi = table.setdefault(e["identifier"], {})
253
+ poi.update({k: props[k] for k in ("cityId", "countryId") if props.get(k)})
254
+ if props.get("cityName"):
255
+ poi.setdefault("cityName", {})[lang] = props["cityName"]
256
+ return dict(sorted(table.items(), key=lambda item: int(item[0][1:])))
257
+
258
+
259
+ def write_city_table(outdir: Path) -> None:
260
+ table = city_table({lang: json.loads((outdir / f"poi_{lang}.json").read_text()) for lang in LANGS})
261
+ path = outdir / "poi_cities.json"
262
+ path.write_text(json.dumps(table, ensure_ascii=False, separators=(",", ":")) + "\n")
263
+ print(f"{path}: {len(table)} POI, {sum('cityId' in p for p in table.values())} with a city", file=sys.stderr)
264
+
265
+
242
266
  def main() -> None:
243
267
  parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
244
268
  parser.add_argument("outdir", type=Path)
@@ -260,6 +284,7 @@ def main() -> None:
260
284
  famous = {e["id"] for e in map(json.loads, cache.open()) if len(e.get("sitelinks", {})) >= args.keep_sitelinks}
261
285
  for lang in LANGS:
262
286
  clean(args.outdir / f"poi_{lang}.json", lang, args.dictionaries, famous, generic)
287
+ write_city_table(args.outdir)
263
288
  return
264
289
  args.outdir.mkdir(parents=True, exist_ok=True)
265
290
  classes, orgs = mapping_lists()
@@ -337,6 +362,7 @@ def main() -> None:
337
362
  print(f"{path}: {len(lexicon)} concepts, {dropped} named after a city dropped", file=sys.stderr)
338
363
  if args.dictionaries:
339
364
  clean(path, lang, args.dictionaries, famous, generic)
365
+ write_city_table(args.outdir)
340
366
 
341
367
 
342
368
  if __name__ == "__main__":