# Clustering and graphing similarities of sentence subjects

I have a bunch of sentences. Each sentence is given a weight of how "close" it is to a particular subject.

Ex. "I love reading math books" Subjects for the above sentence = [Math: 10, Reading: 14, Romance: 1, Leisure: 4]

Now I would like to create a graph of nodes, where each node is a sentence and place these nodes at the origin in a 2D plane. Each subject forms the circumference of a circle surrounding the nodes. The "closeness" of the nodes to their respective subjects is represented by their positions in the 2D plane. I figured I could do this by taking each score for a subject of a sentence and apply it as a vector. Then add all the vectors, for all the subjects, together to settle on a final position

The resulting plane could look like this

The idea here is that we can now bind each sentence node to each other with edges to create a proximity graph. Using a Gabriel graph, we can only bind the closest nodes together

The entire goal here is to construct a script from a bunch of sentences where we can flow down the script going from subject to subject without too much discontinuity.

As you can see I already have a method that seems to make sense. I was wondering however if there was already a set of methods for doing this kind of thing in data science. I was looking into spectral clustering, and similarity measure. I even looked into bioinformatics and found Needleman–Wunsch algorithm and Smith–Waterman algorithm. But I'm not knowledgable in data science or bioinformatics. Can I get some directions as to where I should be headed to solve this kind of problem. Is there already an established set of tools and methods for accomplishing it?

• Do you already have these similarity measures? I would stay away from the bioinformatics algorithms you linked. They would give very high similarity between the words math and bath, they don't know any context. In your example bath and math should probably be far apart. – Pallie Mar 7 '19 at 14:17
• No, the weights for the subjects of a node are going to be handwritten in. I don't have any data to work with, yet. The idea is to get a model first and tune it. Then collect data and use that. – Seph Mar 7 '19 at 14:21
• So maybe it would be possible to calculate an n nearest neighbours for each point and then draw this data as a graph with force directed layout? – Pallie Mar 8 '19 at 9:54