-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export graphs and vertices as csv #1
- Loading branch information
Showing
11 changed files
with
192 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
#!/bin/sh | ||
|
||
java -Xmx80g -jar graphlod-0.1.jar --excludedNamespaces \ | ||
java -Xmx80g -jar graphlod-0.1.jar --name drugbank --excludedNamespaces \ | ||
"http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugtype/" \ | ||
"http://www4.wiwiss.fu-berlin.de/drugbank/resource/references/" \ | ||
--skipChromatic \ | ||
--namespace "http://www4.wiwiss.fu-berlin.de/drugbank/" \ | ||
/data/graphlod/drugbank/drugbank.nt | tee drugbank.txt | ||
|
||
java -Xmx80g -jar graphlod-0.1.jar --skipChromatic \ | ||
java -Xmx80g -jar graphlod-0.1.jar --name dailymed --skipChromatic \ | ||
--namespace "http://www4.wiwiss.fu-berlin.de/dailymed/" \ | ||
/data/graphlod/dailymed/dailymed_dump.nt | tee dailymed_dump.txt | ||
|
||
java -Xmx80g -jar graphlod-0.1.jar --skipChromatic --excludedNamespaces \ | ||
java -Xmx80g -jar graphlod-0.1.jar --name diseasome --skipChromatic --excludedNamespaces \ | ||
"http://www4.wiwiss.fu-berlin.de/diseasome/resource/diseaseClass/" \ | ||
--namespace "http://www4.wiwiss.fu-berlin.de/diseasome/" \ | ||
/data/graphlod/diseasome/diseasome.nt | tee diseasome.txt | ||
|
||
java -Xmx80g -jar graphlod-0.1.jar --skipChromatic \ | ||
java -Xmx80g -jar graphlod-0.1.jar --name dbpedia_person --skipChromatic \ | ||
--namespace "http://dbpedia.org/resource" \ | ||
/data/graphlod/dbpedia/persondata_en.nt | tee dbpedia_persondata.txt | ||
|
||
java -Xmx80g -jar graphlod-0.1.jar --skipChromatic \ | ||
java -Xmx80g -jar graphlod-0.1.jar --name dbpedia_geo_coordinate --skipChromatic \ | ||
--namespace "http://dbpedia.org/resource" \ | ||
/data/graphlod/dbpedia/geo_coordinates_en.nt | tee geo_coordinate.txt | ||
|
||
java -Xmx80g -jar graphlod-0.1.jar --skipChromatic \ | ||
java -Xmx80g -jar graphlod-0.1.jar --name dbpedia_homepages --skipChromatic \ | ||
--namespace "http://dbpedia.org/resource" \ | ||
/data/graphlod/dbpedia/homepages_en.nt | tee dbpedia_homepages.txt | ||
|
||
# fix mapping: sed 's/"\.$/" \./' mappingbased_properties_en.nt > mappingbased_properties_en_fixed.nt | ||
|
||
java -Xmx100g -jar graphlod-0.1.jar --skipChromatic \ | ||
java -Xmx100g -jar graphlod-0.1.jar --name dbpedia_mapping --skipChromatic \ | ||
--namespace "http://dbpedia.org/resource" \ | ||
mappingbased_properties_en_fixed.nt | tee dbpedia_mapping.txt | ||
|
||
java -Xmx80g -jar graphlod-0.1.jar --skipChromatic \ | ||
java -Xmx80g -jar graphlod-0.1.jar --name linkedgeodata --skipChromatic \ | ||
/data/graphlod/linkedgeodata/2013-04-29-{Ae*,C*,E*,Mili*,H*,P*,S*,T*} \ | ||
--namespace "http://linkedgeodata.org/" \ | ||
| tee linkedgeodata.txt | ||
|
||
zip result.txt *.txt *.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package graphlod; | ||
|
||
|
||
import java.io.IOException; | ||
import java.io.Writer; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.apache.commons.csv.CSVFormat; | ||
import org.apache.commons.csv.CSVPrinter; | ||
|
||
import com.google.common.base.Charsets; | ||
import com.google.common.base.Verify; | ||
|
||
public class GraphCsvOutput { | ||
|
||
private final CSVPrinter writer; | ||
private final int maxSizeForDiameter; | ||
|
||
public GraphCsvOutput(String name, int maxSizeForDiameter) { | ||
this.maxSizeForDiameter = maxSizeForDiameter; | ||
Writer out; | ||
try { | ||
Path path = Paths.get(name + "_graphs.csv"); | ||
out = Files.newBufferedWriter(path, Charsets.UTF_8); | ||
writer = CSVFormat.DEFAULT.withHeader("graph", "vertices", "edges", "diameter", "avgindegree", "maxindegree", "avgoutdegree", "maxoutdegree").print(out); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public void writeGraph(GraphFeatures graph) { | ||
double diameter = graph.getVertexCount() < maxSizeForDiameter ? graph.getDiameter() : -1; | ||
try { | ||
writer.printRecord(graph.getId(), graph.getVertexCount(), graph.getEdgeCount(), diameter, | ||
CollectionUtils.average(graph.getIndegrees()), CollectionUtils.max(graph.getIndegrees()), | ||
CollectionUtils.average(graph.getOutdegrees()), CollectionUtils.max(graph.getOutdegrees())); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
public void close() { | ||
try { | ||
writer.close(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package graphlod; | ||
|
||
|
||
import java.io.IOException; | ||
import java.io.Writer; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
import org.apache.commons.csv.CSVFormat; | ||
import org.apache.commons.csv.CSVPrinter; | ||
|
||
import com.google.common.base.Charsets; | ||
import com.google.common.base.Verify; | ||
|
||
public class VertexCsvOutput { | ||
|
||
CSVPrinter writer; | ||
|
||
public VertexCsvOutput(String name) { | ||
Writer out; | ||
try { | ||
Path path = Paths.get(name + "_vertices.csv"); | ||
out = Files.newBufferedWriter(path, Charsets.UTF_8); | ||
writer = CSVFormat.DEFAULT.withHeader("graph", "vertex", "indegree", "outdegree").print(out); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public void writeGraph(GraphFeatures graph) { | ||
List<GraphFeatures.Degree> inDegrees = graph.getIndegrees2(); | ||
List<GraphFeatures.Degree> outDegrees = graph.getIndegrees2(); | ||
|
||
for (int i = 0; i < inDegrees.size(); i++) { | ||
GraphFeatures.Degree in = inDegrees.get(i); | ||
GraphFeatures.Degree out = outDegrees.get(i); | ||
Verify.verify(in.vertex.equals(out.vertex)); | ||
try { | ||
writer.printRecord(graph.getId(), in.vertex, in.degree, out.degree); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
public void close() { | ||
try { | ||
writer.close(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.