Re: [dkpro-user] About WSD using wordnetResource and WordnetSenseKeySenseinventory

8 views
Skip to first unread message

Torsten Zesch

unread,
Jun 20, 2016, 3:39:50 AM6/20/16
to dkpro-c...@googlegroups.com, dkpro-w...@googlegroups.com
This is probably a question for the WSD user list.

-Torsten

2016-06-19 22:56 GMT+02:00 Jose Luis Vieyra Sagaon <jvi...@expansion.com.mx>:
Hello!
I'm using dkpro wsd and wordnet 3.0.

What I want to do is use Lesk algorithm to disambiguate the the word given the sentence as context.

So far it works pretty well, the problem is after I disambiguate the word, I get a Weird object in which the node id is in a different format than wordnet's (WordnetResource):

-WordnetResource (Entity): buy#13253751
-WordNetSenseKeySenseInventory (Word): buy%1:21:00::

I tried everything to form the id from one to the other but haven't done it yet, any ideas?
Ty for your time!
Some code:

I try to match it like this:
Word wword = lesk.getBestSense(theWord, context,POS.NOUN);
ent = wordnet.getEntityById(wword.getSenseKey());

in which :

public class WsdLeskAlgorithm {
private SenseTaxonomy inventory;
private LexicalSemanticResource wordnet = null;
private SimplifiedLesk lesk = null;


public WsdLeskAlgorithm(LexicalSemanticResource wordnet) throws IOException, JWNLException, LexicalSemanticResourceException {

this.wordnet = wordnet;
this.inventory = new WordNetSenseKeySenseInventory(
new ClassPathResource("wordnet/wordnet_properties.xml").getInputStream());

this.lesk = new SimplifiedExtendedLesk(inventory, new DotProduct(),
new MostObjects(), new StringSplit(),
new StringSplit());

System.out.println("Inventory: " + inventory.toString());
}



public Map<Word,Double> getAllSenses(String word, String context,POS pos) throws SenseInventoryException, JWNLException {
Map<Word,Double> probMap = new HashMap<>();

if (lesk != null && wordnet != null) {
Map<String, Double> senseProbmap = lesk.getDisambiguation(word, pos, context);
for (String s : senseProbmap.keySet()) {
Word disamWord = ((WordNetResource) wordnet).getDict().getWordBySenseKey(s);
probMap.put(disamWord, senseProbmap.get(s));
}
}
else
throw new RuntimeException("Lesk or Wordnet was null!!");
return probMap;
}

public Word getBestSense(String word,String context, POS pos) throws SenseInventoryException, JWNLException, LexicalSemanticResourceException {

Word best = null;

Map<Word,Double> probMap = this.getAllSenses(word,context,pos);
if (probMap.size() == 1){
return new ArrayList<>(probMap.keySet()).get(0);
} else if (probMap.size() > 1){
double current = 0.0;
for ( Word w: probMap.keySet()){
if (probMap.get(w) > current){
best = w;
current = probMap.get(w);
}
}
}

return best;
}

}


--
Mto. Ing. José Luis Vieyra S.
DataScience Manager @ GEx
Ext. 75725


Este correo y sus archivos adjuntos son personales, privilegiados y confidenciales y están destinados exclusivamente para el uso de la persona a la que están dirigidos. Si usted recibió este correo por error, le agradeceremos regresarlo al remitente notificando dicho hecho y borre el presente y sus anexos de su sistema sin conservar copia de los mismos. Si usted no es el destinatario al que este correo está dirigido, queda usted notificado que la difusión, distribución o el copiado de este correo y de sus archivos adjuntos está prohibido.
   
 AVISO: Hemos tomado las precauciones razonables para prevenir que este correo esté infectado por virus. No aceptamos responsabilidad alguna por daños o pérdidas causadas por el uso de este correo o de los archivos adjuntos al mismo.

 This e-mail and any attachments transmitted with it are personal, privileged and confidential and solely for the use of the individual to whom they are addressed and intended. If you have received this e-mail in error, please notify the sender by return e-mail and delete this message and its attachments from your system without keeping a copy. If you are not the intended recipient, you are hereby notified that the dissemination, distribution or copying of this e-mail and attachments transmitted with it is strictly prohibited.
   
 NOTICE: We have taken reasonable precautions to prevent viruses from being present in this e-mail. We do not accept responsibility for any loss or damage arising from the use of this e-mail or attachments.

--
You received this message because you are subscribed to the Google Groups "dkpro-core-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dkpro-core-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages