1e0ng / simhash

A Python Implementation of Simhash Algorithm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

converting simhash strings to simhash objects

Kilsicles opened this issue · comments

thanks for your effort implementing the algorithm first of all!
When storing hashes in a database I obviously can only extract strings from it.
Is there any possibility to convert them back to Simhash type (e.g. to measure distance)?

commented

Hi, you can convert a string to an integer then build a Simhash type like this:

value = int('123')
s = Simhash(value)

If possible, I would suggest storing the unsigned big integer into the database instead of the string value for better performance.
If you are using more than 64-bit Simhash, then maybe string is the only option for most databases.

Perfect! Thanks for supporting.

I would suggest storing the unsigned big integer into the database

I changed that, good advice!