- Notifications
You must be signed in to change notification settings - Fork0
Generate input suitable for code2seq from PHP source
morria/code2seq-paths-php
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Read PHP source code and produce a file suitable for use bycode2seqfor training and evaluating a model.
To build the package just runcomposer install. Make sure you have PHP installed along withthephp-ast extension. You can also use the Dockercontainer with all dependencies defined in.devcontainer.
Once built you can run the tool via
./bin/code2seq-paths path/to/php/dir > method_contexts.c2sand from here you can use the filemethod_contexts.c2s as input tocode2seq.Keep in mind that the file produced here will need to be preprocessed withincode2seq.
TODO: describe how to do that.
You can see the available flags via./bin/code2seq-paths --help.
Usage: ./bin/code2seq-paths [options] [files...]] -h, --help Get this help information -s SEED, --seed SEED The seed to use before shuffling the target contexts. -l LENGTH, --max-length=LENGTH The maximum length of a target context. Defaults to unbounded. -i, --ids Use IDs rather than names for context nodes. Defaults to false. ... All other options will be treated as file names to read as PHP source.To avoid setting up a proper environment, you can runcode2seq-paths-php froma Docker image as follows.
docker pull morria/code2seq-paths-phpdocker run --name code2seq-paths-php --volume PATH_TO_SOURCE:/workspace morria/code2seq-paths-php /workspace/To build the container from source run the following.
composer installdocker build -t morria/code2seq-paths-php .The output is structured as follows.
LINE := FUNCTION_NAME WS CONTEXT_LIST;FUNCTION_NAME := string;WS := ' ';CONTEXT_LIST := SOURCE_TERMINAL ',' NODE_LIST ',' TARGET_TERMINAL;SOURCE_TERMINAL := TOKEN_LIST;TARGET_TERMINAL := TOKEN_LIST;NODE_LIST := NODE | NODE '|' NODE_LIST ;NODE := string;For the input code
<?phpfunctionf(int$x){return$x;}
the following output will be produced
f long,parameter,x long,parameter|function|return|variable,x x,parameter,long x,parameter|function|return|variable,x x,variable|return|function|parameter,long x,variable|return|function|parameter,xTo runcode2seq-paths you'll need to have several dependencies installed on your system.
These can be installed on Ubuntu machines via
sudo apt-get install php php-ast composerAlternatively you can use the.devcontainer/Dockerfile to builda system suitable for runningcode2seq-paths.
cd .devcontainerdocker compose buildTo run tests you can run./bin/test which will execute all PHPUnit tests.
About
Generate input suitable for code2seq from PHP source
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.