DAMA-UPC / Babel

A DSL for DataSynth Graph Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Babel: A domain specific language for graph generation

Build Status Codacy Badge Codacy Badge

running-example

Add dependency:

https://bintray.com/dama-upc/Babel-Platform/babel

If using the SBT tool:

Add the following snippet to the build.sbt file:

resolvers += "maven" at "https://dl.bintray.com/dama-upc/Babel-Platform"
libraryDependencies += "edu.upc.dama" %% "babel" % "0.4.1"
addCompilerPlugin("org.scalameta" % "paradise" % "3.0.0-M11" cross CrossVersion.full)

Definition of node models

import babel._
import java.time.LocalDate

@node class Actor(name: String,
                  gender: Option[String],
                  country: String,
                  birthDate: LocalDate)
import babel._

@node class Movie(director: String,
                  title: String,
                  releaseDate: LocalDate,
                  country: String,
                  budgetInUSDollars: Option[Double])

Definition of Edge models

import babel._
import java.time.LocalDate

@edge
class Portrayed(characterName: String)

### Property generators definition

import babel._

object ActorBirthDateGenerator extends PropertyGenerator[LocalDate] {

  override def run(id: Id,
                   r: (Id) => Long,
                   dependencies: Any*): LocalDate =
    LocalDateGenerator.nextLocalDate(
      hash = r(id),
      min = NOW().minusYears(90),
      max = NOW(),
      distribution = Distribution.Uniform
    )
}

Defining graph structure generators.

For defining graph structure generators, we need to implement the following interface:

trait GraphStructureGenerator[T] {
  val run(n: Long): T
  val getNumberNodes(numberEdges: Long): Long
}

About

A DSL for DataSynth Graph Generator


Languages

Language:Scala 100.0%