<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://www.wiki.prgarnett.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Phil</id>
	<title>PRGs Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="http://www.wiki.prgarnett.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Phil"/>
	<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php/Special:Contributions/Phil"/>
	<updated>2026-04-21T15:38:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=18</id>
		<title>Text Analysis:Bibliometrix</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=18"/>
		<updated>2019-12-23T11:50:36Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Page for various tools for the processing of bibliometrix data, these tools were originally developed for a project that was looking into academic communities by exploring search results from Web of Knowledge, at the time specifically Complex Thinking. Most of the tools are built in Neo4J and R. The programs build a network of papers and the work they cite.&lt;br /&gt;
&lt;br /&gt;
The first bit of code that is useful is for turning data loaded from Web of Science into the R Bibliometrix package to a CSV file that is useful for then loading into &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=R style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
library(bibliometrix)&lt;br /&gt;
library(igraph)&lt;br /&gt;
library(ggplot2)&lt;br /&gt;
&lt;br /&gt;
#reads in the exported&lt;br /&gt;
D &amp;lt;- readFiles(&amp;quot;bib_export.bib&amp;quot;)&lt;br /&gt;
#convert it into a matrix&lt;br /&gt;
M &amp;lt;- convert2df(D, dbsource = &amp;quot;isi&amp;quot;, format = &amp;quot;bibtex&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#pull out the bits of the data that we want, could add more in here.&lt;br /&gt;
cited=M$CR&lt;br /&gt;
author=M$AU&lt;br /&gt;
key = M$SR&lt;br /&gt;
title = M$TI&lt;br /&gt;
data = cbind(key,title,author,cited)&lt;br /&gt;
&lt;br /&gt;
#build a data frame for the export, there must be a better way of doing this.&lt;br /&gt;
E_List &amp;lt;- NULL;&lt;br /&gt;
for(i in 1:length(data[,1])){&lt;br /&gt;
  cit_list = unlist(strsplit(data[i,4], split=&amp;quot;.   &amp;quot;))&lt;br /&gt;
  for(s in 1:length(cit_list))&lt;br /&gt;
  {&lt;br /&gt;
    E_List &amp;lt;- rbind(E_List, c(data[i,1],cit_list[s]))&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#save the data&lt;br /&gt;
write.csv2(E_List, file = &amp;quot;NetExport.txt&amp;quot;, row.names = FALSE)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That produces a csv file that Ne04J can load using the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
LOAD CSV FROM &amp;quot;file:/NetExport.txt&amp;quot;  AS line FIELDTERMINATOR &#039;;&#039; MATCH (a:Paper),(b:Reference) WHERE a.name = line[0] AND b.name = line[1] MERGE (a)-[r:Cites]-&amp;gt;(b) RETURN r&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That loads the data into a Neo4J database, that could probably be done in one step. I will probably update this later. Next we can do things with the network in R using iGraph.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=R style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
library(igraph);&lt;br /&gt;
library(RNeo4j); #This needs to be installed with devtools to get a new enough version to interface with Neo4J&lt;br /&gt;
&lt;br /&gt;
graph = startGraph(&amp;quot;http://localhost:7474/db/data/&amp;quot;, username = &amp;quot;neo4j&amp;quot;, password= &amp;quot;Nufoa23&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
papersQuery = &amp;quot;MATCH (p:Paper) RETURN id(p) AS id, p.name AS pName, labels(p)&amp;quot;;&lt;br /&gt;
refsQuery = &amp;quot;MATCH (r:Reference) RETURN id(r) AS id, r.name AS Name, labels(r)&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
papers = cypher(graph, papersQuery)&lt;br /&gt;
colnames(papers) = c(&amp;quot;ID&amp;quot;,&amp;quot;Name&amp;quot;,&amp;quot;Type&amp;quot;)&lt;br /&gt;
references = cypher(graph, refsQuery)&lt;br /&gt;
colnames(references) = c(&amp;quot;ID&amp;quot;,&amp;quot;Name&amp;quot;,&amp;quot;Type&amp;quot;)&lt;br /&gt;
nodes = rbind(papers,references)&lt;br /&gt;
&lt;br /&gt;
#Edit the whole graph&lt;br /&gt;
wholeGraphQ = &amp;quot;MATCH (p:Paper)-[r:Cites]-&amp;gt;(s:Reference) RETURN id(p) AS pID, id(s) AS sID&amp;quot;&lt;br /&gt;
relations = cypher(graph, wholeGraphQ)&lt;br /&gt;
wG = graph.data.frame(relations,directed=TRUE,nodes)&lt;br /&gt;
#V(wG)$label.cex &amp;lt;- 0.5&lt;br /&gt;
V(wG)$color &amp;lt;- ifelse(V(wG)$Type == &amp;quot;Paper&amp;quot;, &amp;quot;lightblue&amp;quot;, &amp;quot;orange&amp;quot;)&lt;br /&gt;
V(wG)$shape &amp;lt;- ifelse(V(wG)$Type == &amp;quot;Reference&amp;quot;, &amp;quot;square&amp;quot;, &amp;quot;circle&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
area = vcount(wG)^2&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(wG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
#save the whole graph&lt;br /&gt;
pdf(&amp;quot;~/Documents/wGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(wG, layout=co, vertex.size=1, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&lt;br /&gt;
#Papers by the cited works, weighted network&lt;br /&gt;
papersByRefs = &amp;quot;MATCH path=(n:Paper)--&amp;gt;(d:Reference)&amp;lt;--(m:Paper) WHERE NOT id(n) = id(m)  AND id(n) &amp;lt; id(m) RETURN n.name AS Paper1, m.name AS Paper2, count(d) AS Weight&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pByRefRels  = cypher(graph, papersByRefs)&lt;br /&gt;
prG = graph.data.frame(pByRefRels,directed = FALSE)&lt;br /&gt;
area = vcount(prG)^2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(prG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
papByRClust = cluster_fast_greedy(prG, merges = TRUE, modularity = TRUE,&lt;br /&gt;
  membership = TRUE, weights = E(prG)$weight)&lt;br /&gt;
V(prG)$color &amp;lt;- papByRClust$membership + 1&lt;br /&gt;
&lt;br /&gt;
PapCl_out = cbind(V(prG)$name,papByRClust$membership)&lt;br /&gt;
&lt;br /&gt;
write_graph(prG, file =&amp;quot;~/Documents/PapersNet.graphml&amp;quot;, format = c(&amp;quot;graphml&amp;quot;))&lt;br /&gt;
write.csv2(cl_out, file =&amp;quot;~/Documents/PapersClusters.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#Save paper-paper graph as pdf&lt;br /&gt;
pdf(&amp;quot;~/Documents/ppGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(clusters, prG, layout=co, vertex.size=2, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&lt;br /&gt;
#build references by papers weighted&lt;br /&gt;
refsByPapers=&amp;quot;MATCH path=(r1:Reference)&amp;lt;--(p:Paper)--&amp;gt;(r2:Reference) WHERE NOT id(r1) = id(r2)  AND id(r1) &amp;lt; id(r2) RETURN r1.name AS Ref1, r2.name AS Ref2, count(p) AS Weight&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rByPapRels  = cypher(graph, refsByPapers)&lt;br /&gt;
refG = graph.data.frame(rByPapRels,directed = FALSE)&lt;br /&gt;
area = vcount(refG)^2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(refG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
refByPClust = cluster_fast_greedy(refG, merges = TRUE, modularity = TRUE,&lt;br /&gt;
  membership = TRUE, weights = E(refG)$weight)&lt;br /&gt;
V(refG)$color &amp;lt;- refByPClust$membership + 1&lt;br /&gt;
&lt;br /&gt;
RefCl_out = cbind(V(refG)$name,refByPClust$membership)&lt;br /&gt;
&lt;br /&gt;
write_graph(refG, file =&amp;quot;~/Documents/RefsNet.graphml&amp;quot;, format = c(&amp;quot;graphml&amp;quot;))&lt;br /&gt;
write.csv2(RefCl_out, file =&amp;quot;~/Documents/RefClusters.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#Save Ref-Ref graph as pdf&lt;br /&gt;
pdf(&amp;quot;~/Documents/rrGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(refG, layout=co, vertex.size=2, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=17</id>
		<title>CypherCode:LineReader</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=17"/>
		<updated>2019-12-23T11:49:26Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. It&#039;s great for building a network offline in a text file, and then you can simply run the program and it will put the data in neo4j.&lt;br /&gt;
&lt;br /&gt;
Obviously you need to provide it with the server address, and a username/password if needed. It just runs so make sure you don&#039;t send all the data to the wrong place!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=java style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
package net.prgarnett.cypherlinereader;&lt;br /&gt;
&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileNotFoundException;&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
import org.neo4j.driver.v1.AuthTokens;&lt;br /&gt;
import org.neo4j.driver.v1.Driver;&lt;br /&gt;
import org.neo4j.driver.v1.GraphDatabase;&lt;br /&gt;
import org.neo4j.driver.v1.Session;&lt;br /&gt;
import org.neo4j.driver.v1.Transaction;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author philip&lt;br /&gt;
 */&lt;br /&gt;
public class LineReader {&lt;br /&gt;
    &lt;br /&gt;
    private final Driver driver;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Load up the driver, using the address, pword, and username.&lt;br /&gt;
     * &lt;br /&gt;
     * @param serveradd&lt;br /&gt;
     * @param password&lt;br /&gt;
     * @param username &lt;br /&gt;
     */&lt;br /&gt;
    public LineReader(String serveradd, String password, String username)&lt;br /&gt;
    {&lt;br /&gt;
        this.driver = GraphDatabase.driver(serveradd, AuthTokens.basic(username, password));&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Give the method the path to the file, it will read any line that does not&lt;br /&gt;
     * start with a &#039;#&#039;.&lt;br /&gt;
     * &lt;br /&gt;
     * @param path &lt;br /&gt;
     */&lt;br /&gt;
    public void ExecuteLines(String path)&lt;br /&gt;
    {&lt;br /&gt;
        try{&lt;br /&gt;
            File targetFile = new File(path);&lt;br /&gt;
        &lt;br /&gt;
            try(Session session = driver.session())&lt;br /&gt;
            {&lt;br /&gt;
                Scanner lineScanner = new Scanner(targetFile);&lt;br /&gt;
                while(lineScanner.hasNext())&lt;br /&gt;
                {&lt;br /&gt;
                    String line = lineScanner.nextLine();&lt;br /&gt;
                    if(!line.startsWith(&amp;quot;#&amp;quot;))&lt;br /&gt;
                    {&lt;br /&gt;
                        this.processLine(line, session);&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        catch (FileNotFoundException e)&lt;br /&gt;
        {&lt;br /&gt;
            System.err.println(e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Private method that processes the line in a transaction, requires the&lt;br /&gt;
     * session to be past.&lt;br /&gt;
     * &lt;br /&gt;
     * @param line&lt;br /&gt;
     * @param session &lt;br /&gt;
     */&lt;br /&gt;
    private void processLine(String line, Session session)&lt;br /&gt;
    {&lt;br /&gt;
        try (Transaction tx = session.beginTransaction())&lt;br /&gt;
        {&lt;br /&gt;
            &lt;br /&gt;
            System.out.println(line);&lt;br /&gt;
            tx.run(line);&lt;br /&gt;
            tx.success();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Database_Tools:Neo4J&amp;diff=16</id>
		<title>Database Tools:Neo4J</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Database_Tools:Neo4J&amp;diff=16"/>
		<updated>2019-12-23T11:49:03Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Neo4J[http://www.neo4j.com] is a great graph database tool, it is really flexible and perfect for storing relationship data where objects are nodes and the relationships between the objects are the edges of the network. This allows for a scalable and flexible way of storing both data and the relationships between the data.&lt;br /&gt;
&lt;br /&gt;
I use neo4j for numerous projects storing the relationships between companies and people, and also mapping inquiries and the documents released during an inquiry, see the [[Projects]] pages. The tools will either be links/descriptions of GitHub projects, or if it really is just a little bit of code then it will be just available here.&lt;br /&gt;
&lt;br /&gt;
===Cypher Code===&lt;br /&gt;
Some bits of Cypher related code:&lt;br /&gt;
*[[CypherCode:LineReader]] - java program that reads and executes lines of cypher code.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=15</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=15"/>
		<updated>2019-12-23T11:47:54Z</updated>

		<summary type="html">&lt;p&gt;Phil: /* Philip Garnett&amp;#039;s Wiki Page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Philip Garnett&#039;s Wiki Page==&lt;br /&gt;
&lt;br /&gt;
This is a dumping ground for bits of project and bits of code etc that goes with me other sites, prgarnett.net[http://prgarnett.net], obscurus.org[http://obscurus.org], and algorithmicindexing.net[http://algorithmicindexing.net].&lt;br /&gt;
&lt;br /&gt;
Some project details:&lt;br /&gt;
*Algorithmic Indexing[http://algorithmicindexing.net] is a meta-project looking at the analysis of text using algorithms and AI to allow us to &#039;&#039;read&#039;&#039; the text. There are few sub-projects looking at public inquires and investigations.&lt;br /&gt;
*The Hillards Archive[http://thehillardsarchive.net] is a project digitising surviving documents of the Hillards supermarket chain.&lt;br /&gt;
&lt;br /&gt;
===Text Analysis===&lt;br /&gt;
A lot of the programming that I do now is around the development of text analysis tools, and tools to populate and manipulate databases, including network (e.g. Neo4J[http://www.neo4j.com]) and documents databases.&lt;br /&gt;
&lt;br /&gt;
====Databases====&lt;br /&gt;
*[[Database Tools:Neo4J]] - a few tools for working with Neo4J in different contexts or for particular use cases.&lt;br /&gt;
*[[Database Tools:MongoDB]] - a few tools for working with MongoDB.&lt;br /&gt;
&lt;br /&gt;
====Text Analysis Tools====&lt;br /&gt;
*[[Text Analysis:Ngrams]] - tools for doing ngrams analysis.&lt;br /&gt;
*[[Text Analysis:Text Processing]] - tools for things like topic modelling, entity detection, other text analysis.&lt;br /&gt;
*[[Text Analysis:Bibliometrix]] - tools processing Bibliometrix data.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=13</id>
		<title>Text Analysis:Bibliometrix</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=13"/>
		<updated>2018-09-20T17:40:27Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Page for various tools for the processing of bibliometrix data, these tools were originally developed for a project that was looking into academic communities by exploring search results from Web of Knowledge, at the time specifically Complex Thinking. Most of the tools are built in Neo4J and R. The programs build a network of papers and their cited works.&lt;br /&gt;
&lt;br /&gt;
The first bit of code that is useful is for turning data loaded from Web of Science into the R Bibliometrix package to a CSV file that is useful for then loading into &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=R style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
library(bibliometrix)&lt;br /&gt;
library(igraph)&lt;br /&gt;
library(ggplot2)&lt;br /&gt;
&lt;br /&gt;
#reads in the exported&lt;br /&gt;
D &amp;lt;- readFiles(&amp;quot;bib_export.bib&amp;quot;)&lt;br /&gt;
#convert it into a matrix&lt;br /&gt;
M &amp;lt;- convert2df(D, dbsource = &amp;quot;isi&amp;quot;, format = &amp;quot;bibtex&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#pull out the bits of the data that we want, could add more in here.&lt;br /&gt;
cited=M$CR&lt;br /&gt;
author=M$AU&lt;br /&gt;
key = M$SR&lt;br /&gt;
title = M$TI&lt;br /&gt;
data = cbind(key,title,author,cited)&lt;br /&gt;
&lt;br /&gt;
#build a data frame for the export, there must be a better way of doing this.&lt;br /&gt;
E_List &amp;lt;- NULL;&lt;br /&gt;
for(i in 1:length(data[,1])){&lt;br /&gt;
  cit_list = unlist(strsplit(data[i,4], split=&amp;quot;.   &amp;quot;))&lt;br /&gt;
  for(s in 1:length(cit_list))&lt;br /&gt;
  {&lt;br /&gt;
    E_List &amp;lt;- rbind(E_List, c(data[i,1],cit_list[s]))&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#save the data&lt;br /&gt;
write.csv2(E_List, file = &amp;quot;NetExport.txt&amp;quot;, row.names = FALSE)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That produces a csv file that Ne04J can load using the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
LOAD CSV FROM &amp;quot;file:/NetExport.txt&amp;quot;  AS line FIELDTERMINATOR &#039;;&#039; MATCH (a:Paper),(b:Reference) WHERE a.name = line[0] AND b.name = line[1] MERGE (a)-[r:Cites]-&amp;gt;(b) RETURN r&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That loads the data into a Neo4J database, that could probably be done in one step. I will probably update this later. Next we can do things with the network in R using iGraph.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=R style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
library(igraph);&lt;br /&gt;
library(RNeo4j); #This needs to be installed with devtools to get a new enough version to interface with Neo4J&lt;br /&gt;
&lt;br /&gt;
graph = startGraph(&amp;quot;http://localhost:7474/db/data/&amp;quot;, username = &amp;quot;neo4j&amp;quot;, password= &amp;quot;Nufoa23&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
papersQuery = &amp;quot;MATCH (p:Paper) RETURN id(p) AS id, p.name AS pName, labels(p)&amp;quot;;&lt;br /&gt;
refsQuery = &amp;quot;MATCH (r:Reference) RETURN id(r) AS id, r.name AS Name, labels(r)&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
papers = cypher(graph, papersQuery)&lt;br /&gt;
colnames(papers) = c(&amp;quot;ID&amp;quot;,&amp;quot;Name&amp;quot;,&amp;quot;Type&amp;quot;)&lt;br /&gt;
references = cypher(graph, refsQuery)&lt;br /&gt;
colnames(references) = c(&amp;quot;ID&amp;quot;,&amp;quot;Name&amp;quot;,&amp;quot;Type&amp;quot;)&lt;br /&gt;
nodes = rbind(papers,references)&lt;br /&gt;
&lt;br /&gt;
#Edit the whole graph&lt;br /&gt;
wholeGraphQ = &amp;quot;MATCH (p:Paper)-[r:Cites]-&amp;gt;(s:Reference) RETURN id(p) AS pID, id(s) AS sID&amp;quot;&lt;br /&gt;
relations = cypher(graph, wholeGraphQ)&lt;br /&gt;
wG = graph.data.frame(relations,directed=TRUE,nodes)&lt;br /&gt;
#V(wG)$label.cex &amp;lt;- 0.5&lt;br /&gt;
V(wG)$color &amp;lt;- ifelse(V(wG)$Type == &amp;quot;Paper&amp;quot;, &amp;quot;lightblue&amp;quot;, &amp;quot;orange&amp;quot;)&lt;br /&gt;
V(wG)$shape &amp;lt;- ifelse(V(wG)$Type == &amp;quot;Reference&amp;quot;, &amp;quot;square&amp;quot;, &amp;quot;circle&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
area = vcount(wG)^2&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(wG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
#save the whole graph&lt;br /&gt;
pdf(&amp;quot;~/Documents/wGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(wG, layout=co, vertex.size=1, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&lt;br /&gt;
#Papers by the cited works, weighted network&lt;br /&gt;
papersByRefs = &amp;quot;MATCH path=(n:Paper)--&amp;gt;(d:Reference)&amp;lt;--(m:Paper) WHERE NOT id(n) = id(m)  AND id(n) &amp;lt; id(m) RETURN n.name AS Paper1, m.name AS Paper2, count(d) AS Weight&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pByRefRels  = cypher(graph, papersByRefs)&lt;br /&gt;
prG = graph.data.frame(pByRefRels,directed = FALSE)&lt;br /&gt;
area = vcount(prG)^2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(prG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
papByRClust = cluster_fast_greedy(prG, merges = TRUE, modularity = TRUE,&lt;br /&gt;
  membership = TRUE, weights = E(prG)$weight)&lt;br /&gt;
V(prG)$color &amp;lt;- papByRClust$membership + 1&lt;br /&gt;
&lt;br /&gt;
PapCl_out = cbind(V(prG)$name,papByRClust$membership)&lt;br /&gt;
&lt;br /&gt;
write_graph(prG, file =&amp;quot;~/Documents/PapersNet.graphml&amp;quot;, format = c(&amp;quot;graphml&amp;quot;))&lt;br /&gt;
write.csv2(cl_out, file =&amp;quot;~/Documents/PapersClusters.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#Save paper-paper graph as pdf&lt;br /&gt;
pdf(&amp;quot;~/Documents/ppGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(clusters, prG, layout=co, vertex.size=2, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&lt;br /&gt;
#build references by papers weighted&lt;br /&gt;
refsByPapers=&amp;quot;MATCH path=(r1:Reference)&amp;lt;--(p:Paper)--&amp;gt;(r2:Reference) WHERE NOT id(r1) = id(r2)  AND id(r1) &amp;lt; id(r2) RETURN r1.name AS Ref1, r2.name AS Ref2, count(p) AS Weight&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rByPapRels  = cypher(graph, refsByPapers)&lt;br /&gt;
refG = graph.data.frame(rByPapRels,directed = FALSE)&lt;br /&gt;
area = vcount(refG)^2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(refG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
refByPClust = cluster_fast_greedy(refG, merges = TRUE, modularity = TRUE,&lt;br /&gt;
  membership = TRUE, weights = E(refG)$weight)&lt;br /&gt;
V(refG)$color &amp;lt;- refByPClust$membership + 1&lt;br /&gt;
&lt;br /&gt;
RefCl_out = cbind(V(refG)$name,refByPClust$membership)&lt;br /&gt;
&lt;br /&gt;
write_graph(refG, file =&amp;quot;~/Documents/RefsNet.graphml&amp;quot;, format = c(&amp;quot;graphml&amp;quot;))&lt;br /&gt;
write.csv2(RefCl_out, file =&amp;quot;~/Documents/RefClusters.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#Save Ref-Ref graph as pdf&lt;br /&gt;
pdf(&amp;quot;~/Documents/rrGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(refG, layout=co, vertex.size=2, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=12</id>
		<title>Text Analysis:Bibliometrix</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=12"/>
		<updated>2018-09-20T17:32:16Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Page for various tools for the processing of bibliometrix data, these tools were originally developed for a project that was looking into academic communities by exploring search results from Web of Knowledge, at the time specifically Complex Thinking. Most of the tools are built in Neo4J and R. The programs build a network of papers and their cited works.&lt;br /&gt;
&lt;br /&gt;
The first bit of code that is useful is for turning data loaded from Web of Science into the R Bibliometrix package to a CSV file that is useful for then loading into &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=R style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
library(bibliometrix)&lt;br /&gt;
library(igraph)&lt;br /&gt;
library(ggplot2)&lt;br /&gt;
&lt;br /&gt;
#reads in the exported&lt;br /&gt;
D &amp;lt;- readFiles(&amp;quot;bib_export.bib&amp;quot;)&lt;br /&gt;
#convert it into a matrix&lt;br /&gt;
M &amp;lt;- convert2df(D, dbsource = &amp;quot;isi&amp;quot;, format = &amp;quot;bibtex&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#pull out the bits of the data that we want, could add more in here.&lt;br /&gt;
cited=M$CR&lt;br /&gt;
author=M$AU&lt;br /&gt;
key = M$SR&lt;br /&gt;
title = M$TI&lt;br /&gt;
data = cbind(key,title,author,cited)&lt;br /&gt;
&lt;br /&gt;
#build a data frame for the export, there must be a better way of doing this.&lt;br /&gt;
E_List &amp;lt;- NULL;&lt;br /&gt;
for(i in 1:length(data[,1])){&lt;br /&gt;
  cit_list = unlist(strsplit(data[i,4], split=&amp;quot;.   &amp;quot;))&lt;br /&gt;
  for(s in 1:length(cit_list))&lt;br /&gt;
  {&lt;br /&gt;
    E_List &amp;lt;- rbind(E_List, c(data[i,1],cit_list[s]))&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#save the data&lt;br /&gt;
write.csv2(E_List, file = &amp;quot;NetExport.txt&amp;quot;, row.names = FALSE)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That produces a csv file that Ne04J can load using the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
LOAD CSV FROM &amp;quot;file:/NetExport.txt&amp;quot;  AS line FIELDTERMINATOR &#039;;&#039; MATCH (a:Paper),(b:Reference) WHERE a.name = line[0] AND b.name = line[1] MERGE (a)-[r:Cites]-&amp;gt;(b) RETURN r&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That loads the data into a Neo4J database, that could probably be done in one step. I will probably update this later. Next we can do things with the network in R using iGraph.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=R style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
library(igraph);&lt;br /&gt;
library(RNeo4j); #This needs to be installed with devtools to get a new enough version to interface with Neo4J&lt;br /&gt;
&lt;br /&gt;
graph = startGraph(&amp;quot;http://localhost:7474/db/data/&amp;quot;, username = &amp;quot;neo4j&amp;quot;, password= &amp;quot;Nufoa23&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
papersQuery = &amp;quot;MATCH (p:Paper) RETURN id(p) AS id, p.name AS pName, labels(p)&amp;quot;;&lt;br /&gt;
refsQuery = &amp;quot;MATCH (r:Reference) RETURN id(r) AS id, r.name AS Name, labels(r)&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
papers = cypher(graph, papersQuery)&lt;br /&gt;
colnames(papers) = c(&amp;quot;ID&amp;quot;,&amp;quot;Name&amp;quot;,&amp;quot;Type&amp;quot;)&lt;br /&gt;
references = cypher(graph, refsQuery)&lt;br /&gt;
colnames(references) = c(&amp;quot;ID&amp;quot;,&amp;quot;Name&amp;quot;,&amp;quot;Type&amp;quot;)&lt;br /&gt;
nodes = rbind(papers,references)&lt;br /&gt;
&lt;br /&gt;
#Edit the whole graph&lt;br /&gt;
wholeGraphQ = &amp;quot;MATCH (p:Paper)-[r:Cites]-&amp;gt;(s:Reference) RETURN id(p) AS pID, id(s) AS sID&amp;quot;&lt;br /&gt;
relations = cypher(graph, wholeGraphQ)&lt;br /&gt;
wG = graph.data.frame(relations,directed=TRUE,nodes)&lt;br /&gt;
#V(wG)$label.cex &amp;lt;- 0.5&lt;br /&gt;
V(wG)$color &amp;lt;- ifelse(V(wG)$Type == &amp;quot;Paper&amp;quot;, &amp;quot;lightblue&amp;quot;, &amp;quot;orange&amp;quot;)&lt;br /&gt;
V(wG)$shape &amp;lt;- ifelse(V(wG)$Type == &amp;quot;Reference&amp;quot;, &amp;quot;square&amp;quot;, &amp;quot;circle&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
area = vcount(wG)^2&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(wG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
#save the whole graph&lt;br /&gt;
pdf(&amp;quot;~/Documents/wGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(wG, layout=co, vertex.size=1, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&lt;br /&gt;
#Papers by the cited works, weighted network&lt;br /&gt;
papersByRefs = &amp;quot;MATCH path=(n:Paper)--&amp;gt;(d:Reference)&amp;lt;--(m:Paper) WHERE NOT id(n) = id(m)  AND id(n) &amp;lt; id(m) RETURN n.name AS Paper1, m.name AS Paper2, count(d) AS Weight&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pByRefRels  = cypher(graph, papersByRefs)&lt;br /&gt;
prG = graph.data.frame(pByRefRels,directed = FALSE)&lt;br /&gt;
area = vcount(prG)^2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(prG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
papByRClust = cluster_fast_greedy(prG, merges = TRUE, modularity = TRUE,&lt;br /&gt;
  membership = TRUE, weights = E(prG)$weight)&lt;br /&gt;
V(prG)$color &amp;lt;- papByRClust$membership + 1&lt;br /&gt;
&lt;br /&gt;
PapCl_out = cbind(V(prG)$name,papByRClust$membership)&lt;br /&gt;
&lt;br /&gt;
write_graph(prG, file =&amp;quot;~/Documents/PapersNet.graphml&amp;quot;, format = c(&amp;quot;graphml&amp;quot;))&lt;br /&gt;
write.csv2(cl_out, file =&amp;quot;~/Documents/PapersClusters.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#Save paper-paper graph as pdf&lt;br /&gt;
pdf(&amp;quot;~/Documents/ppGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(clusters, prG, layout=co, vertex.size=2, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&lt;br /&gt;
#build references by papers weighted&lt;br /&gt;
refsByPapers=&amp;quot;MATCH path=(r1:Reference)&amp;lt;--(p:Paper)--&amp;gt;(r2:Reference) WHERE NOT id(r1) = id(r2)  AND id(r1) &amp;lt; id(r2) RETURN r1.name AS Ref1, r2.name AS Ref2, count(p) AS Weight&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rByPapRels  = cypher(graph, refsByPapers)&lt;br /&gt;
refG = graph.data.frame(rByPapRels,directed = FALSE)&lt;br /&gt;
area = vcount(refG)^2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
co &amp;lt;- layout_with_fr(refG, grid=c(&amp;quot;nogrid&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
refByPClust = cluster_fast_greedy(refG, merges = TRUE, modularity = TRUE,&lt;br /&gt;
  membership = TRUE, weights = E(refG)$weight)&lt;br /&gt;
V(refG)$color &amp;lt;- refByPClust$membership + 1&lt;br /&gt;
&lt;br /&gt;
RefCl_out = cbind(V(refG)$name,refByPClust$membership)&lt;br /&gt;
&lt;br /&gt;
write_graph(refG, file =&amp;quot;~/Documents/RefsNet.graphml&amp;quot;, format = c(&amp;quot;graphml&amp;quot;))&lt;br /&gt;
write.csv2(RefCl_out, file =&amp;quot;~/Documents/RefClusters.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#Save Ref-Ref graph as pdf&lt;br /&gt;
pdf(&amp;quot;~/Documents/rrGraph.pdf&amp;quot;,10,10)&lt;br /&gt;
plot(refG, layout=co, vertex.size=2, edge.arrow.size=0.3, vertex.label=&amp;quot;&amp;quot;)&lt;br /&gt;
dev.off()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=11</id>
		<title>Text Analysis:Bibliometrix</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Text_Analysis:Bibliometrix&amp;diff=11"/>
		<updated>2018-09-20T17:12:29Z</updated>

		<summary type="html">&lt;p&gt;Phil: Created page with &amp;quot;Page for various tools for the processing of bibliometrix data, these tools were originally developed for a project that was looking into academic communities by exploring sea...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Page for various tools for the processing of bibliometrix data, these tools were originally developed for a project that was looking into academic communities by exploring search results from Web of Knowledge, at the time specifically Complex Thinking. Most of the tools are built in Neo4J and R.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=10</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=10"/>
		<updated>2018-09-20T17:05:29Z</updated>

		<summary type="html">&lt;p&gt;Phil: /* Philip Garnett&amp;#039;s Wiki Page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Philip Garnett&#039;s Wiki Page==&lt;br /&gt;
&lt;br /&gt;
This is a dumping ground for bits of project and bits of code etc that goes with me other sites, prgarnett.net[http://prgarnett.net], obscurus.org[http://obscurus.org], and algorithmicindexing.net[http://algorithmicindexing.net].&lt;br /&gt;
&lt;br /&gt;
Some project details:&lt;br /&gt;
*Algorithmic Indexing[http://algorithmicindexing.net] is a meta-project looking at the analysis of text using algorithms and AI to allow us to &#039;&#039;read&#039;&#039; the text. There are few sub-projects looking at public inquires and investigations.&lt;br /&gt;
*The Hillards Archive is a project deigitising surviving documents of the Hillards supermarket chain [http://thehillardsarchive.net].&lt;br /&gt;
&lt;br /&gt;
===Text Analysis===&lt;br /&gt;
A lot of the programming that I do now is around the developement of text analysis tools, and tools to populate and manuiplate databases, including network (e.g. Neo4J[http://www.neo4j.com]) and documents databases.&lt;br /&gt;
&lt;br /&gt;
====Databases====&lt;br /&gt;
*[[Database Tools:Neo4J]] - a few tools for working with Neo4J in different contexts or for particular use cases.&lt;br /&gt;
*[[Database Tools:MongoDB]] - a few tools for working with MongoDB.&lt;br /&gt;
&lt;br /&gt;
====Text Analysis Tools====&lt;br /&gt;
*[[Text Analysis:Ngrams]] - tools for doing ngrams analysis.&lt;br /&gt;
*[[Text Analysis:Text Processing]] - tools for things like topic modelling, entity detection, other text analysis.&lt;br /&gt;
*[[Text Analysis:Bibliometrix]] - tools processing Bibliometrix data.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=9</id>
		<title>CypherCode:LineReader</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=9"/>
		<updated>2017-12-07T21:06:17Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. Its great for building a network offline in a text file, and then you can simply run the program and it will put the data in neo4j.&lt;br /&gt;
&lt;br /&gt;
Obviously you need to provide it with the server address, and a username/password if needed. It just runs so make sure you don&#039;t send all the data to the wrong place!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=java style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
package net.prgarnett.cypherlinereader;&lt;br /&gt;
&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileNotFoundException;&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
import org.neo4j.driver.v1.AuthTokens;&lt;br /&gt;
import org.neo4j.driver.v1.Driver;&lt;br /&gt;
import org.neo4j.driver.v1.GraphDatabase;&lt;br /&gt;
import org.neo4j.driver.v1.Session;&lt;br /&gt;
import org.neo4j.driver.v1.Transaction;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author philip&lt;br /&gt;
 */&lt;br /&gt;
public class LineReader {&lt;br /&gt;
    &lt;br /&gt;
    private final Driver driver;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Load up the driver, using the address, pword, and username.&lt;br /&gt;
     * &lt;br /&gt;
     * @param serveradd&lt;br /&gt;
     * @param password&lt;br /&gt;
     * @param username &lt;br /&gt;
     */&lt;br /&gt;
    public LineReader(String serveradd, String password, String username)&lt;br /&gt;
    {&lt;br /&gt;
        this.driver = GraphDatabase.driver(serveradd, AuthTokens.basic(username, password));&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Give the method the path to the file, it will read any line that does not&lt;br /&gt;
     * start with a &#039;#&#039;.&lt;br /&gt;
     * &lt;br /&gt;
     * @param path &lt;br /&gt;
     */&lt;br /&gt;
    public void ExecuteLines(String path)&lt;br /&gt;
    {&lt;br /&gt;
        try{&lt;br /&gt;
            File targetFile = new File(path);&lt;br /&gt;
        &lt;br /&gt;
            try(Session session = driver.session())&lt;br /&gt;
            {&lt;br /&gt;
                Scanner lineScanner = new Scanner(targetFile);&lt;br /&gt;
                while(lineScanner.hasNext())&lt;br /&gt;
                {&lt;br /&gt;
                    String line = lineScanner.nextLine();&lt;br /&gt;
                    if(!line.startsWith(&amp;quot;#&amp;quot;))&lt;br /&gt;
                    {&lt;br /&gt;
                        this.processLine(line, session);&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        catch (FileNotFoundException e)&lt;br /&gt;
        {&lt;br /&gt;
            System.err.println(e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Private method that processes the line in a transaction, requires the&lt;br /&gt;
     * session to be past.&lt;br /&gt;
     * &lt;br /&gt;
     * @param line&lt;br /&gt;
     * @param session &lt;br /&gt;
     */&lt;br /&gt;
    private void processLine(String line, Session session)&lt;br /&gt;
    {&lt;br /&gt;
        try (Transaction tx = session.beginTransaction())&lt;br /&gt;
        {&lt;br /&gt;
            &lt;br /&gt;
            System.out.println(line);&lt;br /&gt;
            tx.run(line);&lt;br /&gt;
            tx.success();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=8</id>
		<title>CypherCode:LineReader</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=8"/>
		<updated>2017-12-07T14:03:51Z</updated>

		<summary type="html">&lt;p&gt;Phil: Created page with &amp;quot;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. Its great for...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. Its great for building a network offline in a text file, and then you can simply run the program and it will put the data in neo4j.&lt;br /&gt;
&lt;br /&gt;
Obviously you need to provide it with the server address, and a username/password if needed. It just runs so make sure you don&#039;t send all the data to the wrong place!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=java style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
package net.prgarnett.cypherlinereader;&lt;br /&gt;
&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileNotFoundException;&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
import org.neo4j.driver.v1.AuthTokens;&lt;br /&gt;
import org.neo4j.driver.v1.Driver;&lt;br /&gt;
import org.neo4j.driver.v1.GraphDatabase;&lt;br /&gt;
import org.neo4j.driver.v1.Session;&lt;br /&gt;
import org.neo4j.driver.v1.Transaction;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author philip&lt;br /&gt;
 */&lt;br /&gt;
public class LineReader {&lt;br /&gt;
    &lt;br /&gt;
    private final Driver driver;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Load up the driver, using the address, pword, and username.&lt;br /&gt;
     * &lt;br /&gt;
     * @param serveradd&lt;br /&gt;
     * @param password&lt;br /&gt;
     * @param username &lt;br /&gt;
     */&lt;br /&gt;
    public LineReader(String serveradd, String password, String username)&lt;br /&gt;
    {&lt;br /&gt;
        this.driver = GraphDatabase.driver(serveradd, AuthTokens.basic(username, password));&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Give the method the path to the file, it will read any line that does not&lt;br /&gt;
     * start with a &#039;#&#039;.&lt;br /&gt;
     * &lt;br /&gt;
     * @param path &lt;br /&gt;
     */&lt;br /&gt;
    public void ExecuteLines(String path)&lt;br /&gt;
    {&lt;br /&gt;
        try{&lt;br /&gt;
            File targetFile = new File(path);&lt;br /&gt;
        &lt;br /&gt;
            try(Session session = driver.session())&lt;br /&gt;
            {&lt;br /&gt;
                Scanner lineScanner = new Scanner(targetFile);&lt;br /&gt;
                while(lineScanner.hasNext())&lt;br /&gt;
                {&lt;br /&gt;
                    String line = lineScanner.nextLine();&lt;br /&gt;
                    if(!line.startsWith(&amp;quot;#&amp;quot;))&lt;br /&gt;
                    {&lt;br /&gt;
                        this.processLine(line, session);&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        catch (FileNotFoundException e)&lt;br /&gt;
        {&lt;br /&gt;
            System.err.println(e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Private method that processes the line in a transaction, requires the&lt;br /&gt;
     * session to be past.&lt;br /&gt;
     * &lt;br /&gt;
     * @param line&lt;br /&gt;
     * @param session &lt;br /&gt;
     */&lt;br /&gt;
    private void processLine(String line, Session session)&lt;br /&gt;
    {&lt;br /&gt;
        try (Transaction tx = session.beginTransaction())&lt;br /&gt;
        {&lt;br /&gt;
            tx.run(line);&lt;br /&gt;
            tx.success();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Database_Tools:Neo4J&amp;diff=7</id>
		<title>Database Tools:Neo4J</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Database_Tools:Neo4J&amp;diff=7"/>
		<updated>2017-12-07T11:44:13Z</updated>

		<summary type="html">&lt;p&gt;Phil: Created page with &amp;quot;Neo4J[http://www.neo4j.com] is a great graph database tool, it is really flexible and perfect for storing relationship data where objects are nodes and the relationships betwe...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Neo4J[http://www.neo4j.com] is a great graph database tool, it is really flexible and perfect for storing relationship data where objects are nodes and the relationships between the objects are the edges of the network. This allows for a scalable and flexible way of storing both data and the relationships between the data.&lt;br /&gt;
&lt;br /&gt;
I use neo4j for numerous projects storing the relationships between companies and people, and also mapping inquiries and the documents released during an inquiry, see the [[Projects]] pages. The tools will either be links/descriptions of GitHub projects, or if it really is just a little bit of code then it will be just available here.&lt;br /&gt;
&lt;br /&gt;
===Cypher Code===&lt;br /&gt;
Some bits of Cypher related code:&lt;br /&gt;
*[[CypherCode:LineReader]] - java program that reads and excutes lines of cypher code.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=6</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=6"/>
		<updated>2017-12-07T11:28:14Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Philip Garnett&#039;s Wiki Page==&lt;br /&gt;
&lt;br /&gt;
This is a dumping ground for bits of project and bits of code etc that goes with me other sites, prgarnett.net[http://prgarnett.net], obscurus.org[http://obscurus.org], and algorithmicindexing.net[http://algorithmicindexing.net].&lt;br /&gt;
&lt;br /&gt;
Some project details:&lt;br /&gt;
*Algorithmic Indexing[http://algorithmicindexing.net] is a meta-project looking at the analysis of text using algorithms and AI to allow us to &#039;&#039;read&#039;&#039; the text. There are few sub-projects looking at public inquires and investigations.&lt;br /&gt;
*The Hillards Archive is a project deigitising surviving documents of the Hillards supermarket chain [http://thehillardsarchive.net].&lt;br /&gt;
&lt;br /&gt;
===Text Analysis===&lt;br /&gt;
A lot of the programming that I do now is around the developement of text analysis tools, and tools to populate and manuiplate databases, including network (e.g. Neo4J[http://www.neo4j.com]) and documents databases.&lt;br /&gt;
&lt;br /&gt;
====Databases====&lt;br /&gt;
*[[Database Tools:Neo4J]] - a few tools for working with Neo4J in different contexts or for particular use cases.&lt;br /&gt;
*[[Database Tools:MongoDB]] - a few tools for working with MongoDB.&lt;br /&gt;
&lt;br /&gt;
====Text Analysis Tools====&lt;br /&gt;
*[[Text Analysis:Ngrams]] - tools for doing ngrams analysis.&lt;br /&gt;
*[[Text Analysis:Text Processing]] - tools for things like topic modelling, entity detection, other text analysis.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=5</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=5"/>
		<updated>2017-12-07T11:23:22Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Philip Garnett&#039;s Wiki Page==&lt;br /&gt;
&lt;br /&gt;
This is a dumping ground for bits of project and bits of code etc that goes with me other sites, prgarnett.net[http://prgarnett.net], obscurus.org[http://obscurus.org], and algorithmicindexing.net[http://algorithmicindexing.net].&lt;br /&gt;
&lt;br /&gt;
Some project details:&lt;br /&gt;
*Algorithmic Indexing[http://algorithmicindexing.net] is a meta-project looking at the analysis of text using algorithms and AI to allow us to &#039;&#039;read&#039;&#039; the text. There are few sub-projects looking at public inquires and investigations.&lt;br /&gt;
*The Hillards Archive is a project deigitising surviving documents of the Hillards supermarket chain [http://thehillardsarchive.net].&lt;br /&gt;
&lt;br /&gt;
===Text Analysis===&lt;br /&gt;
A lot of the programming that I do now is around the developement of text analysis tools, and tools to populate and manuiplate databases, including network (e.g. Neo4J[http://www.neo4j.com]) and documents databases.&lt;br /&gt;
&lt;br /&gt;
====Databases====&lt;br /&gt;
[[Database Tools:Neo4J]] - a few tools for working with Neo4J in different contexts or for particular use cases. &amp;lt;br /&amp;gt;&lt;br /&gt;
[[Database Tools:MongoDB]] - a few tools for working with MongoDB.&lt;br /&gt;
&lt;br /&gt;
====Text Analysis Tools====&lt;br /&gt;
[[Text Analysis:Ngrams]] - tools for doing ngrams analysis. &amp;lt;br /&amp;gt;&lt;br /&gt;
[[Text Analysis:Text Processing]] - tools for things like topic modelling, entity detection, other text analysis.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=4</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=Main_Page&amp;diff=4"/>
		<updated>2017-12-07T11:15:33Z</updated>

		<summary type="html">&lt;p&gt;Phil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Philip Garnett&#039;s Wiki Page==&lt;br /&gt;
&lt;br /&gt;
This is a dumping ground for bits of project and bits of code etc that goes with me other sites, prgarnett.net[http://prgarnett.net], obscurus.org[http://obscurus.org], and algorithmicindexing.net[http://algorithmicindexing.net].&lt;br /&gt;
&lt;br /&gt;
Some project details:&lt;br /&gt;
*Algorithmic Indexing[http://algorithmicindexing.net] is a meta-project looking at the analysis of text using algorithms and AI to allow us to &#039;&#039;read&#039;&#039; the text. There are few sub-projects looking at public inquires and investigations.&lt;br /&gt;
*The Hillards Archive is a project deigitising surviving documents of the Hillards supermarket chain [http://thehillardsarchive.net].&lt;br /&gt;
&lt;br /&gt;
===Text Analysis===&lt;br /&gt;
A lot of the programming that I do now is around the developement of text analysis tools, and tools to populate and manuiplate databases, including network (e.g. Neo4J[http://www.neo4j.com]) and documents databases.&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
</feed>