buildo / benderama Goto Github PK
View Code? Open in Web Editor NEWunattractive giant monster
License: MIT License
unattractive giant monster
License: MIT License
As a developer I would like to use benderama on sets of tables, so that the constraints between tables are satisfied.
For instance, if table A
has a foreign key b
on the table B
, benderama should generate a row for table A
having column b
that exists in table B
.
Extend benderama to work with sets of tables linked by constraints.
Interface proposal
object Main extends App {
import G._
// data taken from a table
val data = Map(("col1", "int") -> List(1,2,3,2,2,3,1,5,0), ("col2", "string") -> List("hi", "man", "hi", "hi"))
// create a model for the given dataset
val dataModel: M = model(data)
//samplers are used to specify how to convert parts of the model to values
//defaults sampler will be defined - and output value will be randomized :D
implicit def intSampler: IntModel => Int = (i: IntModel) => i.mu.toInt
implicit def strSampler: StringModel => String = (i: StringModel) =>
i.wordsFrequency.filter(_._2 == i.wordsFrequency.valuesIterator.max).head._1
//sample is used to sample one row from the model
val res: List[_] = dataModel.sample
println(res)
}
object G {
//we can add an optional list of pairs (columnName, model) that are matched by columnName
//this would add some flexibility
def model(m: Map[(String, String), List[_]]): M = new M(
m.map { c =>
val (column, values) = c
column._2 match {
case "int" => buildIntModel(values)
case "string" => buildStringModel(values)
case _ => throw new Exception("aaa")
}
} toList
)
private[this] def buildIntModel(values: List[_]): Mi = {
val intValues = values.asInstanceOf[List[Int]]
val avg: Double = intValues.sum / intValues.length.toDouble
val std: Double = math.sqrt(intValues.foldLeft(0.0){ case (k, v) => k + math.pow(v - avg, 2.0) })
new IntModel(avg, std)
}
private[this] def buildStringModel(values: List[_]): Mi = {
val stringValues = values.asInstanceOf[List[String]]
new StringModel(stringValues.groupBy(w => w).mapValues(_.length))
}
}
trait Mi
class IntModel(val mu: Double, std: Double) extends Mi
class StringModel(val wordsFrequency: Map[String, Int]) extends Mi
class M(models: List[Mi]) {
def sample(implicit
intSampler: IntModel => Int,
stringSampler: StringModel => String
): List[_] = models.map { a => a match {
case m: IntModel => m: Int
case m: StringModel => m: String
}}
}
Deal with nullable columns
This R&D project has been discontinued as, for the foreseeable future, it will be useful only for one project...
To kill it completely we should:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.