Giter VIP home page Giter VIP logo

refazer's Introduction

Refazer

Refazer (rebuild, in Portuguese) is technique for automatically learning program transformations. It builds on the observation that code edits performed by developers can be used as input-output examples for learning program transformations. Example edits may share the same structure but involve different variables and subexpressions, which must be generalized in a transformation at the right level of abstraction.

Usage

Let's say that we want to learn a transformation that adds a missing call to a function. The following code illustrates how we can invoke Refazer passing an input-output example and Refazer learns a list o transformations that satisfy the example.

var input = 
@"def product(n, term):
  return term(n)*product(n-1)";
var output = 
@"def product(n, term):
  if n == 1: 
    return term(1)
  return term(n)*product(n-1)";
        
var examples = new List<Tuple<string, string>>() { Tuple.Create(input, output) };
var refazer = new Refazer4Python();
var transformations = refazer.LearnTransformations(examples);

After learning the transformations, we can get the top learned transformation and applied it to a program to add the base case.

if (!transformations.IsNullOrEmpty()) {
  var result = refazer.Apply(transformations.First(), input);
  if (!result.IsNullOrEmpty()) {
    //print the transformed program
    Console.Out.WriteLine(result.First());    
  } 
}

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.