Skip to content

Commit

Permalink
add entity_types db
Browse files Browse the repository at this point in the history
  • Loading branch information
Binh Vu committed Oct 1, 2023
1 parent ab1336d commit ed1dc93
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions kgdata/wikidata/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ def db_entities_attr(attr: EntAttr, output: str, compact: bool, lang: str):
},
)
)
wikidata.add_command(
dataset2db(
"entity_types",
format={
"record_type": {"type": "tuple2", "key": None, "value": None},
"is_sorted": False,
},
)
)
wikidata.add_command(
dataset2db(
"entity_labels",
Expand Down
11 changes: 11 additions & 0 deletions kgdata/wikidata/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ def __call__(
ser_value=str.encode,
dbopts=small_dbopts,
)
get_entity_type_db: make_get_rocksdb[list[str]] = make_get_rocksdb(
deser_value=orjson.loads,
ser_value=orjson.dumps,
dbopts=small_dbopts,
)
get_entity_pagerank_db = make_get_rocksdb(
deser_value=unpack_float,
ser_value=pack_float,
Expand Down Expand Up @@ -273,6 +278,12 @@ def entity_labels(self):
self.database_dir / "entity_labels.db", read_only=self.read_only
)

@cached_property
def entity_types(self):
return get_entity_type_db(
self.database_dir / "entity_types.db", read_only=self.read_only
)

@cached_property
def classes(self):
wdclasses = get_class_db(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "kgdata"
version = "5.0.0"
version = "5.1.0"
description = "Library to process dumps of knowledge graphs (Wikipedia, DBpedia, Wikidata)"
readme = "README.md"
authors = [{ name = "Binh Vu", email = "binh@toan2.com" }]
Expand Down
1 change: 1 addition & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ wikidata_db properties
wikidata_db entities
wikidata_db entity_labels
wikidata_db entity_metadata
wikidata_db entity_types
wikidata_db entity_outlinks
wikidata_db entity_redirections
wikidata_db wp2wd
Expand Down

0 comments on commit ed1dc93

Please sign in to comment.