Skip to content

Commit

Permalink
[#3] Creating save function to Linked Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Peres committed May 15, 2019
1 parent 3ebc588 commit 92e6dc6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package br.ufc.insightlab.linkedgraphast.model.graph

import java.io.{File, PrintWriter}
import java.lang
import java.util.stream.StreamSupport

Expand Down Expand Up @@ -245,4 +246,18 @@ class LinkedGraph(structure: GraphStructure = new DefaultGraphStructure()) exten
}
.mkString("\n")

def save(filePath: String): Unit = {
val wr = new PrintWriter(new File("extracted-schema.nt"))

this.getLinksAsStream
.foreach{
case Attribute(s,p,o) =>
wr.write(s"<${s.uri}> <${p.uri}> ${fixLiteralString(o.value)} .\n")
case Relation(s,p,o) =>
wr.write(s"<${s.uri}> <${p.uri}> <${o.uri}> .\n")
}

wr.close()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory

import scala.collection.JavaConverters._
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global

import scala.concurrent.duration.Duration
import scala.util.{Failure, Success, Try}

Expand Down Expand Up @@ -221,8 +221,7 @@ object VirtuosoSchemaExtractor {
println(graph.getNumberOfNodes)
println(graph.getNumberOfEdges)

val wr = new PrintWriter(new File("extracted-schema.nt"))
wr.write(graph.toNTriple)
graph.save("dbpedia-extracted.nt")
}


Expand Down

0 comments on commit 92e6dc6

Please sign in to comment.