-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new-yaml-format
- Loading branch information
Showing
9 changed files
with
102 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "fingerprints" | ||
version = "1.2.3" | ||
description = "A library to generate entity fingerprints." | ||
readme = "README.md" | ||
license = { file = "LICENSE" } | ||
authors = [{ name = "OpenSanctions", email = "[email protected]" }] | ||
classifiers = [ | ||
"Intended Audience :: Developers", | ||
"Operating System :: OS Independent", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
] | ||
requires-python = ">= 3.10" | ||
dependencies = ["normality >= 2.5.0, < 3.0.0"] | ||
|
||
[project.urls] | ||
Documentation = "https://github.com/opensanctions/fingerprints/" | ||
Repository = "https://github.com/opensanctions/fingerprints.git" | ||
Issues = "https://github.com/opensanctions/fingerprints/issues" | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"bump2version", | ||
"pyyaml >= 5.0.0, < 7.0.0", | ||
"mypy", | ||
"ruff", | ||
"build", | ||
"pytest", | ||
"pytest-cov", | ||
"types-PyYAML", | ||
"coverage>=4.1", | ||
] | ||
|
||
[project.entry-points."babel.extractors"] | ||
|
||
[tool.hatch.build.targets.sdist] | ||
only-include = ["fingerprints", "LICENSE", "README.md"] | ||
|
||
[tool.distutils.bdist_wheel] | ||
universal = true | ||
|
||
[tool.coverage.run] | ||
branch = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sys | ||
import csv | ||
from collections import Counter | ||
|
||
from fingerprints.cleanup import clean_name_light | ||
from fingerprints.types import remove_types | ||
|
||
|
||
def main(file_name): | ||
counter = Counter() | ||
with open(file_name, "r") as fh: | ||
for idx, row in enumerate(csv.DictReader(fh)): | ||
if idx % 100_000 == 0: | ||
print(idx) | ||
if row["prop_type"] != "name": | ||
continue | ||
schema = row["schema"] | ||
# if schema not in ("Organization", "Company"): | ||
if schema != "Person": | ||
continue | ||
value = row["value"] | ||
clean = clean_name_light(value) | ||
if clean is None: | ||
continue | ||
# clean = remove_types(clean) | ||
# if clean is None: | ||
# continue | ||
tokens = clean.split(" ") | ||
for token in tokens: | ||
if len(token) > 2: | ||
counter[token] += 1 | ||
# print((value, clean)) | ||
|
||
# if idx > 1_000_000: | ||
# break | ||
|
||
for token, count in counter.most_common(1000): | ||
print((token, count)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1]) |