Skip to content

Commit

Permalink
make id generator consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
longbinlai committed Jan 20, 2025
1 parent 0665ee2 commit 4f4a35c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions python/graphy/utils/cryptography.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


def id_generator(value: str, length: int = 16) -> str:
value = value.lower()
return hashlib.sha256(value.encode()).hexdigest()[:length]


Expand Down
2 changes: 1 addition & 1 deletion python/graphy/utils/data_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def extract_data(self, dimension_node_names=[]):
if not paper_data.get("id", ""):
# this is a bug of inconsistent data
if "title" in paper_data:
paper_data["id"] = id_generator(paper_data["title"].lower())
paper_data["id"] = id_generator(paper_data["title"])
else:
continue
# some hacking messy stuff
Expand Down
2 changes: 1 addition & 1 deletion python/graphy/utils/paper_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def parse_dict(meta: dict):

paper_id = parsed_meta.get("id", "")
if paper_id == "":
parsed_meta["id"] = id_generator(parsed_meta.get("title", "").lower())
parsed_meta["id"] = id_generator(parsed_meta.get("title", ""))

if not parsed_meta.get("published", ""):
try:
Expand Down

0 comments on commit 4f4a35c

Please sign in to comment.