Alignment API and Server 3.6

fr.inrialpes.exmo.align.ling
Class JWNLDistances

java.lang.Object
  extended by fr.inrialpes.exmo.align.ling.JWNLDistances

public class JWNLDistances
extends Object

Compute a string distance using the JWNL API (WordNet API)

Version:
$Id: JWNLDistances.java 947 2009-02-28 21:33:40Z euzenat $
Author:
Jerome Pierson, David Loup, Petko Valtchev, Jerome Euzenat

Field Summary
static double ADJ_WEIGHT
           
private  Hashtable adjectives1
           
private  Hashtable adjectives2
           
(package private)  double[][] adjectivesMasks
           
(package private)  double[][] adjectivesResults
           
private static double MINIMUM_DISTANCE
           
static double NOUN_WEIGHT
           
private  Hashtable nouns1
           
private  Hashtable nouns2
           
(package private)  double[][] nounsMasks
           
(package private)  double[][] nounsResults
           
static double VERB_WEIGHT
           
private  Hashtable verbs1
           
private  Hashtable verbs2
           
(package private)  double[][] verbsMasks
           
(package private)  double[][] verbsResults
           
 
Constructor Summary
JWNLDistances()
           
 
Method Summary
 double basicGlossOverlap(String s1, String s2)
          NOT FINISHED Compute the overlap between all glosses of two strings
 double basicSynonymDistance(String s1, String s2)
          Compute a basic distance between 2 strings using WordNet synonym.
 double basicSynonymySimilarity(String s1, String s2)
          Evaluate if two terms can be synonym
private  double bestMatch(double[][] matrix)
           
 double compareComponentNames(String s1, String s2)
           
 double computeSimilarity(String s1, String s2)
           
 double computeTokenSimilarity(net.didion.jwnl.data.IndexWord index1, net.didion.jwnl.data.IndexWord index2)
           
 double cosynonymySimilarity(String s1, String s2)
          Compute the proportion of common synset between two words
 void display(net.didion.jwnl.data.Synset syn)
           
 void displayMatrix(double[][] matrix)
           
 void fillWithOnes(double[][] matrix)
           
 double findMatchForAdj(net.didion.jwnl.data.IndexWord index1, net.didion.jwnl.data.IndexWord index2)
           
 double[][] getAdjectivesResults()
           
(package private)  Set<net.didion.jwnl.data.Synset> getAllSenses(String term)
          Retrieve all WordNet sense of a term
 int getCommonConcepts(net.didion.jwnl.data.list.PointerTargetNodeList list1, net.didion.jwnl.data.list.PointerTargetNodeList list2)
           
 double[][] getNounsResults()
           
 int getNumberOfOccurences(String token, Hashtable nouns, Hashtable adj, Hashtable verbs)
           
 int getNumberOfOccurences(String token, int n)
           
 double[][] getVerbsResults()
           
 void Initialize()
          Initialize the JWNL API.
 void Initialize(String wordnetdir, String wordnetversion)
           
 void lookUpWord(String word, Hashtable<String,net.didion.jwnl.data.IndexWord> nouns, Hashtable<String,net.didion.jwnl.data.IndexWord> adjectives, Hashtable<String,net.didion.jwnl.data.IndexWord> verbs)
           
 double wuPalmerSimilarity(String s1, String s2)
          Compute the Wu-Palmer similarity defined by score = 2*depth(lcs(s1,s2)) / (depth(s1) + depth(s2))
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOUN_WEIGHT

public static final double NOUN_WEIGHT
See Also:
Constant Field Values

ADJ_WEIGHT

public static final double ADJ_WEIGHT
See Also:
Constant Field Values

VERB_WEIGHT

public static final double VERB_WEIGHT
See Also:
Constant Field Values

MINIMUM_DISTANCE

private static final double MINIMUM_DISTANCE
See Also:
Constant Field Values

nounsResults

double[][] nounsResults

verbsResults

double[][] verbsResults

adjectivesResults

double[][] adjectivesResults

nounsMasks

double[][] nounsMasks

verbsMasks

double[][] verbsMasks

adjectivesMasks

double[][] adjectivesMasks

nouns1

private Hashtable nouns1

adjectives1

private Hashtable adjectives1

verbs1

private Hashtable verbs1

nouns2

private Hashtable nouns2

adjectives2

private Hashtable adjectives2

verbs2

private Hashtable verbs2
Constructor Detail

JWNLDistances

public JWNLDistances()
Method Detail

Initialize

public void Initialize()
                throws AlignmentException
Initialize the JWNL API. Must be done one time before computing distance Need to configure the file_properties.xml located in the current directory

Throws:
AlignmentException

Initialize

public void Initialize(String wordnetdir,
                       String wordnetversion)
                throws AlignmentException
Throws:
AlignmentException

basicSynonymDistance

public double basicSynonymDistance(String s1,
                                   String s2)
Compute a basic distance between 2 strings using WordNet synonym.

Parameters:
s1 -
s2 -
Returns:
Distance between s1 & s2 (return 1 if s2 is a synonym of s1, else return a BasicStringDistance between s1 & s2)

getAllSenses

Set<net.didion.jwnl.data.Synset> getAllSenses(String term)
                                        throws AlignmentException
Retrieve all WordNet sense of a term

Parameters:
term -
Returns:
the set of senses of term
Throws:
AlignmentException

cosynonymySimilarity

public double cosynonymySimilarity(String s1,
                                   String s2)
                            throws AlignmentException
Compute the proportion of common synset between two words

Parameters:
s1 -
s2 -
Returns:
Throws:
AlignmentException

basicSynonymySimilarity

public double basicSynonymySimilarity(String s1,
                                      String s2)
                               throws AlignmentException
Evaluate if two terms can be synonym

Parameters:
s1 -
s2 -
Returns:
Throws:
AlignmentException

basicGlossOverlap

public double basicGlossOverlap(String s1,
                                String s2)
                         throws AlignmentException
NOT FINISHED Compute the overlap between all glosses of two strings

Parameters:
s1 -
s2 -
Returns:
The glosses is made as indicated in Example 4.29 of the first edition of our Ontology matching book: - for each word: get glosses for all senses - suppress quotations (between quotes) - suppress empty words (or, and, the, a, an, for, of ) - suppress empty phrases (usually including) - suppress technical vocabulary (sentence, verb, noun, adjective, term) - stem words - create a set of words (not bag) with these Compare their intersection over their union. This function is not implemented because it would require to much add on to the API
Throws:
AlignmentException

wuPalmerSimilarity

public double wuPalmerSimilarity(String s1,
                                 String s2)
                          throws AlignmentException
Compute the Wu-Palmer similarity defined by score = 2*depth(lcs(s1,s2)) / (depth(s1) + depth(s2))

Parameters:
s1 -
s2 -
Returns:
the Wu-Palmer similarity The algorithm returns the best Wu-Palmer similarity among the pairs of synsets corresponding to s1 and s2 Assumption: JE**1: root is when no hypernyms exists... Sketck: 1) full depth-first search from s1 with record shortest path distance from s1 and depth 2) depth-first search from s2 until reached lcs with record the best Wu-Palmer NOTE: The first phase (on s1) is a preprocessing step. In the case when the user want to compute a whole Wu-Palmer matrix, this step is made |s2| times: it may be worth caching this step
Throws:
AlignmentException

computeSimilarity

public double computeSimilarity(String s1,
                                String s2)

compareComponentNames

public double compareComponentNames(String s1,
                                    String s2)

computeTokenSimilarity

public double computeTokenSimilarity(net.didion.jwnl.data.IndexWord index1,
                                     net.didion.jwnl.data.IndexWord index2)

findMatchForAdj

public double findMatchForAdj(net.didion.jwnl.data.IndexWord index1,
                              net.didion.jwnl.data.IndexWord index2)

lookUpWord

public void lookUpWord(String word,
                       Hashtable<String,net.didion.jwnl.data.IndexWord> nouns,
                       Hashtable<String,net.didion.jwnl.data.IndexWord> adjectives,
                       Hashtable<String,net.didion.jwnl.data.IndexWord> verbs)
Parameters:
word -

display

public void display(net.didion.jwnl.data.Synset syn)

getCommonConcepts

public int getCommonConcepts(net.didion.jwnl.data.list.PointerTargetNodeList list1,
                             net.didion.jwnl.data.list.PointerTargetNodeList list2)

bestMatch

private double bestMatch(double[][] matrix)

getNumberOfOccurences

public int getNumberOfOccurences(String token,
                                 int n)
Parameters:
token - A token.
n - The number of the ontology (typically 1 or 2).
Returns:
the number of occurences of the token in the hashtables nouns, adjectives and verbs.

getNumberOfOccurences

public int getNumberOfOccurences(String token,
                                 Hashtable nouns,
                                 Hashtable adj,
                                 Hashtable verbs)

displayMatrix

public void displayMatrix(double[][] matrix)

fillWithOnes

public void fillWithOnes(double[][] matrix)

getAdjectivesResults

public double[][] getAdjectivesResults()

getNounsResults

public double[][] getNounsResults()

getVerbsResults

public double[][] getVerbsResults()

Alignment API and Server 3.6

(C) INRIA & friends, 2003-2008