Open lyriccoder opened 2 years ago
Hi @lyriccoder , Can you please remind me what are you trying to achieve?
You are right that name1NodeId
etc are not needed in the prediction, they are for visualization purposes on the code2seq.org website.
So why do you need them? Or which fields do you need?
Currently, Code2seq sends a request to a server. I want to run it locally, without any network. I need to get the same json as your service returns.
Since I can run JavaExtractor manually, I want to run it locally, get the results and create json which is passed to the prediction function. But I see that the results of JavaExtractor and your service are different. I need to know the way you run JavaExtractor on your server, maybe you have additional parameters, etc. I just want to create the same json you return from the AWS server.
For some reason, your server returns more data: Some nodes are included in your response, but not included when I run JavaExtractor. E.g., I noticed if the shortPath
field of the json contains the GenericClass
substring, it won't be included in the result of JavaExtrator.
Hi @lyriccoder , So my question is why do you need exactly the same json? Some fields there are used only for visualization on the website.
I meant the json with fields which are needed for prediction. Some nodes are missing... Seems you are using another parameters in JavaExtractor. It can affect the prediction.
Can you please provide a code example that returns a different response in the service and in the local extractor? (where the difference is in the content, and not only the format?)
On Thu, Oct 28, 2021 at 4:38 AM lyriccoder @.***> wrote:
I meant the json with fields which are needed for prediction. Some nodes are missing... Seems you are using another parameters in JavaExtractor. It can affect the prediction.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tech-srl/code2seq/issues/105#issuecomment-953632700, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSOXMBQPNAA4KWG2C2QZFTUJED2BANCNFSM5GYA2QTQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
I did it in the previous message. Ok, let me show it again.
1) Here is the request I send:
curl -X POST https://po3g2dx2qa.execute-api.us-east-1.amazonaws.com/production/extractmethods -d '{"code": "public boolean f(Set<String> set, String value) { for (String entry : set) { if (entry.equalsIgnoreCase(value)) { return true ; } } return false; }", "decompose":"true"}'
I get the following response:
2) I run JavaExtractor with the following params:
java -cp JavaExtractor/JPredict/target/JavaExtractor-0.0.2-SNAPSHOT.jar JavaExtractor.App --max_path_length 9 --max_path_width 2 --file Input.java
I get the following response:
3) The difference is demonstrated below. Those values are in the http response, but they are missed in the result of JavaExtractor:
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
As you see, the examples with GenericClass
is only presented here
4) Inverted difference is demonstrated below. Those values are in the result of JavaExtractor, but they are missed in the http response:
string Cls0|Cls|Prm|Mth|Prm|VDID0 value
string Cls0|Cls|Prm|Mth|Prm|Cls1 string
METHOD_NAME Nm1|Mth|Prm|Cls|Cls0 string
string Cls0|Cls|Prm|Mth|Bk|Foreach|Bk|If|Cal0|Nm2 value
set VDID0|Prm|Cls|Cls0 string
value VDID0|Prm|Mth|Bk|Foreach|Bk|If|Bk|Ret|BoolEx0 true
boolean Prim0|Mth|Prm|Cls|Cls0 string
string Cls0|Cls|Prm|Mth|Bk|Foreach|VDE|Cls0 string
string Cls1|Prm|Mth|Bk|Foreach|Bk|If|Bk|Ret|BoolEx0 true
string Cls0|Cls|Prm|Mth|Bk|Foreach|Bk|If|Cal0|Nm0 entry
set VDID0|Prm|Mth|Bk|Foreach|Bk|If|Bk|Ret|BoolEx0 true
string Cls0|Cls|Prm|Mth|Bk|Foreach|Bk|If|Cal0|Nm3 equals|ignore|case
string Cls0|Cls|Prm|Mth|Bk|Ret|BoolEx0 false
string Cls0|Cls|Prm|Mth|Bk|Foreach|Nm1 set
string Cls0|Cls|Prm|Mth|Bk|Foreach|VDE|VD|VDID0 entry
I see. Good catch!
I will try to debug this. In the meantime, you can use the JavaExtractor because this is the extractor that the model was trained with. The cases of "inverted difference" might be due to the differences in parameters: you used --max_path_length 9
instead of --max_path_length 8
.
Uri
Hi@lyriccoder Could you please tell me how do you run JavaExtractor locally ? I found your repository code2seq still used the api to extract codes, but in this issue it seemed that you had already run it locally.My purpose is to extract codes locally.
java -cp JavaExtractor/JPredict/target/JavaExtractor-0.0.2-SNAPSHOT.jar JavaExtractor.App --max_path_length=8 --max_path_width=2 --file filename
There is a hardcoded filename inside extractor.py
or interactive_predict.py
. It rewrites Input.java
and passes into the filename
param
Thanks!!!! I made it!
Hi @urialon.
Could you please tell me how do you construct a json for the service
https://po3g2dx2qa.execute-api.us-east-1.amazonaws.com/production/extractmethods
?I requested the following procedure (you used it in the previous issue):
I tried to run JavaExtractor with the following params (I found them in
extract.py
):Running: java -cp /app/JavaExtractor/JPredict/target/JavaExtractor-0.0.2-SNAPSHOT.jar JavaExtractor.App --max_path_length 9 --max_path_width 2 --file /app/Input.java
.It returned me the following result:
I noticed that some values are missed, e.g.:
How can I get absolutely the same items? 1) Actually, I see that "name1NodeId", "name2NodeId", "name1TokenNum", "name2TokenNum" are pointed to the nodes of the ast tree and they are not needed in the prediction function. Also, I see that ast tree is not also used. Is it right?
2) So, the last part is to understand how you are getting the response. Usually there are missing values in the result of JavaExtractor, and they are usually related to
GenericClass1
value. Also, I noticed that some values in the response are missed, but they exist in the result of JavaExtractor:Could you please tell me, how do u run JavaExtractor on your server?