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

not_same_if_only_first_names_match.py 898 B

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
  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 not_same_if_only_first_names_match(
  8. identities: Tuple[Identity, Identity]
  9. ) -> Optional[OneOrManyLabels]:
  10. """
  11. >>> not_same_if_only_first_names_match((Identity({"names": ["Hlib Babii"]}), Identity({"names": ["Hlib Shevchuk"]})))
  12. MatchLabel.NoMatch
  13. >>> not_same_if_only_first_names_match((Identity({}), Identity({}))) is None
  14. True
  15. """
  16. name1 = identities[0].name
  17. name2 = identities[1].name
  18. if name1 is not None and name2 is not None:
  19. if len(spl1 := name1.split(" ")) == 2 and len(spl2 := name2.split(" ")) == 2:
  20. if spl1[0] == spl2[0] and spl1[1] != spl2[1]:
  21. return MatchLabel.NoMatch
Tip!

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

Comments

Loading...