Skip to content

Established way of getting duplicate ids? #63

@AltamashRafiq

Description

@AltamashRafiq

Hi! First of all, thank you for the amazing set of packages! My team and I are big fans of your work 😄

I am wondering if there is an established way to get duplicate ids. Lets take the code below:

from semhash import SemHash

data = [
    {"id": 0, "text": "hello"},
    {"id": 1, "text": "hello"},
    {"id": 2, "text": "helllo"},
]

semhash = SemHash.from_records(records=data, columns=['text'])
deduplicator = semhash.self_deduplicate(threshold=0.0000001)

This gives for deduplicator.selected:

[{'id': 0, 'text': 'hello'}]

And for deduplicator.filtered:

[DuplicateRecord(record={'id': 1, 'text': 'hello'}, exact=True, duplicates=[({'id': 0, 'text': 'hello'}, 1.0)]),
 DuplicateRecord(record={'id': 2, 'text': 'helllo'}, exact=False, duplicates=[({'id': 0, 'text': 'hello'}, 0.5699238181114197), ({'id': 1, 'text': 'hello'}, 0.5699238181114197)])]

It is nice to get the duplicate records from the filtered attribute but it would also be great to have the reverse of this. I.e. for each record in deduplicator.selected, it would be nice to have a list of the duplicates. To my knowledge, the way to get this using the current implementation is to loop over the filtered for each item in selected. Would there be an easier / already established way of doing this?

It would be cool if we could (hypothetically) get for deduplicator.selected:

[DeDuplicatedRecord(record={'id': 0, 'text': 'hello'}, duplicates=[<duplicates_here>])]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions