-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add implementation for built-in jaccard similarity #70
base: main
Are you sure you want to change the base?
Conversation
I think this is worth considering, but watch out:
I think the fact that you and the writers of duckdb had two different assumptions here shows that being implicit here can lead to mistakes. I could see users of mismo wanting either method in different situations. One option is to just not support it, and make users call What about an API of something like from typing import Literal
def jaccard(a: ir.StringValue, b: ir.StringValue, *, tokenize: Literal["by_character", "on_whitespace"]) -> ir.FloatingValue:
.... Then the user has to explicitly choose the method they want. Make it required, so no hidden default. kwarg so it is clear. I would love to workshop the names. Is there some other common method we're missing here? Of course, the user can just implement it themselves with |
[ | ||
("foo", "foo", 1), | ||
("foo bar", "foo", 0.3333), # this is currently failing | ||
("foo bar", "bar foo", 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's figure out the semantics first in the main comment thread, but eventually I will want to see
- empty case
- NULL case
- case with repeated elements in one set, eg jaccard("foo foo bar", "foo baz") -> 1/3
Thanks for spotting that @NickCrews. I hadn't considered the fact that duckdb considers each character as a separate element. From a quick search online, I've found multiple examples for both tokenizing by word and by character, so I think it makes sense to be explicit about which method to use when calculating the jaccard similarity of two strings of text. |
I've added some functionality to tokenize either by word or by character (perhaps something like |
Adds the duckdb builtin jaccard similarity which currently does not always result in the same value as
mismo.sets.jaccard