Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

same_if_first_and_last_names_in_email.py 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. from typing import Optional, Tuple
  2. from bohrapi.artifacts.identity import Identity
  3. from bohrapi.core import Heuristic
  4. from bohrlabels.core import OneOrManyLabels
  5. from bohrlabels.labels import MatchLabel
  6. @Heuristic(Identity, Identity)
  7. def same_if_first_and_last_names_in_email(
  8. identities: Tuple[Identity, Identity]
  9. ) -> Optional[OneOrManyLabels]:
  10. """
  11. >>> same_if_first_and_last_names_in_email((Identity({"emails": ["hlibbabii@gmail.com"]}), Identity({"names": ["hlib babii"]})))
  12. MatchLabel.Match
  13. >>> same_if_first_and_last_names_in_email((Identity({"names": ["hlib babii"]}), Identity({"emails": ["hlibbabii@gmail.com"]})))
  14. MatchLabel.Match
  15. >>> same_if_first_and_last_names_in_email((Identity({"emails": ["hbabii@gmail.com"]}), Identity({"names": ["hlib babii"]}))) is None
  16. True
  17. >>> same_if_first_and_last_names_in_email((Identity({}), Identity({}))) is None
  18. True
  19. """
  20. if (email := identities[0].email) is not None and (
  21. name := identities[1].name
  22. ) is not None:
  23. pass
  24. elif (email := identities[1].email) is not None and (
  25. name := identities[0].name
  26. ) is not None:
  27. pass
  28. else:
  29. return
  30. if len(spl := name.split(" ")) >= 2:
  31. if len(first_name := spl[0]) > 1 and len(last_name := spl[-1]) > 1:
  32. if first_name in email and last_name in email:
  33. return MatchLabel.Match
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...