0
$\begingroup$

I have a table of records, each record is about a publication onm some topic, the different colums indicating the title, authors, abstract and so on

I made a function searchkeyword[string_] that searches all records that contain, either in the title or in the abstract, the specified keyword. This is a way to check what are the most popular keywors. However, keywords are not mutually exclusive, meaning that some work can contain more than 1 keyword.

To present the results to a large public, I would like to build a graph, and with that I mean something similar to this https://reference.wolfram.com/language/ref/GraphData.html

I would like to have a node for each table record, and some other nodes, preferably shown as bubbles, for each keyword, and a link between a nodes'work and a blbble'node/keyword if the spoecified work contains the given keyword.

However, I have no clue how to do this, as I never used the https://reference.wolfram.com/language/ref/GraphData.html function

$\endgroup$
2
  • $\begingroup$ Nah, you just want to enter a Graph in the form Graph[{publication1->keyword1,publication1->keyword2,..., publication2->keyword1, publication2->keyword2, ...}] and so on. That is one directed edge for each keyword per publication. How to get these directed edges depends very much on the way you stored the data. So nothing more can be said without a (small!) example data set. $\endgroup$ Feb 18, 2020 at 18:24
  • $\begingroup$ As I said, it's stored in a table where colums are title and abstract, and keywords have to be searched inside. Like publications={{title1, abstract1, other column without keywords},{title2, abstract2, other column without keywords}}. The way to build the association and it format is my main question. $\endgroup$ Feb 18, 2020 at 18:41

1 Answer 1

2
$\begingroup$

You could build a list of rules linking the publication to words and then generate a graph. e.g.

SeedRandom[1];
words = RandomWord["CommonWords", 10];
pub1Words = RandomSample[words, 4];
pub2Words = RandomSample[words, 5];
pub1Edges = "pub1" -> # & /@ pub1Words;
pub2Edges = "pub2" -> # & /@ pub2Words;
Graph[Join[pub1Edges, pub2Edges], VertexLabels -> "Name", ImageSize -> 500]

enter image description here

$\endgroup$
3
  • $\begingroup$ I understand. However, in this way you need to generate association for each publication (so maybe you can make an array for that and generate it with for or table), but maybe it's easier to make the reverse and generate association for each keyword? Keywords are like 10, publications ... many :D $\endgroup$ Feb 18, 2020 at 18:39
  • $\begingroup$ My Adapted code: SeedRandom[1]; words = RandomWord["CommonWords", 10]; pubWords =Table[RandomSample[words, RandomInteger[1,10]],{i,1,40}]; pubEdges = Table[StringJoin["pub",ToString[i]] -> # & /@ pubWords[[i]],{i,1,40}]; Graph[Join[pubEdges], VertexLabels -> "Name", ImageSize -> 500] $\endgroup$ Feb 18, 2020 at 18:47
  • $\begingroup$ RandomInteger[1,10] should be RandomInteger[10] and Join should be Flatten. Also add GraphLayout -> "RadialEmbedding" for a better layout. Depending on the number of publications and words, the graph quickly becomes too hard to interpret. $\endgroup$ Feb 18, 2020 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.