Coder Social home page Coder Social logo

random-data's People

Contributors

muzea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

random-data's Issues

generator 生成器类型

指定一个表达式来生成一个数据

这个类型引入了本地变量的概念,refprevindex,在这里会成为局部的保留字

语法

constraint g generator initValue expression

  • initValue 初始值 第一次取值的时候仍然会用 expression 去求一次值,也就是说,initValueref[0],第一次输出的值是 ref[1]
  • expression 一个合法的、不换行的 js_Expression 它需要返回一个值

例如

constraint g generator 0 prev+index

什么是局部的保留字

显然这个类型我们需要引用一些特殊的信息,比如当前处在 列表 的第几个,之前的值是什么样子的,所以需要在里面占用掉一些变量的名字。

但是这几个变量只有在这个约束求值的时候才会存在,所以叫做局部的保留字。

你仍然可以使用 index 作为一个约束的变量名,这不会冲突,只是在 generator 约束的求值中无法访问这个变量。

一些有意思的模板

比如sql测试数据

constraint 姓 set 赵 钱 孙 李
constraint 名 set 一 二 三 四
constraint value int 10 1000
constraint status int 0 2
repeat 10 INSERT INTO list (name, value, status) VALUES ("${姓}${名}", ${value}, ${status});

重新设计 `generator` 的 api

  • stringifygenerator 将分开实现
  • generator 的随机数取法抽象出来,允许在取随机数的时候由外部指定

format 语法

允许重写一个约束渲染时候的 template

语法

format varName template

比如

constraint w int 1 10
constraint g graph graphNum nodeNum edgeNum
format g ${value[0]} ${value[1]} ${w}

这样可以实现有权图,目前这个语法主要用来扩展 graph 类型

影响

这个信息会挂在到约束上面

因为 stringify 的时候是没有 format 信息的,所以这里

todo

  • 如果数据挂在到约束上面 (现在的 shuffle) 那么多 store 的设计会有问题,需要修改
  • 如果不挂到约束上面,可能需要重新设计几个模块交互的api rawTemplate rawValue
  • 求值顺序 对于一个 graph 来说,是求完所有的边再取 format 计算,还是一条边算完 format 再算下一条边

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.