Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generate input suitable for code2seq from PHP source

NotificationsYou must be signed in to change notification settings

morria/code2seq-paths-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Read PHP source code and produce a file suitable for use bycode2seqfor training and evaluating a model.

Usage

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.c2s

and 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.

Flags

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.

Docker

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 .

Output Format

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,x

Dependencies

To 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 composer

Alternatively you can use the.devcontainer/Dockerfile to builda system suitable for runningcode2seq-paths.

cd .devcontainerdocker compose build

Development

To run tests you can run./bin/test which will execute all PHPUnit tests.

About

Generate input suitable for code2seq from PHP source

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp