Comments (11)
Hi @Avra2 ,
Here it is:
https://github.com/tech-srl/code2seq/blob/master/reader.py#L78-L87
The code is not as simple as one would imagine, because every example has a different number of paths, so we need to sample the paths of every example separately.
Let me know if you have any questions!
Uri
from code2seq.
@urialon. Thank you.
You mentioned in your paper that, "we represent node using a learned embedding matrix E^nodes and then encode the entire sequence using the final states of a bi-directional LSTM." What is embedding matrix E^nodes and how you get that in your code please?
from code2seq.
@urialon. Hello Doctor,
Can you please just add some hints what algorithm you used to sample over AST paths? What format your AST path is in in the first place? Have you used any AST parser to generate the AST tree, then you looped over that parsed AST tree to generate paths? For binary tree, I see it's easy to loop over it to generate all paths between all terminals, but not sure how you did that given that AST is an N-tree.
Thanks.
from code2seq.
Hi @Avra2 ,
See answers below.
What is embedding matrix E^nodes and how you get that in your code please?
This is a standard, simple, embedding matrix, initialized here:
https://github.com/tech-srl/code2seq/blob/master/model.py#L359
and used here: https://github.com/tech-srl/code2seq/blob/master/model.py#L519-L520
Can you please just add some hints what algorithm you used to sample over AST paths?
A simple sampling without repetitions.
What format your AST path is in in the first place?
See the README and the processed datasets.
Have you used any AST parser to generate the AST tree, then you looped over that parsed AST tree to generate paths?
Yes, we used JavaParser in our code, but basically every parser can work, the parser is only used at preprocessing time. The neural network is agnostic to the parser.
For binary tree, I see it's easy to loop over it to generate all paths between all terminals, but not sure how you did that given that AST is an N-tree.
Why is it different? For every pair of terminals, we can go up in the tree until we reach their common ancestor, and that is the shortest path.
Let me know if you have any more questions
Uri
from code2seq.
Hi @urialon,
I am using your technique in my research work. I want to split path into Right path and left path. Kindly guide me, how can I do this. Thanks in anticipation.
from code2seq.
Hi @sadiasahar ,
Thank you for your interest in our work.
Can you please provide more details?
Uri
from code2seq.
@urialon, thank you for the reply.
I can explain it with an example. Suppose the path between node elements and true is:
(elements, Name↑ FieldAccess↑ Foreach↓ Block↓ IfStmt↓ Block↓ Return↓ BooleanExpr, true)
Now I want to split path from common ancestor. In this Example, from 'Foreach' Node. The Output I am requiring is
(elements, [Name↑ FieldAccess↑], [Foreach↓ Block↓ IfStmt↓ Block↓ Return↓ BooleanExpr], true)
from code2seq.
I see. We tried something similar in this PLDI 2018 paper.
So what's the problem? Can you just edit the data files and split the paths?
from code2seq.
When I preprocessed my data, I got the output
['i', 'Nm0|Ls|For|VDE|Prim0', 'int']
The problem is, in the string
'Nm0|Ls|For|VDE|Prim0'
I am unable to locate common ancestor, that is why can not split the path according to my requirement. How can I locate the ancestor in the string?
from code2seq.
Right, I see. You can change these lines:
https://github.com/tech-srl/code2seq/blob/master/JavaExtractor/JPredict/src/main/java/JavaExtractor/FeatureExtractor.java#L25-L26
But then you'll need to re-build the java package, and re-preprocess the data.
Best,
Uri
from code2seq.
@urialon, thank you so much. I tried as you suggested and got required output.
from code2seq.
Related Issues (20)
- Generating embeddings for Python and Java HOT 5
- Help with implementing local service with JavaExtractor HOT 10
- I can not preprocess Python dataset
- Error running prediction on Code2seq released model
- I got Out of Memory Error during Training
- Unable to get embeddings from the trained model for Java
- Extract Path Contexts Only HOT 5
- InvalidArgumentError in sess.run() HOT 3
- Visualize Python AST HOT 2
- Extract java files HOT 2
- Getting "was not completed in time" error when preprocessing dataset HOT 11
- code2seq for Python HOT 3
- Error processing property '_dropout_mask_cache' of <ContextValueCache> HOT 6
- I am getting TimeError while using code2seq to predict long method HOT 2
- Generating code documentation with code2seq HOT 8
- Tensorflow out-of-bound error while trying to train the Code2Seq model on our own python dataset HOT 6
- Model is predicting empty string for custom python dataset HOT 8
- Exporting code vectors HOT 6
- Encountered error of preprocess data HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from code2seq.