Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Path Contexts Only #110

Closed
Avv22 opened this issue Dec 5, 2021 · 5 comments
Closed

Extract Path Contexts Only #110

Avv22 opened this issue Dec 5, 2021 · 5 comments

Comments

@Avv22
Copy link

Avv22 commented Dec 5, 2021

Hello,

Given that both your models code2seq and code2vec are initially made to predict method name from source code body represented as path context, can you please give give how to extract path context as we are just looking for source code representation of the source code.

Thank you.

@urialon
Copy link
Contributor

urialon commented Dec 7, 2021 via email

@lyriccoder
Copy link

lyriccoder commented Dec 8, 2021

Seems @Avra2 wants to get paths.
Try to compile Java application inside the project or just find the compiled jar file.

You can run it with java -cp JavaExtractor/JPredict/target/JavaExtractor-0.0.2-SNAPSHOT.jar JavaExtractor.App --max_path_length=8 --max_path_width=2 --file filename, where filename is a file with a java function.

Suppose, you have the code:

public boolean f(Set<String> set, String value) 
{  
   for (String entry : set) 
   {  
       if (entry.equalsIgnoreCase(value)) 
       {  
           return true ;   
        }  
   }  
   return false;  
}

So, the code will be translated into the following list of paths:

set GenericClass1|Prm|Mth|Bk|Foreach|VDE|VD|VDID0 entry
METHOD_NAME Nm1|Mth|Prm|GenericClass1 set
set GenericClass1|Prm|Mth|Bk|Foreach|VDE|Cls0 string
set VDID0|Prm|GenericClass|Cls0 string
string Cls0|GenericClass|Prm|Mth|Bk|Foreach|VDE|VD|VDID0 entry
string Cls0|GenericClass|Prm|Mth|Prm|Cls1 string
set GenericClass|Cls0 string
set GenericClass1|Prm|Mth|Bk|Foreach|Nm1 set
string Cls0|GenericClass|Prm|Mth|Bk|Foreach|Nm1 set
boolean Prim0|Mth|Prm|GenericClass|Cls0 string
METHOD_NAME Nm1|Mth|Prm|GenericClass|Cls0 string
set GenericClass1|Prm|Mth|Prm|VDID0 value
set GenericClass1|Prm|Mth|Bk|Ret|BoolEx0 false
set GenericClass1|Prm|Mth|Bk|Foreach|Bk|If|Cal0|Nm3 equals|ignore|case
boolean Prim0|Mth|Prm|GenericClass1 set
string Cls0|GenericClass|Prm|Mth|Prm|VDID0 value
set GenericClass1|Prm|Mth|Bk|Foreach|Bk|If|Cal0|Nm2 value
set GenericClass1|Prm|Mth|Bk|Foreach|Bk|If|Cal0|Nm0 entry
set VDID0|Prm|GenericClass1 set
string Cls0|GenericClass|Prm|Mth|Bk|Ret|BoolEx0 false
string Cls0|GenericClass|Prm|Mth|Bk|Foreach|VDE|Cls0 string
set GenericClass1|Prm|Mth|Prm|Cls1 string

Did u want those lists of paths (you called it "path context")?

@Avv22
Copy link
Author

Avv22 commented Dec 8, 2021

@lyriccoder @urialon. Thanks for response. By path context, I don't refer to paths extracted by parser but aggregated path learned by your model by the help of attention mechanism as this should be "the most that contributes to method name" please? So can we use this "vector that the most that contributes to method name" as representation embedding for the whole file or this is just useful for your task, which is method name prediction? If this vector can be used for various tasks, then can you please show how to extract it from your network during training?

Thanks.

@urialon
Copy link
Contributor

urialon commented Dec 10, 2021 via email

@Avv22 Avv22 closed this as completed Apr 12, 2022
@Avv22
Copy link
Author

Avv22 commented Apr 12, 2022

@urialon. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants