metaspn-entities 0.1.7__py3-none-any.whl → 0.1.8__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.
@@ -1,6 +1,7 @@
1
1
  from .adapter import SignalResolutionResult, resolve_normalized_social_signal
2
2
  from .attribution import OutcomeAttribution
3
3
  from .context import RecommendationContext, EntityContext, build_confidence_summary, build_recommendation_context
4
+ from .demo import resolve_demo_social_identity
4
5
  from .events import EmittedEvent
5
6
  from .models import EntityResolution
6
7
  from .resolver import EntityResolver
@@ -10,6 +11,7 @@ __all__ = [
10
11
  "resolve_normalized_social_signal",
11
12
  "SignalResolutionResult",
12
13
  "OutcomeAttribution",
14
+ "resolve_demo_social_identity",
13
15
  "EntityContext",
14
16
  "RecommendationContext",
15
17
  "build_confidence_summary",
@@ -0,0 +1,81 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Dict, Mapping
4
+
5
+ from .models import EntityType
6
+ from .resolver import EntityResolver
7
+
8
+
9
+ def resolve_demo_social_identity(
10
+ resolver: EntityResolver,
11
+ social_payload: Mapping[str, Any],
12
+ *,
13
+ caused_by: str = "demo-pipeline",
14
+ ) -> Dict[str, Any]:
15
+ platform = str(social_payload.get("platform") or "").strip().lower()
16
+ source = str(social_payload.get("source") or social_payload.get("provenance") or "demo")
17
+
18
+ handle = social_payload.get("author_handle") or social_payload.get("handle")
19
+ if not isinstance(handle, str) or not handle.strip():
20
+ raise ValueError("demo payload requires author_handle or handle")
21
+ handle = handle.strip()
22
+
23
+ handle_type = f"{platform}_handle" if platform else "handle"
24
+ resolution = resolver.resolve(
25
+ handle_type,
26
+ handle,
27
+ context={
28
+ "entity_type": EntityType.PERSON,
29
+ "caused_by": caused_by,
30
+ "provenance": source,
31
+ "confidence": 0.93,
32
+ },
33
+ )
34
+
35
+ for key in ("profile_url", "author_url", "canonical_url"):
36
+ url = social_payload.get(key)
37
+ if isinstance(url, str) and url.strip():
38
+ resolver.add_alias(
39
+ resolution.entity_id,
40
+ "canonical_url",
41
+ url.strip(),
42
+ confidence=0.96,
43
+ caused_by=caused_by,
44
+ provenance=source,
45
+ )
46
+ break
47
+
48
+ email = social_payload.get("email")
49
+ if isinstance(email, str) and email.strip():
50
+ resolver.add_alias(
51
+ resolution.entity_id,
52
+ "email",
53
+ email.strip(),
54
+ confidence=0.98,
55
+ caused_by=caused_by,
56
+ provenance=source,
57
+ )
58
+
59
+ canonical_id = resolver.store.canonical_entity_id(resolution.entity_id)
60
+ context = resolver.entity_context(canonical_id)
61
+ digest_payload = {
62
+ "entity_id": canonical_id,
63
+ "confidence": context.confidence_summary["overall_confidence"],
64
+ "matched_identifiers": [
65
+ {
66
+ "identifier_type": item["identifier_type"],
67
+ "value": item["value"],
68
+ "confidence": item["confidence"],
69
+ "last_seen_at": item["last_seen_at"],
70
+ }
71
+ for item in context.identifiers
72
+ ],
73
+ "why": {
74
+ "matched_identifier_count": len(context.identifiers),
75
+ "alias_count": len(context.aliases),
76
+ "confidence_summary": context.confidence_summary,
77
+ "relationship_stage_hint": resolver.recommendation_context(canonical_id).relationship_stage_hint,
78
+ },
79
+ "events": [event.payload for event in resolver.drain_events()],
80
+ }
81
+ return digest_payload
@@ -7,7 +7,17 @@ def normalize_identifier(identifier_type: str, value: str) -> str:
7
7
  identifier_type = identifier_type.strip().lower()
8
8
  value = value.strip()
9
9
 
10
- if identifier_type in {"twitter_handle", "github_handle", "handle"}:
10
+ if identifier_type in {
11
+ "twitter_handle",
12
+ "x_handle",
13
+ "linkedin_handle",
14
+ "github_handle",
15
+ "instagram_handle",
16
+ "tiktok_handle",
17
+ "bluesky_handle",
18
+ "youtube_handle",
19
+ "handle",
20
+ }:
11
21
  return value.lstrip("@").lower()
12
22
 
13
23
  if identifier_type == "email":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metaspn-entities
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Canonical entity resolution, aliasing, and merges for MetaSPN systems
5
5
  Author: MetaSPN Contributors
6
6
  License-Expression: MIT
@@ -135,3 +135,16 @@ Attribution guarantees:
135
135
  - canonical merge redirects are resolved before returning `entity_id`
136
136
  - output includes explicit confidence for downstream learning logic
137
137
  - deterministic tie-breaks are applied by score, then hit count, then entity ID
138
+
139
+ ## Demo Pipeline Invocation
140
+
141
+ For demo digest identity resolution (without direct DB queries in renderer), use:
142
+
143
+ - `resolve_demo_social_identity(resolver, social_payload)`
144
+
145
+ Returned payload includes:
146
+ - `entity_id`
147
+ - `confidence`
148
+ - `matched_identifiers`
149
+ - `why` metadata (confidence summary, counts, relationship hint)
150
+ - emitted event payloads for auditability
@@ -1,14 +1,15 @@
1
- metaspn_entities/__init__.py,sha256=LCrhnRQHweDRNX9BOj6FV34uzLRbT7whU6TleZlZiHU,709
1
+ metaspn_entities/__init__.py,sha256=mkKm_bGmH4PogzvMUR_BJDuuOSFBkz-VvWzs1Bie06Y,792
2
2
  metaspn_entities/adapter.py,sha256=eNB5kr1tinav85WPA4YCldRDJBgb6uYe3ZWCRVjdOms,4654
3
3
  metaspn_entities/attribution.py,sha256=bCJGAW5XAzI9ZOWVTvw_bWfUVXbEAATFJ3N9W4_C2U8,3061
4
4
  metaspn_entities/context.py,sha256=sUpW50Z99R0iQ5ryVR9uk7WqUaiKCxMyTQlvuV3DvVk,6054
5
+ metaspn_entities/demo.py,sha256=QJyIRuds0AoOwGBo0a93f62742848v4XogSV99LQjL0,2764
5
6
  metaspn_entities/events.py,sha256=Hkc3gy5_vRTSR0MKUvF24dTqNqOkG423_PTUe7csUfw,2066
6
7
  metaspn_entities/models.py,sha256=b2EFsc1EIT9Ao_bKA2I52-5W_0fTwhsyO6VFRG8gZg8,1377
7
- metaspn_entities/normalize.py,sha256=nPAHRfipgS6zHy2x70ZFd5HB1W4FKmeTF8Kd4TYz5tI,1125
8
+ metaspn_entities/normalize.py,sha256=o05fEXXoDWAGH1RNEH_zcfhRxR6CpAEBralbTlsK5ng,1308
8
9
  metaspn_entities/resolver.py,sha256=bKnxInPNLefdgblrrl1oAtc2aiUlXqZz3bmSZWNX21E,9910
9
10
  metaspn_entities/sqlite_backend.py,sha256=h7_dMNmd9-k9hxvJwZp_TM9_yNWyFbJric6TvH_BseU,12087
10
- metaspn_entities-0.1.7.dist-info/licenses/LICENSE,sha256=tvVpto97dUnh1-KVYPs1rCr5dzyX8jUyNmT7F7ZPVAM,1077
11
- metaspn_entities-0.1.7.dist-info/METADATA,sha256=MRfkGTOysqJ99tSf5gdSgirOPhTXDtExezGWlPDQ3WQ,4635
12
- metaspn_entities-0.1.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
- metaspn_entities-0.1.7.dist-info/top_level.txt,sha256=YP2V8Z1Statrs3YAI-tGvyC73vLjPHr9Vkal4yqXkhs,17
14
- metaspn_entities-0.1.7.dist-info/RECORD,,
11
+ metaspn_entities-0.1.8.dist-info/licenses/LICENSE,sha256=tvVpto97dUnh1-KVYPs1rCr5dzyX8jUyNmT7F7ZPVAM,1077
12
+ metaspn_entities-0.1.8.dist-info/METADATA,sha256=AD2i7hlPWzTu0DeoWO1zbaHS2zIknbc8x_qeolStghM,4995
13
+ metaspn_entities-0.1.8.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
14
+ metaspn_entities-0.1.8.dist-info/top_level.txt,sha256=YP2V8Z1Statrs3YAI-tGvyC73vLjPHr9Vkal4yqXkhs,17
15
+ metaspn_entities-0.1.8.dist-info/RECORD,,