Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm looking for an algorithm or function that can take a text string and convert it a number

I looking for a algorithm, function or technique that can take a string and convert it to a number. I would like the algorithm or function to have the following properties:

  1. Identical string yields the same calculated value
  2. Similar strings would yield similar values (similar can be defined as similar in meaning or similar in composition)

  3. Capable of handling strings of variable length

I read an article several years ago that gives me hope that this can be achieved. Unfortunately, I have been unable to recall the source of the article.

like image 690
Mutuelinvestor Avatar asked Nov 24 '25 02:11

Mutuelinvestor


1 Answers

Similar in composition is pretty easy, I'll let somebody else tackle that.

Similar in meaning is a lot harder, but fun :), I remember reading an article about how a neural network was trained to construct a 2D "semantic meaning graph" of a whole bunch of english words, where the distance between two words represented how "similar" they are in meaning, just by training it on wikipedia articles.

You could do the same thing, but make it one-dimensional, that will give you a single continuous number, where similar words will be close to each other.

like image 112
Jonathon Ashworth Avatar answered Nov 25 '25 17:11

Jonathon Ashworth