PyFuncAST-Lex / README.md
rehaidib's picture
Update README.md
c6a5bd7 verified
metadata
language:
  - en
tags:
  - software-engineering
  - code-analysis
  - refactoring
  - AST
  - lexical-features
  - Python
  - static-analysis
task_categories:
  - feature-extraction
pretty_name: Python Function's code feature
size_categories:
  - 1M<n<10M
license: cc-by-4.0

πŸ“Š Python Function-Level AST and Lexical Features Dataset

πŸ“ Dataset Summary

This dataset integrates function-level static analysis data from Python repositories.
It merges three data sources:

  1. Lizard Cyclomatic Analysis: provides complexity, NLOC, and basic function metadata.
  2. AST Extracted Features: includes detailed abstract syntax tree information such as token counts, parameters, variable extraction, and function bodies.
  3. Lexical Features: captures lexical and structural features of each function (e.g., class structure, modifiers, incoming/outgoing calls, and statement types) and presents it in natural language.

The resulting Dataset represents each Python function as a unified row combining complexity metrics, lexical information, and AST structure β€” enabling advanced research in:

  • Code comprehension
  • Automated refactoring
  • Software quality analysis
  • Function-level code search
  • Maintainability prediction
  • ML model training for software engineering tasks

🧠 Intended Uses

  • Feature extraction for code comprehension and maintainability modeling.
  • Supervised learning for:
    • Maintainability prediction (regression / ordinal classification).
    • Refactoring-need ranking (learning-to-rank).
  • Benchmarking code-representation learning or graph-based refactoring tools.
  • Downstream tasks such as clone detection, defect prediction, and code search.

πŸ“‚ Dataset Structure

Each row corresponds to one Python function identified across open-source repositories.

Columns

Column name Description
project_name Repository name
class_name Class name containing the function (if applicable)
class_modifiers Access modifiers of the class
class_implements Interfaces implemented
class_extends Class inheritance
function_name Function name
function_body Raw function body code
cyclomatic_complexity Cyclomatic complexity measure
NLOC Number of lines of code
num_parameter Number of function parameters
num_token Number of tokens
num_variable Number of variables detected in function
start_line / end_line Start and end line of the function in the file
function_index Function index in AST parsing
function_params Parameter names
function_variable Variable names extracted
function_return_type Return type (if inferred)
function_body_line_type Mapping of statement types inside the function (e.g., Assign, If, Return)
function_num_functions Number of functions declared inside
function_num_lines Number of lines of function (lexical)
outgoing_function_count / outgoing_function_names Number and names of functions called inside this function
incoming_function_count / incoming_function_names Number and names of functions calling this function
lexical_representation Present the code features as natural language.

βš™οΈ Data Sources

  • Static analysis performed on public Python repositories cloned from GitHub that apply the following characteristics (python language projects, commits > 500, and contributors > 10).
  • Function-level analysis uses:

πŸ§ͺ Dataset Creation

Collection

  1. Clone open-source Python repositories.
  2. Run Lizard static analysis to generate base metrics.
  3. Parse source files to extract AST and 15 code features.
  4. Convert code features to natural language using rule-based code.
  5. Merge the three sources

πŸ’‘ How to Load

    from datasets import load_dataset
    data = load_dataset("rehaidib/PyFuncAST-Lex", split="train")

or manually:

    import pandas as pd
    df = pd.read_parquet("PyFuncAST-Lex.parquet")

Citation

If you use this dataset, please cite:

  @dataset{PyFuncAST-Lex,
    title        = {PyFuncAST-Lex: Python Function-Level AST and Lexical Features Dataset},
    author       = {Reem Al-Ehaidib},
    year         = {2025},
    month        = {11},
    publisher    = {Hugging Face Datasets},
    version      = {1.0},
    url          = {https://huggingface.co/datasets/rehaidib/pyfunc_code_features}
  }