Sandipan Dey re-works a university assignment on semantic relatedness in Python:
Let’s define the semantic relatedness of two WordNet nouns x and y as follows:
- A = set of synsets in which x appears
- B = set of synsets in which y appears
- distance(x, y) = length of shortest ancestral path of subsets A and B
- sca(x, y) = a shortest common ancestor of subsets A and B
This is the notion of distance that we need to use to implement the
distance()
andsca()
methods in theWordNet
data type.
It looks like a helpful assignment for understanding natural language processing a little better.