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_partially_first_and_last_names_in_email.py 2.2 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
38
39
40
41
42
43
44
45
46
47
48
49
  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_partially_first_and_last_names_in_email(
  8. identities: Tuple[Identity, Identity]
  9. ) -> Optional[OneOrManyLabels]:
  10. """
  11. >>> same_if_partially_first_and_last_names_in_email((Identity({"emails": ["hbabii@gmail.com"]}), Identity({"names": ["hlib babii"]})))
  12. MatchLabel.Match
  13. >>> same_if_partially_first_and_last_names_in_email((Identity({"names": ["hlib babii"]}), Identity({"emails": ["hbabii@gmail.com"]})))
  14. MatchLabel.Match
  15. >>> same_if_partially_first_and_last_names_in_email((Identity({"emails": ["babiih@gmail.com"]}), Identity({"names": ["hlib babii"]})))
  16. MatchLabel.Match
  17. >>> same_if_partially_first_and_last_names_in_email((Identity({"emails": ["hlibb@gmail.com"]}), Identity({"names": ["hlib babii"]})))
  18. MatchLabel.Match
  19. >>> same_if_partially_first_and_last_names_in_email((Identity({"emails": ["bhlib@gmail.com"]}), Identity({"names": ["hlib babii"]})))
  20. MatchLabel.Match
  21. >>> same_if_partially_first_and_last_names_in_email((Identity({"emails": ["hlibbabii@gmail.com"]}), Identity({"names": ["hlib babii"]})))
  22. MatchLabel.Match
  23. >>> same_if_partially_first_and_last_names_in_email((Identity({}), Identity({}))) is None
  24. True
  25. """
  26. if (email := identities[0].email) is not None and (
  27. name := identities[1].name
  28. ) is not None:
  29. pass
  30. elif (email := identities[1].email) is not None and (
  31. name := identities[0].name
  32. ) is not None:
  33. pass
  34. else:
  35. return
  36. if len(spl := name.split(" ")) >= 2:
  37. if len(first_name := spl[0]) > 2 and len(last_name := spl[-1]) > 2:
  38. if (first_name[:1] + last_name) in email:
  39. return MatchLabel.Match
  40. if (first_name + last_name[:1]) in email:
  41. return MatchLabel.Match
  42. if (last_name[:1] + first_name) in email:
  43. return MatchLabel.Match
  44. if (last_name + first_name[:1]) in email:
  45. return MatchLabel.Match
Tip!

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

Comments

Loading...