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_same_names.py 710 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
  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_same_names(
  8. identities: Tuple[Identity, Identity]
  9. ) -> Optional[OneOrManyLabels]:
  10. """
  11. >>> same_if_same_names((Identity({"names": ["Hlib Babii"]}), Identity({"names": ["Hlib Babii"]})))
  12. MatchLabel.Match
  13. >>> same_if_same_names((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 and name1 == name2:
  19. return MatchLabel.Match
Tip!

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

Comments

Loading...