Thursday, March 23, 2017

linkDistance - D3 study

Understanding D3.js Force Layout - 4: linkDistance

http://bl.ocks.org/sathomas/83515b77c2764837aac2

Tuesday, March 21, 2017

Preparing a pull request for an outdated fork

I have a directory on github at : http://github.com/bshambaugh/ovn

It was behind http://github/valueflows/valueflows.

So I needed to first configure a remote for a fork:

https://help.github.com/articles/configuring-a-remote-for-a-fork/

then sync it by branch with valueflows/valueflows:

https://help.github.com/articles/syncing-a-fork/

Now I want to do a Pull Request with the json file created with owl2vowl?

well at least it is at:

https://github.com/bshambaugh/ovn/blob/master/release-doc-in-process/all_vf.json

Friday, March 17, 2017

Loading Data in node-arc-d3

Starting from the top of the flowchart in https://github.com/bshambaugh/node-arc-d3 :

I have issues:
https://github.com/bshambaugh/node-arc-d3/issues/7
(SPARQL Queries)
https://github.com/bshambaugh/node-arc-d3/issues/13
(Have a box to load ldp containers, turtle files, and perform sparql queries)

And excerpts from the EISPP wireframes (http://bshambaugh.org/eispp):

Loading RDF files and LDP containers

Loading RDF Files

Save data/load data

 Save data
SPARQL Queries



These wireframe screenshots involve both GET and POST. For now I will use GET. I will also do disambiguation as mentioned in Issue 13.
https://github.com/bshambaugh/node-arc-d3/tree/master/js/tests/sparqlldpfiledisambig


Use URIjs to show the query parameter and the path, and follow a flowchart like:

Eventually, it is hoped, that NLQ will also be a data source:


Like In the EISPP wireframe:


To get this is I am reading the PowerAqua Thesis, to use it to extract relevant facts, which I believe are triples. PowerAqua helped build Miriam Fernandez' Thesis:


(A thesis presented for the degree of Doctor of Philosophy in Computer SciencePowerAqua:Open Question Answeringon the Semantic Web, V. Lopez)
http://technologies.kmi.open.ac.uk/poweraqua/thesis-master-viva.pdf


Wednesday, March 15, 2017

Tuesday, March 14, 2017

Link Labels in D3 at Midpoint:

Adding a Label to the Links (StackOverflow):

http://stackoverflow.com/questions/23470330/adding-label-to-the-links-in-d3-force-directed-graph

Labels to avoid overlap:

http://stackoverflow.com/questions/17425268/d3js-automatic-labels-placement-to-avoid-overlaps-force-repulsion

Meh.. (place a node at the midpoint where the node label should be somehow)

???

 var linknodes = svgContainer.append("g")
                  .attr("class","nodes")
                  .selectAll("circles")
                  .data(graph.links)
                  .enter().append("circle").attr("r",20)
                  .attr("fill", function(d) { return color(d.group); })
                  .call(d3.drag()
                  .on("start", dragstarted)
                  .on("drag", dragged)
                  .on("end", dragended));

function ticked() {

    linknodes
        .attr("x", function(d) { return (d.source.x + d.target.x)/2; })
        .attr("y", function(d) { return (d.source.y + d.target.y)/2; });

}

simulation
      .nodes("brents midpoint nodes")
      .on("tick", ticked);

but this does not work....I need to figure out how to create nodes on the fly

http://stackoverflow.com/questions/9539294/adding-new-nodes-to-force-directed-layout

references : https://bl.ocks.org/mbostock/1095795

http://stackoverflow.com/questions/17529522/transparent-color-in-javascript-d3-js

D3 Force Directed Graph with Fit Node Labels and Collision Detection

Key code:

.force("collide", d3.forceCollide(60));

       .enter().append("ellipse")
       .attr("rx", function(d) { return d.id.length * 4 })
       .attr("ry", 15)
      .attr("fill", function(d) { return color(d.group); })

Full code
(seeAlso: https://github.com/bshambaugh/node-arc-d3/blob/master/js/d3sketch.js) :

function draw(width,height,graph) {

 // see https://bl.ocks.org/mbostock/4062045

 var svgContainer = d3.select("body").append("svg")
                                       .attr("width",width)
                                       .attr("height",height);

  var color = d3.scaleOrdinal(d3.schemeCategory20);

  var simulation = d3.forceSimulation()
//    .force("link", d3.forceLink().id(function(d) { return d.id; }).distance(300).strength(0.5))
    .force("link", d3.forceLink().id(function(d) { return d.id; }))
    .force("charge", d3.forceManyBody())
    .force("center", d3.forceCenter(width / 2, height / 2))
    .force("collide", d3.forceCollide(60));

  var link = svgContainer.append("g")
      .attr("class", "links")
    .selectAll("line")
    .data(graph.links)
    .enter().append("line")
      .attr("stroke-width", function(d) { return Math.sqrt(d.value); });

    // Extended d3 force directed graphs with link labels

    var linklabel = svgContainer.append("g")
                  .attr("class","links")
                  .selectAll("text")
                  .data(graph.links)
                  .enter().append("text");

var linklabels = linklabel
                    .text( function(d) { return d.label; })
                    .attr("font-family","sans-serif")
                    .attr("font-size","10px")
                    .attr("fill","black");


  var nodevar = svgContainer.append("g")
      .attr("class", "nodes")
    .selectAll("circle")
    .data(graph.nodes)
//    .enter().append("circle")
//      .attr("r", 5)
       .enter().append("ellipse")
       .attr("rx", function(d) { return d.id.length * 4 })
       .attr("ry", 15)
      .attr("fill", function(d) { return color(d.group); })
      .call(d3.drag()
          .on("start", dragstarted)
          .on("drag", dragged)
          .on("end", dragended));

    // Extended d3 dforce directed graph with node labels

    var nodelabel = svgContainer.append("g")
                   .attr("class","nodes")
                   .selectAll("text")
                   .data(graph.nodes)
                   .enter()
                   .append("text")
                   .call(d3.drag()
                       .on("start", dragstarted)
                       .on("drag", dragged)
                       .on("end", dragended));

   var nodelabels = nodelabel
                  //  .attr("x", function(d) { return d.x; })
                  //  .attr("y", function(d) { return d.y; })
                    .text( function(d)  { return d.id; })
                    .attr("font-family","sans-serif")
                    .attr("font-size","10px")
                    .attr("fill","black")
                    .attr("text-anchor", "middle");


   nodevar.append("title")
      .text(function(d) { return d.id; });

  simulation
      .nodes(graph.nodes)
      .on("tick", ticked);

  simulation.force("link")
      .links(graph.links);

  function ticked() {
    link
        .attr("x1", function(d) { return d.source.x; })
        .attr("y1", function(d) { return d.source.y; })
        .attr("x2", function(d) { return d.target.x; })
        .attr("y2", function(d) { return d.target.y; });

    // extended with link labels

    linklabels
        .attr("x", function(d) { return (d.source.x + d.target.x)/2; })
        .attr("y", function(d) { return (d.source.y + d.target.y)/2; });

    nodevar
        .attr("cx", function(d) { return d.x; })
        .attr("cy", function(d) { return d.y; });

      // extended with node labels

     nodelabels
        .attr("x", function(d) { return d.x; })
        .attr("y", function(d) { return d.y; });
  }


  function dragstarted(d) {
  if (!d3.event.active) simulation.alphaTarget(0.3).restart();
  d.fx = d.x;
  d.fy = d.y;
}

function dragged(d) {
  d.fx = d3.event.x;
  d.fy = d3.event.y;
}

function dragended(d) {
  if (!d3.event.active) simulation.alphaTarget(0);
  d.fx = null;
  d.fy = null;
}

};

======================================

TODO: Express edge labels as transparent nodes centered at the midpoint of the edge, so that the force collide method applies?




Sunday, March 12, 2017

D3 mindmaps and tutorials

Mindmaps with D3:

http://thomasrickard.uk/articles/d3---mindmaps-%28v4%29-13-08-2016.html

D3 Force Directed Graph (curved edges) http://jsfiddle.net/skysigal/gp0u5rLu/
I will need these if there are two or more triples that share the same subject and object.

D3 Tutorials from Slideshare:

https://www.slideshare.net/josdirksen/learn-d3js-in-90-minutes

https://www.slideshare.net/YoungHoKim6/a-quick-and-dirty-d3js-tutorial?next_slideshow=1

https://www.slideshare.net/miconi/d3introduction?next_slideshow=2

Collision Detection:

http://fwz.github.io/2013/09/15/learn-d3-the-hard-way-(1)----collision-detection/

related to: https://bl.ocks.org/mbostock/1747543
https://bl.ocks.org/mbostock/3231298

Nodes and edges:

http://stackoverflow.com/questions/17920704/avoid-collision-between-nodes-and-edges-in-d3-force-layout

I suppose the collision between nodes and edges is like the collision between a node and a line of nodes. Think Analytical Geometry! You also need to worry about the labels as well.

Link Length:

https://gist.github.com/sathomas/83515b77c2764837aac2

Questions about Sigmajs

See: http://sigmajs.org/
Build from: https://github.com/jacomyal/sigma.js

Is it possible to draw a graph without providing node positions? Answer, provide random initial node positions or provide positions on a circle and then run ForceAtlas2 layout engine?
https://github.com/jacomyal/sigma.js/issues/336

Then the question is, how do you stop the ForceAtlas2 layout engine?


How do you show edge labels?
http://stackoverflow.com/questions/19401147/show-edge-label-in-sigma-jsHow do I click on edges and have something happen?

https://github.com/jacomyal/sigma.js/wiki/Events-API

Thursday, March 9, 2017

Modify d3 force directed graph


    .force("link", d3.forceLink().id(function(d) { return d.id; }).distance(300).strength(0.5))
//    .force("link", d3.forceLink().id(function(d) { return d.id; }))



http://stackoverflow.com/questions/39244186/how-do-you-set-a-fixed-link-distance-with-d3-v4

https://github.com/d3/d3-force



change the lines in " var nodevar"

//    .enter().append("circle")
//      .attr("r", 5)
     .enter().append("ellipse")
      .attr("rx", 60)
      .attr("ry", 15)

//    .enter().append("circle")


Tuesday, March 7, 2017

Getting PowerAqua Running with Tomcat 7 - NLQ for Semantic Search

I navigated to the PowerAqua site:
http://technologies.kmi.open.ac.uk/poweraqua/

Then I navigated to SourceForge

https://sourceforge.net/projects/poweraqua/files/code/webapps-tomcat/poweraqualinked.zip

I dumped the unzipped PowerAquaLinked folder into my tomcat7/webapps/ROOT directory, but it does not initiate with the init.jsp script like I think it should from index.html.

The sample app works https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/ and a static index.html file work. Perhaps it is a configuration option.
I did not touch anything. It just 404s now.

Investigation of the file service_properties.xml shows a lot of paths with the prefix http://kmi-web03.open.ac.uk . ping http://kmi-web03.open.ac.uk gives
ping: http://kmi-web03.open.ac.uk unknown host. The same for port 8080.
ping: unknown host http://kmi-web03.open.ac.uk:8080

service_properties.xml contains the host kmi-web15.open.ac.uk on port 8890, which also does not exist. (ping: unknown host kmi-web15.open.ac.uk:8890) .

multi_index_properties.xml contains installation specific code like:
/Applications/apache-tomcat-5.5.23/webapps/poweraqualinked/LuceneIndexes/

so does indexproperties: index_properties.xml .

--------------------------------------------

so I need to derive a list of services that I need to set up, and then I need to reference them:

First I know I need a sql database:
https://sourceforge.net/projects/poweraqua/files/mysql%20indexes%20backup/

From service_properties.xml :

See: https://sourceforge.net/projects/sesame/

<PLUGIN_MANAGER>/Applications/apache-tomcat-5.5.23/webapps/poweraqualinked/WEB-INF/aquaplugins</PLUGIN_MANAGER>

<SERVER>http://kmi-web03.open.ac.uk:8080/sesame</SERVER>

cat service_properties.xml | grep -o "<REPOSITORY_NAME>http://[a-z0-9.\/:-]*" | grep -o "/[a-z]*" | grep -o "[a-z]*" | sort | uniq

academia
agent
aktivesa
angioplasty
animals
apocalypse
autos
baberuth
baltimoremayor
beavers
beer
bengal
biomedical
biopax
biosphere
biozen
calcium
census
chevrolet
children
coastalontology
conclusions
cyclic
danchundogs
dbpedia
deer
diseases
doap
dog
earthrealm
eculture
eldorado
elements
fao
fasting
fearlus
filmfestival
finance
flows
foaf
food
formdemo
functions
fungalv
galen
geneontology
gps
gutenberg
helmet
human
hunger
imdb
infrastructure
jackierobinson
jamendo
jennifer
kanzakimusic
kappaalphapsi
kimo
kmi
koala
ksw
lavalamps
lighbulb
lod
magnatude
material
mensa
mid
moses
moviedatabase
music
mygrid
ncioncology
newport
ontoworld
parkinson
peergynt
people
periodictable
person
phenomena
phenomenon
pizza
plainmoor
premises
process
property
rosebowl
royalcaribbean
russia
semanticconferences
sesame
skoda
space
sparql
stconcepts
steinbach
sweetjplnasa
tapfull
tartan
taxonomy
time
tiposcomida
tmj
traffic
travel
trees
upm
utexas
wave
wildlife
zirconium

Virtuoso Properties (virtuoso_properties.xml):

<?xml version="1.0" encoding="UTF-8"?>
<CONFIGURATION>

<SERVER>
    <URL>kmi-web15.open.ac.uk</URL>
    <PORT>8890</PORT>
    <LOGIN>dba</LOGIN>
    <PASSWORD>dba</PASSWORD>
    <GRAPHS>
        <GRAPH>
            <IRI>http://dbpedia.org</IRI>
            <TYPE>OWL</TYPE>
        </GRAPH>
    </GRAPHS>
</SERVER>

</CONFIGURATION>

Multi-Index Properties ():

<CONFIGURATION>
    <WATSON>true</WATSON>
   <POWERMAP>true</POWERMAP>
   <VIRTUOSO>true</VIRTUOSO>     <REMOTESPARQLVIRTUOSO>false</REMOTESPARQLVIRTUOSO><ONTOLOGY_INDEX_DB>
jdbc:mysql://localhost:3306/ontologyindexrelation
</ONTOLOGY_INDEX_DB>
<ONTOLOGY_INDEX_DB_LOGIN>
root
</ONTOLOGY_INDEX_DB_LOGIN>
<ONTOLOGY_INDEX_DB_PASSWORD/>
<INDEX_GLOBAL_PATH>
/Applications/apache-tomcat-5.5.23/webapps/poweraqualinked/LuceneIndexes/</INDEX_GLOBAL_PATH>
 <INDEX_INFO_FOLDER>
 ./indexListInformation/indexkmiweb07-philips/
 </INDEX_INFO_FOLDER>
</CONFIGURATION>

cat index_properties.xml | grep -o "<METADATA_INDEX_TABLE>[a-z0-9.\/:-]*" |  grep -o "[a-z0-9.\/:-]*" | sort | uniq

<INDEX_DIRECTORY>
indexkmiweb07linkedata/index
indexkmiweb07mysql/index
indexkmiweb07pg/index
indexkmiweb07trec/index
indexkmiweb07uam/index

compare to: /poweraqualinked/LuceneIndexes$

indexkmiweb07linkedata
indexkmiweb07mysql
indexkmiweb07pg
indexkmiweb07trec
indexkmiweb07-trec
indexkmiweb07uam

<SPELL_INDEX_DIRECTORY>
indexkmiweb07linkedata/spell
indexkmiweb07mysql/spell
indexkmiweb07pg/spell
indexkmiweb07trec/spell
indexkmiweb07uam/spell

<METADATA_INDEX_TABLE>
indexkmiweb07linkedata
indexkmiweb07mysql
indexkmiweb07pg
indexkmiweb07trec
indexkmiweb07uam

----------------------
The next step should be to look at the database backup. I don't know where all of the repositories come from for sesame. I was unable to find them in the downloaded files (excluding the database backup).

backup-ontologyindexrelation_2012-01-03_19.13.03.sql
backup-metadataindex-jul09_2012-01-03_19.13.34.sql

https://forums.mysql.com/read.php?10,195091,195097

I get something like:
ERROR 1045: Access denied for user: 'root@localhost' (Using 
password: NO)
 
 
metadataindex

    indexkmiweb07eculturedirectclasses

       id  ontologyId  entityURI  classURI  classLabel
    indexkmiweb07eculturedirectsubclasses
    indexkmiweb07eculturedirectsuperclasses
    indexkmiweb07ecultureequivalent
    indexkmiweb07eculturesubclasses
    indexkmiweb07eculturesuperclasses
    indexkmiweb07fiatdirectclasses
    indexkmiweb07fiatdirectsubclasses
    indexkmiweb07fiatdirectsuperclasses
    indexkmiweb07fiatequivalent
    indexkmiweb07fiatsubclasses
    indexkmiweb07fiatsuperclasses
    indexkmiweb07linkedatadirectclasses
    indexkmiweb07linkedatadirectsubclasses
    indexkmiweb07linkedatadirectsuperclasses
    indexkmiweb07linkedataequivalent
    indexkmiweb07linkedatasubclasses
    indexkmiweb07linkedatasuperclasses
    indexkmiweb07mysqldirectclasses
    indexkmiweb07mysqldirectsubclasses
    indexkmiweb07mysqldirectsuperclasses
    indexkmiweb07mysqlequivalent
    indexkmiweb07mysqlsubclasses
    indexkmiweb07mysqlsuperclasses
    indexkmiweb07pgdirectclasses
    indexkmiweb07pgdirectsubclasses
    indexkmiweb07pgdirectsuperclasses
    indexkmiweb07pgequivalent
    indexkmiweb07pgsubclasses
    indexkmiweb07pgsuperclasses
    indexkmiweb07swdirectclasses
    indexkmiweb07swdirectsubclasses
    indexkmiweb07swdirectsuperclasses
    indexkmiweb07swequivalent
    indexkmiweb07swsubclasses
    indexkmiweb07swsuperclasses
    indexkmiweb07trecdirectclasses
    indexkmiweb07trecdirectsubclasses
    indexkmiweb07trecdirectsuperclasses
    indexkmiweb07trecequivalent
    indexkmiweb07trecsubclasses
    indexkmiweb07trecsuperclasses
 
ontologyindexrelation

    ontologyindextable
 
    id ontologyId indexManagerId  

https://help.ubuntu.com/community/MysqlPasswordReset

Useful References: (PowerAqua: supporting users in querying and exploring the Semantic Web)
http://www.semantic-web-journal.net/sites/default/files/swj102_2.pdf

(A thesis presented for the degree of Doctor of Philosophy in Computer SciencePowerAqua:Open Question Answeringon the Semantic Web, V. Lopez)
http://technologies.kmi.open.ac.uk/poweraqua/thesis-master-viva.pdf

Tomcat Web Application Deployment link

https://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html

Sparql with JavaScript Research

I looked at:

http://biohackathon.org/d3sparql/

http://notes.3kbo.com/javascript-sparql

https://github.com/RubenVerborgh/SPARQL.js

https://ruben.verborgh.org/blog/2014/08/22/writing-a-sparql-parser-in-javascript/

http://dailyjs.com/post/linked-data-and-javascript

http://kidehen.typepad.com/kingsley_idehens_typepad/2011/01/sparql-guide-for-the-javascript-developer.html

http://docs.publishmydata.com/developers/270_example_using_javascript_to_request_data_from_sparql_endpoint.html

In the end, this jquery script based on the last link works:

https://github.com/bshambaugh/node-arc-d3/blob/master/js/tests/jquerysparql/index2.html

Sunday, March 5, 2017

Quotes from PowerAqua

 From: "PowerAqua: Fishing the Semantic Web"

 " The system takes as input a natural language query, translates it into a set of logical queries, which are then answered by consulting and aggregating information derived from multiple heterogeneous semantic sources."

"Hence, to perform effective QA on the semantic web,we need a system which is able to locate and aggregate information, without any pre-formulated assumption about the ontological structure of the relevant information"

https://pdfs.semanticscholar.org/c529/c0c7c61504bb9023636b00ea88c803cf604c.pdf

Adding labels to edges that share the same two nodes

Today I had a problem with edges between the same two nodes overlapping, so that the labels also overlapped. I thought that the solution would be to use a d3 graph with curved edges (https://bl.ocks.org/mbostock/4600693).

I am not sure at this point how to add labels to a graph with curved edges. The syntax looks quite different.

Thus, I also investigated sigma.js which offers more functionality.
https://github.com/jacomyal/sigma.js

Saturday, March 4, 2017

Explorations for including a custom library

https://addyosmani.com/writing-modular-js/

I found this interesting for module definition with define and possible module retrieval with require.