followthemoney 4.3.0__py3-none-any.whl → 4.3.1__py3-none-any.whl

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.

Potentially problematic release.


This version of followthemoney might be problematic. Click here for more details.

@@ -9,7 +9,7 @@ from followthemoney.statement import Statement, StatementEntity, SE
9
9
  from followthemoney.dataset import Dataset, DefaultDataset, DS
10
10
  from followthemoney.util import set_model_locale
11
11
 
12
- __version__ = "4.3.0"
12
+ __version__ = "4.3.1"
13
13
 
14
14
  # Data model singleton
15
15
  model = Model.instance()
followthemoney/compare.py CHANGED
@@ -71,12 +71,31 @@ def _compare(scores: Scores, weights: Weights, n_std: int = 1) -> float:
71
71
  return 1.0 / (1.0 + math.exp(-prob))
72
72
 
73
73
 
74
+ def entity_is_same(left: EntityProxy, right: EntityProxy) -> bool:
75
+ """Check if two entities are the same apart from their ID."""
76
+ if left.schema != right.schema:
77
+ return False
78
+
79
+ props = set(left.properties.keys()).union(right.properties.keys())
80
+ if 0 == len(props):
81
+ return False
82
+
83
+ for prop in props:
84
+ left_vals = sorted(left.get(prop))
85
+ right_vals = sorted(right.get(prop))
86
+ if left_vals != right_vals:
87
+ return False
88
+ return True
89
+
90
+
74
91
  def compare(
75
92
  left: EntityProxy,
76
93
  right: EntityProxy,
77
94
  weights: Weights = COMPARE_WEIGHTS,
78
95
  ) -> float:
79
96
  """Compare two entities and return a match score."""
97
+ if entity_is_same(left, right):
98
+ return 1.0
80
99
  scores = compare_scores(left, right)
81
100
  return _compare(scores, weights)
82
101
 
@@ -1,5 +1,6 @@
1
1
  import re
2
2
  from banal import is_mapping, as_bool
3
+ from rigour.ids import get_identifier_format
3
4
  from typing import TYPE_CHECKING, Any, List, Optional, TypedDict
4
5
 
5
6
  from followthemoney.exc import InvalidModel
@@ -157,6 +158,11 @@ class Property:
157
158
  raise InvalidModel("Invalid reverse: %s" % self)
158
159
  self.reverse = self.range._add_reverse(model, self._reverse, self)
159
160
 
161
+ if self.type == registry.identifier and self.format is not None:
162
+ format_ = get_identifier_format(self.format)
163
+ if format_ is None or format_.NAME != self.format:
164
+ raise InvalidModel("Invalid identifier format: %s" % self.format)
165
+
160
166
  @property
161
167
  def label(self) -> str:
162
168
  """User-facing title for this property."""
followthemoney/proxy.py CHANGED
@@ -462,7 +462,7 @@ class EntityProxy(object):
462
462
  return self._size
463
463
 
464
464
  def __hash__(self) -> int:
465
- if not self.id:
465
+ if self.id is None:
466
466
  raise RuntimeError("Cannot hash entity without an ID")
467
467
  return hash(self.id)
468
468
 
@@ -55,7 +55,7 @@ Thing:
55
55
  wikidataId:
56
56
  label: Wikidata ID
57
57
  type: identifier
58
- format: qid
58
+ format: wikidata
59
59
  maxLength: 32
60
60
  keywords:
61
61
  label: Keywords
@@ -1,6 +1,6 @@
1
1
  import re
2
2
  from typing import Optional, TYPE_CHECKING
3
- from rigour.ids import get_identifier_format_names, get_identifier_format
3
+ from rigour.ids import get_identifier_format
4
4
 
5
5
  from followthemoney.types.common import PropertyType
6
6
  from followthemoney.util import dampen, shortest, longest
@@ -35,8 +35,8 @@ class IdentifierType(PropertyType):
35
35
  format: Optional[str] = None,
36
36
  proxy: Optional["EntityProxy"] = None,
37
37
  ) -> Optional[str]:
38
- if format in get_identifier_format_names():
39
- format_ = get_identifier_format(format)
38
+ format_ = get_identifier_format(format)
39
+ if format_ is not None:
40
40
  return format_.normalize(text)
41
41
  return text
42
42
 
@@ -61,7 +61,7 @@ class IdentifierType(PropertyType):
61
61
  return f"id:{value}"
62
62
 
63
63
  def caption(self, value: str, format: Optional[str] = None) -> str:
64
- if format in get_identifier_format_names():
65
- format_ = get_identifier_format(format)
64
+ format_ = get_identifier_format(format)
65
+ if format_ is not None:
66
66
  return format_.format(value)
67
67
  return value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: followthemoney
3
- Version: 4.3.0
3
+ Version: 4.3.1
4
4
  Summary: A data model for anti corruption data modeling and analysis.
5
5
  Project-URL: Documentation, https://followthemoney.tech/
6
6
  Project-URL: Repository, https://github.com/opensanctions/followthemoney.git
@@ -50,7 +50,7 @@ Requires-Dist: pytz>=2021.1
50
50
  Requires-Dist: pyyaml<7.0.0,>=5.0.0
51
51
  Requires-Dist: rdflib<7.3.0,>=6.2.0
52
52
  Requires-Dist: requests<3.0.0,>=2.21.0
53
- Requires-Dist: rigour<2.0.0,>=1.3.13
53
+ Requires-Dist: rigour<2.0.0,>=1.4.0
54
54
  Requires-Dist: sqlalchemy[mypy]<3.0.0,>=2.0.0
55
55
  Provides-Extra: dev
56
56
  Requires-Dist: build; extra == 'dev'
@@ -1,5 +1,5 @@
1
- followthemoney/__init__.py,sha256=SGtXmqy22FtLMX0kcGDSUMbWNGUvoA13F5SUobauMg8,856
2
- followthemoney/compare.py,sha256=bZlnj2VMoe67q4Lyq_VwS1a-EJnEK1kC8prbs8jyL9E,5774
1
+ followthemoney/__init__.py,sha256=9UJzMQUcqjQ4kWQIDMF1GB0ji8ph-GQlXa3e_X2uuX4,856
2
+ followthemoney/compare.py,sha256=frgumsDv4Ru9UkNof62jDjKCxxpCgV1Rusfu8s20uGA,6327
3
3
  followthemoney/entity.py,sha256=bBiX7hNquXemS3vYCUHKtWI_IqX43Z6i8RQDbZ7gXsg,3449
4
4
  followthemoney/exc.py,sha256=GyMgwY4QVm87hLevDfV7gM1MJsDqfNCi_UQw7F_A8X8,858
5
5
  followthemoney/graph.py,sha256=7X1CGHGvmktS2LSZqld2iXWzG7B831eCNYyBqamqEJ8,10921
@@ -9,8 +9,8 @@ followthemoney/model.py,sha256=bWFVNa-DhYzc8BdSXBZdG2ev6Nh9uHx6i4tin8DvEEU,7374
9
9
  followthemoney/names.py,sha256=LODQqExKEHdH4z6Mmbhlm0KeKRzGcptaSWzYXZ7lONI,1120
10
10
  followthemoney/namespace.py,sha256=utggu9IGA8bhgEYom3OUB1KxkAJR_TrMNbY5MUF_db8,4536
11
11
  followthemoney/ontology.py,sha256=WWY_PYQGl5Ket4zZBuZglzQxD2Bh9UqHok6GJNNX7GA,3001
12
- followthemoney/property.py,sha256=9qZ_o2iA-1llLMJ3O2hsW7c2XhkFU1YbvVqretGYUSA,7913
13
- followthemoney/proxy.py,sha256=5pMyP0JWWuBcvMIu3AXlW6Za7EEWWdFD2EZkD8UkbQw,19703
12
+ followthemoney/property.py,sha256=6FoKoUloDoQVM4XMnjjolKArlV4yBq9KOYxv8Os8WGQ,8234
13
+ followthemoney/proxy.py,sha256=nahd9lLZzum_-QEchqydinDa1Zg5_Ffl0fyo35BNncQ,19707
14
14
  followthemoney/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  followthemoney/schema.py,sha256=WYnPE4Lego0pJHlojECEv0aO9Miw_YIvEb35HoDo4Zk,18087
16
16
  followthemoney/util.py,sha256=LoCSp1iE6VwXjotCkBXFRppeQs55726GzOuNIu3CvRE,4409
@@ -104,7 +104,7 @@ followthemoney/schema/Similar.yaml,sha256=gD8rZEaPQWzU-rEfsKdn62uEucF3KxYBcPMoSd
104
104
  followthemoney/schema/Succession.yaml,sha256=RMJQqZ4Fv88N1RvWTAgjYg9BB5cELSj5CCAjM681Fpg,749
105
105
  followthemoney/schema/Table.yaml,sha256=GcsIAgSO9t2tvObA9zU2HhxlSqTe9CePmUnagu1Z0vI,641
106
106
  followthemoney/schema/TaxRoll.yaml,sha256=ugMzaaS7uyq2OLD50eGLcfvd6Cg0cSt65-T9GVqpRSA,746
107
- followthemoney/schema/Thing.yaml,sha256=hh1oMDQzWiSs1TamBNonmwEdlh2TVrNc3w9hWW8iSeY,2716
107
+ followthemoney/schema/Thing.yaml,sha256=xqGtSzyfE_EWx5PrxETKftF-9NSlsTYIbXrNqhdx9jw,2721
108
108
  followthemoney/schema/Trip.yaml,sha256=nLQD_ApmVJ8D56Czl7K700hhNZjzFV9FOQ3NBSQDLiM,771
109
109
  followthemoney/schema/UnknownLink.yaml,sha256=lneS_HZNgeLyJxwzWnLx0ZoyY3MXt99I_K2X_o9z5g8,682
110
110
  followthemoney/schema/UserAccount.yaml,sha256=2bbPKNtt1R3zWSSkaq_SVzRPfFzX74kAxwtIxTymHA8,840
@@ -150,7 +150,7 @@ followthemoney/types/date.py,sha256=PjcaEyW6CBzf0-gHWKUsKjWIaD3AVBEl0zLSRQOVXxc,
150
150
  followthemoney/types/email.py,sha256=L3RTYrMABlNQF7hCynXGfzoj6YNEHW5JAY_BwuhoZdA,3375
151
151
  followthemoney/types/entity.py,sha256=oDxVEhuxyU1ScpOpebPpUm3o0I9j_p7Qrq-t5yNpluQ,2338
152
152
  followthemoney/types/gender.py,sha256=fi9iKLbjAUxDCLBtU1MxWidxv7KgCY2eH5746FYlEGk,1725
153
- followthemoney/types/identifier.py,sha256=hzD188FtwG0w3TcmbnDwnUMc8MZVcWgQJKGAvrwygc4,2296
153
+ followthemoney/types/identifier.py,sha256=7YET9mdYAktMup_kTvnxLu9SJzEU7ZJgN3KImzjfT-Y,2219
154
154
  followthemoney/types/ip.py,sha256=mMFTODFiXAJROCUYJvoLAShyIiTIWVmMBh5zT_GquYM,1300
155
155
  followthemoney/types/json.py,sha256=V3qJD5RxJykNX51u3w1Nx9xqoNBnkulhzkJI9XMYKFo,1690
156
156
  followthemoney/types/language.py,sha256=SXgRRH-DyPmyyrqYurSyMiG6WHB8a0Gw81XxroEGD-c,2747
@@ -161,8 +161,8 @@ followthemoney/types/phone.py,sha256=r8uRqWinS0CYnYBTs405k5gO4jeatUDgjdzzijoMKJE
161
161
  followthemoney/types/string.py,sha256=fqyTauAm4mNnNaoH-yH087RBbNh-G5ZZUO3awTGQUUg,1230
162
162
  followthemoney/types/topic.py,sha256=Mi0Gx0m3bDeTmyuvM6jdRMqv81O03U4eI99R13KGu2Y,4503
163
163
  followthemoney/types/url.py,sha256=QFpS_JIV8unFHuh_uGv22SWUUkocBoOpzLsAJWom_gI,1455
164
- followthemoney-4.3.0.dist-info/METADATA,sha256=dyrwBXiefNsSpmwOcsP-TsEnJBqmn9DY9vJsMhFVwk0,6748
165
- followthemoney-4.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
166
- followthemoney-4.3.0.dist-info/entry_points.txt,sha256=caoFTlf213jhg5sz3TNSofutjUTzaKtWATuSIdd9Cps,653
167
- followthemoney-4.3.0.dist-info/licenses/LICENSE,sha256=H6_EVXisnJC0-18CjXIaqrBSFq_VH3OnS7u3dccOv6g,1148
168
- followthemoney-4.3.0.dist-info/RECORD,,
164
+ followthemoney-4.3.1.dist-info/METADATA,sha256=i41B2NtbZrqWsc0F26XIP9GCvbRtMZ1ZsWeRWvk4AAg,6747
165
+ followthemoney-4.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
166
+ followthemoney-4.3.1.dist-info/entry_points.txt,sha256=caoFTlf213jhg5sz3TNSofutjUTzaKtWATuSIdd9Cps,653
167
+ followthemoney-4.3.1.dist-info/licenses/LICENSE,sha256=H6_EVXisnJC0-18CjXIaqrBSFq_VH3OnS7u3dccOv6g,1148
168
+ followthemoney-4.3.1.dist-info/RECORD,,