Converting facts into a graph

101 views
Skip to first unread message

madiha shiekh

unread,
Sep 20, 2018, 10:07:27 AM9/20/18
to SWI-Prolog
Hii

I am new to prolog and currently i have a set of automatically generated facts from the text descriptions ... The basic idea is to build a graph of those facts . As i am new any help would be appreciated like for example the set of facts are below

at(i,trainstation).
in(i,bamberg).
in(trainstation,bamberg).

now how can i replace predicates with path or connected instead of at or in and how can i represent edge with at written on it ... As i  am a beginner i need some nice clues as it is a small part of my project

thnnkyou in advance

Boris Vassilev

unread,
Sep 20, 2018, 12:02:24 PM9/20/18
to madiha shiekh, SWI-Prolog
What kind of graph representation do you have in mind? How is it going to be used within the project?

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

madiha shiekh

unread,
Sep 20, 2018, 12:07:50 PM9/20/18
to SWI-Prolog
I am looking for a simple graph in which instead of weights like 8, 9 values i can have at , in other predicates and it should be like i in bamberg i, at treainstation kind of representation if it can be graphical that will be great. I am new to prolog these facts have been generated using python my task is to convert them in to a graphical representation... Moreover every time the number of facts can vary like it can go up to 8 or more facts and i have no idea how to deal with it

On Thursday, September 20, 2018 at 6:02:24 PM UTC+2, boris.vassilev wrote:
What kind of graph representation do you have in mind? How is it going to be used within the project?
On Thu, Sep 20, 2018 at 5:07 PM, madiha shiekh <madiha...@gmail.com> wrote:
Hii

I am new to prolog and currently i have a set of automatically generated facts from the text descriptions ... The basic idea is to build a graph of those facts . As i am new any help would be appreciated like for example the set of facts are below

at(i,trainstation).
in(i,bamberg).
in(trainstation,bamberg).

now how can i replace predicates with path or connected instead of at or in and how can i represent edge with at written on it ... As i  am a beginner i need some nice clues as it is a small part of my project

thnnkyou in advance

--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.

Boris Vassilev

unread,
Sep 20, 2018, 12:12:55 PM9/20/18
to madiha shiekh, SWI-Prolog
I'm sorry, I would have liked to help but I cannot understand you. :-(

To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.

madiha shiekh

unread,
Sep 20, 2018, 12:16:50 PM9/20/18
to SWI-Prolog
its ok ... we generating facts automatically from sentences and then want to have a graphical representation to see which node is connected to which and for that i want to learn that how i can make a graph of the data i have shown here ...
Does i have to change predicate name(at) to edge and if yes how by having same arguments as at have ? or can i add new facts by replacing the predicated name to show that they are connected just need to make a graph consider arguments as nodes and predicates as a edge between them

I hope i have given you some concept

Boris Vassilev

unread,
Sep 20, 2018, 1:11:48 PM9/20/18
to madiha shiekh, SWI-Prolog
Hmm. There are two packs that let you generate graphml and graphviz graphs, see here: http://www.swi-prolog.org/pack/list

Maybe there are more?

I guess you need to see which format is better for your use case first. How are you going to render it?

Then you can see if one of the two packs easily generates the picture you need rendered.

Only then try to figure out how to turn your current representation to the representation that you need.



To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.

madiha shiekh

unread,
Sep 20, 2018, 1:13:28 PM9/20/18
to SWI-Prolog
Thankyou so much for the replay i will look at this and will let you know for further queries.. Thanks alot 

cc.carlo.cap

unread,
Sep 22, 2018, 9:02:13 AM9/22/18
to SWI-Prolog


Il giorno giovedì 20 settembre 2018 16:07:27 UTC+2, madiha shiekh ha scritto:
Hii


Hi Madiha

You could try my genealogy graph layout .

It requires dot installed - on Ubuntu, as easy as
$ sudo apt install graphviz

Then, after downloaded the repo above in ~/Downloads/prolog-snippets-master,
$ cd ~/Downloads/prolog-snippets-master/genealogy
$ swipl elizabeth.pl
Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.19-18-g8b798fb-DIRTY)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- elizabeth.
true .

?- ^D
% halt

Now in ~/Downloads/prolog-snippets-master/genealogy/temp.svg you should see a graph of the database.
The layout engine is dot, of course, so you have a *lot* of options about the outcome, tweaking the code, of course.

Enjoy, Carlo
Reply all
Reply to author
Forward
0 new messages