wrodNet representation using HyperGraphDB

55 views
Skip to first unread message

Mohanad abu baker

unread,
Oct 14, 2017, 4:50:49 PM10/14/17
to HyperGraphDB
Dear All,

I have no idea about hypergraphdb, and I would like to install it and represent WordNet using HyperGraphDB.
Please if any one has any help I will appreciate it. I am a graduate student and my Supervisor ask me to install hypergraphdb and represent the wordnet using it.

Regards,
Muhanad

Borislav Iordanov

unread,
Oct 23, 2017, 1:31:39 AM10/23/17
to hyperg...@googlegroups.com
Hi,

HyperGraphDB is an embedded database. First, make sure you can create a Java program that create a new database, adds and retrieves data from it. Take a look at the tutorials:

or

Then take a look at the “Loading Wordnet in a HypergraphDB” section here:


You will need the ability to code in Java to use HyperGraphDB. 

Cheers,
Boris 


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

Mohanad abu baker

unread,
Oct 28, 2017, 12:52:38 PM10/28/17
to HyperGraphDB
Dear Boris ,
I appreciate your help, I follow the steps in the tutorial. I use the code in the tutorial to load wordnet as hypergraphDB.
Now I have a folder with files like "0000006c.jdb".
In hypergraphDB code, there is conrath similarity function. its looks like this:


public double getJiangConrathSimilarity(HGHandle s1, HGHandle s2)

{

Set<HGHandle> lcsSet = getAllLeastCommonSubsumers(s1, s2);

double ics = 0.0;

for (HGHandle h : lcsSet)

ics = Math.max(ics, getInformationContent(h));

return 1.0 -(getInformationContent(s1) + getInformationContent(s2) - 2.0*ics)/2.0;

}


 Can you show me just a piece of code to query it in java.
Regards.
Muahnad

Mohanad abu baker

unread,
Oct 29, 2017, 1:04:02 PM10/29/17
to HyperGraphDB
The problem is how to get a handle for an atom. Lets say I want to compare the similarity for two words from WordNet Db, and I loaded the WordNet Using HyperGraphDB.

Borislav Iordanov

unread,
Oct 29, 2017, 1:10:17 PM10/29/17
to hyperg...@googlegroups.com
Hi,

You have to lookup the word by its lemma first. Each word is stored as an atom and then each synset as a different atom, that links to the synonyms in the synset etc.

So to lookup a word, you can do:

HyperGraph graph = HGEnvironment(location of your WordNet graph);

// A wrapper with utility functions pertaining to WordNet
WNGraph wngraph = new WNGraph(graph);
HGHandle dogLemma = wngraph.findWord(“dog”);

Hope this helps!
Boris

On Oct 29, 2017, at 1:04 PM, Mohanad abu baker <mohan...@gmail.com> wrote:

The problem is how to get a handle for an atom. Lets say I want to compare the similarity for two words from WordNet Db, and I loaded the WordNet Using HyperGraphDB.

Mohanad abu baker

unread,
Oct 29, 2017, 1:41:12 PM10/29/17
to HyperGraphDB
I will try it. Thanx a lot. You don't know how much this will help me. Good bless you.

Mohanad abu baker

unread,
Oct 29, 2017, 5:15:38 PM10/29/17
to HyperGraphDB
Dear Boris,
I follow the code you wrote it to me and its great. Now I know how to get the Handle for an atom.
but when I run the following code, I get a casting error.

String wordnetDB = "c:/hypergraphdb1";

HyperGraph graph = HGEnvironment.get(wordnetDB);


WNGraph wngraph = new WNGraph(graph);

HGHandle flagLemma = wngraph.findWord("flag");

HGHandle swagLemma = wngraph.findWord("swag");


double h;

      

SemTools x = new SemTools(graph);

h= x.getJiangConrathSimilarity(flagLemma, swagLemma);

      


The error is :

Exception in thread "main" java.lang.ClassCastException: org.hypergraphdb.app.wordnet.data.Word cannot be cast to org.hypergraphdb.app.wordnet.data.SynsetLink


at org.hypergraphdb.app.wordnet.SemTools.getInformationContent(SemTools.java:121)


at org.hypergraphdb.app.wordnet.SemTools.getJiangConrathSimilarity(SemTools.java:429)


at org.hypergraphdb.app.wordnet.conrathtest.main(conrathtest.java:41)


Regards,

Borislav Iordanov

unread,
Oct 29, 2017, 10:54:35 PM10/29/17
to hyperg...@googlegroups.com
Hi,

That is because this similarity measure is between concepts (i.e. senses in WordNet’s ontology) and not words. So given two words, you must first pick synsets they belong to and then compute similarity between the two. 

Best,
Boris

Mohanad abu baker

unread,
Oct 30, 2017, 12:10:04 PM10/30/17
to HyperGraphDB
Dear Boris,

So you mean I have to get the Synset for each word, then the handle for each Synset. After that I should send the handle of the Sysnset To the SemTools?

Could you please show me the code for get the Sysnset of a word?

Regards,
Muhanad

Mohanad abu baker

unread,
Oct 30, 2017, 5:40:43 PM10/30/17
to HyperGraphDB
Dear Boris,

I read and read until finally wrote this code, taking into my considerations the instructions you have told me:

WNGraph wngraph = new WNGraph(graph);


HGHandle LoveLemma = wngraph.findWord("love");

HGHandle RomanceLemma = wngraph.findWord("Romance");

String LoveVar= graph.get(LoveLemma).toString();

String RomanceVar= graph.get(RomanceLemma).toString();


List<HGHandle> syn = wngraph.getNounSenses(LoveLemma);

List<HGHandle> syn2 = wngraph.getNounSenses(RomanceLemma);


double SimilarityMeasure;


SemTools SemObject = new SemTools(graph);

SimilarityMeasure= SemObject.getJiangConrathSimilarity(syn.get(0), (syn2.get(0)));

System.out.println(h);


I get Similarity Result. But I want to ask you is this code ok?

Is there any other code is better than this code to get getJiangConrathSimilarity measure? If Yes please write it here.


Regards,

Muhanad

Borislav Iordanov

unread,
Oct 30, 2017, 10:11:17 PM10/30/17
to hyperg...@googlegroups.com
Hi Mohanad,

Yes, this looks ok. Obviously, if there are multiple senses for those words, you are just randomly picking the very first one. In general, you might need some other means to pick the correct sense. Or maybe if you already know that the words are supposed to be similar, you pick the two senses that maximize the similarity. This is a bit what is done when in various WSD (word sense disambiguation) algorithms. 

Cheers,
Boris

Mohanad abu baker

unread,
Oct 31, 2017, 2:35:43 AM10/31/17
to HyperGraphDB
Dear Boris,

I highly appreciate your help. You are the best.
God bless you

Regards,
Muhanad

Mohanad abu baker

unread,
Nov 4, 2017, 3:53:53 PM11/4/17
to HyperGraphDB
Dear Boris,
How are you doing sir?

I want to ask you how to do the following :
If I want to use Breadth first search to search for a Synset. Then if I find it, I want to extract a sub-hypergraph from the WordNet hypergraph with k-levels for example.
Can I do this, is there any code in java already written for this purpose?
Please if yes , help me.

Regards,
Muhand

Borislav Iordanov

unread,
Nov 5, 2017, 10:21:55 PM11/5/17
to hyperg...@googlegroups.com
I don’t think there is specific code to handle this. But you should have all the necessary tools to implement it :)

Good luck!

Boris

Message has been deleted

Mohanad abu baker

unread,
Nov 14, 2017, 1:52:06 PM11/14/17
to HyperGraphDB
Dear Borislav,

If I want to find the set of all closet common parents between two Synsets in an ISA sematic relationships hierarchy, I must use getAllLeastCommonSubsumers function from SemTools Class.
Now if I want to find the closet parents between the synset "table" and  the synset "array" I must send their handles to the function, But table has more than one handle and array has also multiple handles.
So in this case we will send only one handle for each of them and in this case the function will work exactly like getLeastCommonSubsumers.

I wrote some code to make my question clear:

String wordnetDB = "c:/hypergraphdb1";

HyperGraph graph = HGEnvironment.get(wordnetDB);

WNGraph wngraph = new WNGraph(graph);

HGHandle synset1 = wngraph.findWord("calendar");

HGHandle synset2 = wngraph.findWord("transpose");

List<HGHandle> syn1 = wngraph.getNounSenses(synset1);

List<HGHandle> syn2 = wngraph.getNounSenses(synset2);

SemTools SemInstance= new SemTools(graph);

Set<HGHandle> Root= SemInstance.getAllLeastCommonSubsumers(syn1.get(1),syn2.get(1));

for(HGHandle r: Root)

System.out.println(graph.get(r));



The above code, it will return one parent because we specify one synset for table and one synset for array.

How can we send all the handles for the synset  "table" and also the synset "array" to return the closet parents?


Regards,

Muhanad


Reply all
Reply to author
Forward
0 new messages