Two-digit word algorithm (Lesk's algorithm)
Hii .. Can anyone help me find an algorithm in Java code for finding synonyms of a search word based on context and I want to implement the algorithm with WordNet database.
For example, "I am starting a Java program." From context, I want to find synonyms for the word "running", but the synonyms should be appropriate according to the context.
a source to share
Let me illustrate a possible approach:
- Let your offer be
A B C
- Let each word have synsets, i.e.
{A:(a1, a2, a3), B:(b1), C:(c1, c2)}
- Now form the possible syntax sets:
(a1, b1, c1), (a1, b1, c2), (a2, b1, c1) ... (a3, b1, c2)
- Define a function
F(a, b, c)
that returns the distance (estimate) between (a, b, c). - Call F on every sync set.
- Choose the set with the highest score.
First, the function F can simply return the product of the reciprocal number of nodes between two nodes:
Maximize (Product [i = 0 to len (offer); j = 0 to len (offer)] (1 / D (node_i, node_j)))
Later you can increase your difficulty.
a source to share
Here is a Perl implementation of the algorithm http://senserelate.sourceforge.net/ you can use it from Java code, but it requires some setup work.
a source to share