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());    
  } 
}

refazer's People

Contributors

eglassman avatar gustavoasoares avatar ruanvictorreis 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  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

refazer's Issues

What is the purpose of this function? It's causing an error

https://github.com/gustavoasoares/refazer/blob/features/extraction/Refazer.Test/TestUtils.cs#L17-L20

Error preventing successful build:

Severity Code Description Project File Line Suppression State
Error CS7036 There is no argument given that corresponds to the required formal parameter 'id' of 'TestUtils.AssertCorrectExtraction(string, int)' Refazer.Test C:\Users\eglassman\Source\SecondCopyRepos\refazer\Refazer.Test\TestUtils.cs 19 Active

how to install or use refazer on linux

hi,
i am going to use refazer on linux. And when i loaded refazer.sln with Rider, i have seen errors as following.


10/19/17
11:14 AM Project 'Refazer' load finished with warnings: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. at (1122:5)

11:14 AM .NET Framework is not found: MsBuild can not find TargetFramework assemblies, specify a Mono MSBuild in settings. You can download the latest stable Mono release. Also install msbuild package.

11:14 AM Project 'Refazer.WebAPI' load failed: The imported project "/usr/share/dotnet/sdk/2.0.0/Microsoft/VisualStudio/v15.0/WebApplications/Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. /usr/info/code/csharp/refazer-0.1/Refazer.WebAPI/Refazer.WebAPI.csproj at (553:3)

11:14 AM MSBuild targets were not found: Make sure that all SDKs required for projects in this solution are installed, or specify a different MSBuild version in settings.

11:14 AM Project 'Refazer.Test' load finished with warnings: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. at (1122:5)

11:15 AM Project 'Refazer' load finished with warnings: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. at (1122:5)

11:15 AM .NET Framework is not found: MsBuild can not find TargetFramework assemblies, specify a Mono MSBuild in settings. You can download the latest stable Mono release. Also install msbuild package.

11:15 AM Project 'Refazer.Test' load finished with warnings: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. at (1122:5)


It seems to be related with .NETFramework, Version...
Any one here can offer me some suggestion about how to fix this problem...

Learn extraction programs from multiple examples

Here's the method to adapt:

[TestMethod]
        public void TestLearnMultipleExamples1()
        {
            var examples = new List<Tuple<string, string>>();
            var before = @"i = 0";
            var after = @"i = 1";
            examples.Add(Tuple.Create(before, after));
            before = @"i, j = 0, 1";
            after = @"i, j = 1, 1";
            examples.Add(Tuple.Create(before, after));
            TestUtils.AssertCorrectTransformation(examples);
        }

Improve performance of web api

Currently, we are sequentially testing all incorrect submissions. The time to test about 300 submissions against one transformation is ranging from a couple of seconds to minutes, depending on the transformation.

One problem is when the transformation leads to an infinite loop or recursion, which stops after the timeout. If there are many timeouts, it will slow down the process.

Try to add parallelism to improve the performance.

Remove Prose dependence in Test project

When running the test cases, we need to add the Prose and Code Analysis libraries to the test project, otherwise Prose throws an exception. These libraries should not be required since they are already important in the Refazer project.

Node ID's look off

image

When our Root Node is:
{PythonAst(){ SuiteStatement(){ AssignmentStatement(){ NameExpression(j) literal(1) } } }}
and its Children are:
{SuiteStatement(){ AssignmentStatement(){ NameExpression(j) literal(1) } } }

Difficulty compiling; apparent package update and namespace issues

After trying to update my packages, I got the following error:

Could not install package 'Microsoft.CodeAnalysis.Common 2.2.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

@gustavoasoares, what .NETFramework version do you have?

The tutorial in the Readme doesnt work for me

hello,
I am doing some research on Programming language correction and i found this project of yours which i think is very interesting.
However, i am not quite familiar with C# and i didnt get to see the results of the project. Can you give me a quick tutorial on how to use it. I tried to build the project in Vscode it gives me some errors when building the refazerweb , and also when trying to execute the Readme tutorial it tells me there is some problems with nuget packages or that it does not recognize the IsNullorEmpty fonction. Also, the test does not succeed only 5 or 6 of them, so i am a bit confused as i would really love to test this project.
If you have some explanation or help it would be wonderful.
Thank you very much

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.